Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th March 2005, 14:59   #1  |  Link
Guest
Guest
 
Posts: n/a
How to read fourcc in avi and use it in avisource?

I wonder if there ia a way to read the fourcc(codec)in avi file, before opening it with avisource - in order to open the avi with the proper codec?

I want to get avisynth to do this automaticly so any avi can be opened with the right codec if it is installed.

On reading the fourcc's I found this:
Quote:
If you open the AVI file in Windows Wordpad (in Start/Programs/Accessories) you should see something along the lines of "vidsXXXX" somewhere in the top few lines of garbage displayed. In this case, the XXXX is the FOURCC that the AVI file needs to decode its video.
It's from here!

Has anyone found a solution to this?

Tin2tin
  Reply With Quote
Old 20th March 2005, 15:41   #2  |  Link
Leak
ffdshow/AviSynth wrangler
 
Leak's Avatar
 
Join Date: Feb 2003
Location: Austria
Posts: 2,441
Re: How to read fourcc in avi and use it in avisource?

Quote:
Originally posted by Guest
I wonder if there ia a way to read the fourcc(codec)in avi file, before opening it with avisource - in order to open the avi with the proper codec?

I want to get avisynth to do this automaticly so any avi can be opened with the right codec if it is installed.
Ummm... how else do you think AviSynth is handling this? It looks at the FourCC of the AVI file you specify and tries opening it with the codec that's registered with Windows for this FourCC.

If the FourCC is bogus, or you want to use a different codec, use a different FourCC by adding a FourCC="...." parameter to your AVISource call...

Isn't this what you're looking for?

np: Markus Guentner - Regensburg 1 (Regensburg)
Leak is offline   Reply With Quote
Old 20th March 2005, 16:36   #3  |  Link
Guest
Guest
 
Posts: n/a
Oh, so avisynth is all ready doing this automatically!? I didn't know.

Thanks,

Tin2tin
  Reply With Quote
Old 20th March 2005, 21:49   #4  |  Link
Maximillius
Guest
 
Posts: n/a
Quote:
Originally posted by Guest
Oh, so avisynth is all ready doing this automatically!? I didn't know.
Of course. It's no different then when opening an avi in virtualdub or in any media player and it reads the fourcc info in the avi header and tries opening it using that codec. It's nothing magical.

Last edited by Maximillius; 20th March 2005 at 21:56.
  Reply With Quote
Old 20th March 2005, 23:03   #5  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
And if you want to change your Mpeg4 .AVI's 4CC code, you can always use "Nic's FourCC changer": -




Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 20th March 2005, 23:23   #6  |  Link
Guest
Guest
 
Posts: n/a
The reason for my question is that I'm trying to figure out an error free way to load any avi file into avisynth from my DVD slideshow GUI - or at least find a way to throw a warning/avoid loading/suggest a codec - if the user is loading an avi with an unsupported/uninstalled codec.

Thanks for your replys,
Tin2tin
  Reply With Quote
Old 23rd March 2005, 17:01   #7  |  Link
ShawnFumo
Registered User
 
Join Date: Mar 2005
Posts: 65
Actually, I'd love to have access to the FourCC of an AVI within avisynth itself, to help with the NLE I'm trying to build on it. There may be some CLI program that can spit back a FourCC, but I'd like to keep as much of the loading process within Avisynth itself as possible.

When I first load a file, I'm using WriteFileStart to create a text file with the clip's original properties (height, framecount, colorspace, etc). Having access to the FourCC so that I could write it out in the same place would be quite helpful. I was able to make a function to spit out colorspace (using the various isRGB24, etc), but I don't think there's any current way to get the FourCC.

So, would someone be able to hack together a variation on AVISource that just returns the FourCC as a string instead of returning the actual clip? That'd be great for my own uses (and Tin2tin's) and could also help automation in other people's scripts. Like if you know the file is DV, you can assume that it needs to be de-interlaced and take that into account.

Many thanks,
Shawn
ShawnFumo is offline   Reply With Quote
Old 23rd March 2005, 21:10   #8  |  Link
Guest
Guest
 
Posts: n/a
I got some help on solving this on the wxbasic forum.
I guess that this solution could be ported to a c function, since there is no readfile(txt) in avisynth yet(as far as I know). But I'm not into c.
Tin2tin

Last edited by Guest; 24th March 2005 at 01:49.
  Reply With Quote
Old 24th March 2005, 05:24   #9  |  Link
ShawnFumo
Registered User
 
Join Date: Mar 2005
Posts: 65
Hmmm, now that you mention it, I should be able to grab the FourCC using Python's various file-reading commands. I still think it'd be more elegant to be able to grab it from within Avisynth, though. Maybe I'll try tackling an avisynth plugin eventually, but I don't want to pull myself in too many directions at the moment.

I didn't realize that wxBasic existed! I think I'll stick with wxPython since it seems so well-supported, but that's really cool that wx apps can be done in basic. I've been meaning to try out your DVDSlideshowGUI but haven't had a chance yet.

Cheers,
Shawn
ShawnFumo is offline   Reply With Quote
Old 14th April 2005, 21:56   #10  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
@Guest,

Trev created a small plugin (and i tweaked it a bit):

http://www.geocities.com/wilbertdijkhof/AVIInfo_v02.zip

It opens an avi without decompressing any frames, and is able to give info about the video/audio streams. It always outputs to a string.

Example usage:

Code:
# returns framerate of video
clip = ...
Value(clip.AVIInfo(framerate,1)) # value converts string to int (actually float i guess)

# returns fourCC
clip = ...
clip.AVIInfo(fourCC,1)
Wilbert is offline   Reply With Quote
Old 15th April 2005, 10:15   #11  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Very nice! Thanks!
tin3tin is offline   Reply With Quote
Old 16th April 2005, 21:15   #12  |  Link
danpos
BDVD Team
 
danpos's Avatar
 
Join Date: Dec 2004
Location: Rio de Janeiro - RJ/Brasil
Posts: 306
@Wilbert

Hi! Is there some way to redirect the AVIInfo output for a text file?

Cheers,
danpos is offline   Reply With Quote
Old 16th April 2005, 23:36   #13  |  Link
danpos
BDVD Team
 
danpos's Avatar
 
Join Date: Dec 2004
Location: Rio de Janeiro - RJ/Brasil
Posts: 306
@Wilbert

I´ve tried the AVIInfo plugin and it worked (almost) like a charm, because of a information about sample rate of audiostream was bogus (38 KHz instead of 44.1 KHz)... I've used in this way:

Code:
c="movie.avi"

BlankClip

\Subtitle("Stream 1: " + c.AVIInfo("type",1),20,20).

\Subtitle("Codec: " + c.AVIInfo("fourCC",1),20,40).

\Subtitle("Framerate: " + c.AVIInfo("framerate",1),20,60).

\Subtitle("# de frames: " + c.AVIInfo("length",1),20,80).

\Subtitle("Largura: " + c.AVIInfo("width",1),20,100).

\Subtitle("Altura: " + c.AVIInfo("height",1),20,120).

\Subtitle("Stream 2: " + c.AVIInfo("type",2),20,140).

\Subtitle("Samplerate: " + c.AVIInfo("framerate",2),20,160).

\Subtitle("# de amostras: " + c.AVIInfo("length",2),20,180)
BTW, it's a good plugin that can to be used in a lot of situations ...

Cheers,

EDIT: I've tried the above script using a another avi file with framerate of 23.976 for video stream. AVIInfo returns 23.00000000 as the framerate value. So, I think that (perhaps) the rounding routine must be reviewed ...

Last edited by danpos; 17th April 2005 at 00:06.
danpos is offline   Reply With Quote
Old 17th April 2005, 04:18   #14  |  Link
stickboy
AviSynth Enthusiast
 
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
Quote:
Originally posted by danpos
Hi! Is there some way to redirect the AVIInfo output for a text file?
You can use one of the WriteFile functions to output a string to a text file.

Wilbert:
The documentation to AVIInfo is misleading; its first argument is a filename, not a clip.

Looking through the code regarding that rounding error:
Code:
float fps = float(psi.dwRate/psi.dwScale);
should be:
Code:
float fps = float(psi.dwRate)/psi.dwScale;
(BTW, why bother with the enums if you use hard-coded magic numbers? )
stickboy is offline   Reply With Quote
Old 17th April 2005, 04:34   #15  |  Link
trevlac
budala
 
Join Date: Oct 2003
Location: U.S.
Posts: 545
@Wilbert,

Code:
//*** Change this ****
float fps = float(psi.dwRate/psi.dwScale); // framerate (audio: samplerate)

//*** To this ****
float fps = float((float)psi.dwRate/(float)psi.dwScale); // framerate (audio: samplerate)
I think because both rate and scale are integers, the result of their division is an integer. Then it is being changed to a float. Very subtle bug.

@danpos

AVIInfo is looking at the stream header. For Audio, the sample rate is also in the actual audio stream. This might be why you get 38 vs 44. Maybe the header level one is not the best to look at. I think wilbert is going to enhance AVIInfo to add channels for audio. Then he will be looking at the actual audio stream.


--------------
damb ... stickboy pointed out the bug and I didn't even notice his post. Must be late.
trevlac is offline   Reply With Quote
Old 17th April 2005, 13:45   #16  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Oops. Thanks for your comments.

Quote:
BTW, why bother with the enums if you use hard-coded magic numbers?
Because I couldn't find out how to use it properly Isn't it possible to do it soft-coded?

Anyway, the following version should work properly

http://www.wilbertdijkhof.com/AVIInfo_v03.zip

@danpos, could you check it? The 38 KHz should also be fixed.

@Trev,
Quote:
Maybe the header level one is not the best to look at.
The samplerate is taken from the stream level. It's related to this rounding error.

Quote:
I think wilbert is going to enhance AVIInfo to add channels for audio.
Later

edit: updated link

Last edited by Wilbert; 15th October 2010 at 21:31.
Wilbert is offline   Reply With Quote
Old 17th April 2005, 20:59   #17  |  Link
stickboy
AviSynth Enthusiast
 
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
Quote:
Originally posted by Wilbert
Because I couldn't find out how to use it properly Isn't it possible to do it soft-coded?
You really should use the enums instead... It's much more readable.
Code:
enum info_t { type, fourCC, framerate, width, height, length, skew };
info_t info;

// ...

if (lstrcmpi(_info, "type") == 0)
 info = type;
else if (lstrcmpi(_info, "fourCC") == 0)
  info = fourCC;
// ... et cetera ...
stickboy is offline   Reply With Quote
Old 18th April 2005, 02:08   #18  |  Link
danpos
BDVD Team
 
danpos's Avatar
 
Join Date: Dec 2004
Location: Rio de Janeiro - RJ/Brasil
Posts: 306
@stickboy

Thanks for the hint about to output the AVIInfo informations to text file!

@Trevlac

Thanks for your support and good explanation about the question!

@Wilbert

I´ve tried the new version of plugin and it's returning the correct video stream framerate, but the audio stream sample rate remains bogus (now, I´ve tried with a .avi file which audio stream presents 48 KHz as sample rate ) ... BTW the plugin will help me a lot with a little utility that I´m developing for now ...

Keep up the good work, mate!
danpos is offline   Reply With Quote
Old 18th April 2005, 09:21   #19  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
but the audio stream sample rate remains bogus (now, I´ve tried with a .avi file which audio stream presents 48 KHz as sample rate
Could you give me some info? The duration of those streams, the type of audio (although that shouldn't matter) ...

edit: ok. This happens with mp3 in avi (uncompressed audio in avi works fine).

Last edited by Wilbert; 18th April 2005 at 22:21.
Wilbert is offline   Reply With Quote
Old 20th April 2005, 01:18   #20  |  Link
danpos
BDVD Team
 
danpos's Avatar
 
Join Date: Dec 2004
Location: Rio de Janeiro - RJ/Brasil
Posts: 306
Quote:
Originally posted by Wilbert

edit: ok. This happens with mp3 in avi (uncompressed audio in avi works

fine).
yep, I do confirm that audio stream in .avi that I've used to test the pluglin is .mp3 ..

Cheers,
danpos is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:56.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.