framerate denominator and numerator got much bigger after encoding
I transcoded an avi file frame-served by avisynth with xvid codec by MEncoder. In the avs script, I manually changed the source framerate by writing something lik "changefps(24000,1001)", which means the framerate is about 23.976 with denominator to be 1001 and numerator to be 24000 (a standrad NTSC film setting). But when I checked the ouput video file after encoding, the denominator and numerator turned out to be bigger than 100000000, though the calculated framerate is still approximately 23.976. Could anyone tell me how I can control the behaviour of MEncoder so that the denominator and numerator will stay the same as the source? Thanks
On Wed, 23 Apr 2008 09:06:38 +0800 JRaSH <jrash06@163.com> wrote:
Could anyone tell me how I can control the behaviour of MEncoder so that the denominator and numerator will stay the same as the source?
There is no numerator or denominator. There is only a single frame-rate value stored in the file. There are millions of possible different ways to represent that number it, for the sake of humans.
RC wrote:
On Wed, 23 Apr 2008 09:06:38 +0800 JRaSH <jrash06@163.com> wrote:
Could anyone tell me how I can control the behaviour of MEncoder so that the denominator and numerator will stay the same as the source?
There is no numerator or denominator. There is only a single frame-rate value stored in the file. There are millions of possible different ways to represent that number it, for the sake of humans.
In AVI, samplerate and framerate are stored as a numerator and denominator: dwRate and dwScale. http://msdn2.microsoft.com/en-us/library/ms902872.aspx ----------------------------------------------------------------------- dwScale Used with dwRate to specify the time scale that this stream will use. Dividing dwRate by dwScale gives the number of samples per second. For video streams, this rate should be the frame rate. For audio streams, this rate should correspond to the time needed for nBlockAlign bytes of audio, which for PCM audio simply reduces to the sample rate. dwRate See dwScale. ----------------------------------------------------------------------- To the original poster: what values are you seeing? Run "mplayer -v outputfile.avi" and look for a block like this: ====== STREAM Header ===== Type: vids FCC: xvid (64697678) Flags: 0 Priority: 0 Language: 0 InitialFrames: 0 Rate: 24000/1001 = 23.976 <---------look at this line Start: 0 Len: 83093 Suggested BufferSize: 108990 Quality 10000 Sample size: 0 ========================== In general, mplayer will simply copy the input framerate to the output framerate, unless you specify -ofps. I think the problem is in the avisynth demuxer, but I can't test it. Try the attached patch. Maybe it'll work; maybe it'll segfault; maybe it won't compile. You can additionally try removing the line right above the lines my patch adds: sh_video->fps = (float) ((float) AVS->video_info->fps_numerator / ... -Corey Index: libmpdemux/demux_avs.c =================================================================== --- libmpdemux/demux_avs.c (revision 26473) +++ libmpdemux/demux_avs.c (working copy) @@ -301,6 +301,8 @@ sh_video->format = mmioFOURCC('Y', 'V', '1', '2'); sh_video->fps = (float) ((float) AVS->video_info->fps_numerator / (float) AVS->video_info->fps_denominator); sh_video->frametime = 1.0 / sh_video->fps; + sh_video->video->dwRate = AVS->video_info->fps_numerator; + sh_video->video->dwScale = AVS->video_info->fps_denominator; sh_video->bih = malloc(sizeof(BITMAPINFOHEADER) + (256 * 4)); sh_video->bih->biCompression = sh_video->format;
Corey Hickey wrote:
RC wrote:
On Wed, 23 Apr 2008 09:06:38 +0800 JRaSH <jrash06@163.com> wrote:
Could anyone tell me how I can control the behaviour of MEncoder so that the denominator and numerator will stay the same as the source?
There is no numerator or denominator. There is only a single frame-rate value stored in the file. There are millions of possible different ways to represent that number it, for the sake of humans.
To the original poster: what values are you seeing? Run "mplayer -v outputfile.avi" and look for a block like this:
====== STREAM Header ===== Type: vids FCC: xvid (64697678) Flags: 0 Priority: 0 Language: 0 InitialFrames: 0 Rate: 24000/1001 = 23.976 <---------look at this line Start: 0 Len: 83093 Suggested BufferSize: 108990 Quality 10000 Sample size: 0 ==========================
Interestingly, I tried your way to check the header, and it turned out to be right!!! My way to check the dominator was writing a avs script like: a=directshowsource("encoded.avi") messageclip(string(a.FramerateNumerator)+" "+string(a.FramerateDenominator)) and then when this avs was played, it showed a message: "52484375 2189038", which means the numerator is 52484375, and the dominator 2189038. Obviously, it is avisynthis that has a bug not mencoder. Thank you for your advice. JRaSH
participants (3)
-
Corey Hickey -
JRaSH -
RC