Mpeg duration too short
Hello, I'm using mencoder to generate DVD-conform MPEGs from lossless FFv1/pcm_16sle AVI files. While doing so, I've realized that in 9/10 of all cases, the resulting mpegs are too short. Sometimes just a few frames, but often a few seconds - and once even 7 minutes! == Example and infos about reproducing the error: 1) Original lossless video - duration=1500 frames: http://download.das-werkstatt.com/pb/mthk/examples/mencoder_mpeg/vx-04690_01... 2) Resulting MPEG - duration=1475 frames: http://download.das-werkstatt.com/pb/mthk/examples/mencoder_mpeg/vx-04690_01... 3) Command line and uncut output of encoding: http://pastebin.com/JcRCQy5y 4) FFprobe output to see the duration: Original: http://pastebin.com/49VU3hmb MPEG: http://pastebin.com/ekkqLP1K == Additional information: The resulting MPEGs are very often too short, but not always. It seems to be depending on the material within the video - and even the audio (!). In one case, I've removed the audio stream from the original lossless AVI and the resulting MPEG then had the full duration. Another thing I've noticed is, that the number of missing frames at the end somehow correlates with the keyframe-interval (keyint) used. In this case, the MPEG was encoded with keyint=25. Exactly the number of missing frames at the end. It seems that the missing frames are only dropped at the end of the video - not in between. I've verified that. I'd be very very happy for any information about why this happens - and how to resolve this, as I'd need the MPEG to match the original duration frame-exact. Thank you very much, Peter B.
Peter B. <pb <at> das-werkstatt.com> writes:
I'm using mencoder to generate DVD-conform MPEGs from lossless FFv1/pcm_16sle AVI files. While doing so, I've realized that in 9/10 of all cases, the resulting mpegs are too short.
Is this also reproducible with FFmpeg? Carl Eugen
Zitat von Carl Eugen Hoyos <cehoyos@ag.or.at>:
Peter B. <pb <at> das-werkstatt.com> writes:
I'm using mencoder to generate DVD-conform MPEGs from lossless FFv1/pcm_16sle AVI files. While doing so, I've realized that in 9/10 of all cases, the resulting mpegs are too short.
Is this also reproducible with FFmpeg?
I don't know yet, but I'll give it a try. Pb
Zitat von Carl Eugen Hoyos <cehoyos@ag.or.at>:
Peter B. <pb <at> das-werkstatt.com> writes:
I'm using mencoder to generate DVD-conform MPEGs from lossless FFv1/pcm_16sle AVI files. While doing so, I've realized that in 9/10 of all cases, the resulting mpegs are too short.
Is this also reproducible with FFmpeg?
I've now tried with FFmpeg (git version: N-36728-g794006f), and the duration is fine - so it's mencoder-specific. However, there's an interesting issue caused by FFmpeg: The first frame of the video is extremely ugly pixelated: http://download.das-werkstatt.com/pb/mthk/examples/mencoder_mpeg/vx-04690_01... I assume this could be related by the "rc buffer underflow" warning? The rest of the MPEG generated with FFmpeg is fine. // ------------------------------- ffmpeg -i input/hires/vx-04690_01-026s.avi -target pal-dvd -vcodec mpeg2video -bufsize 1835k -maxrate 8000k -b:v 4000k -g 25 -vstrict 0 -acodec ac3 -ab 192k out/026s-ffmpeg.mpg ffmpeg version N-36728-g794006f Copyright (c) 2000-2012 the FFmpeg developers built on Jan 12 2012 09:16:04 with gcc 4.4.5 configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-postproc --enable-swscale --enable-avfilter --enable-pthreads --enable-bzlib --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-zlib --enable-libopenjpeg --enable-decoder=png --enable-encoder=png --enable-libdirac --enable-libschroedinger libavutil 51. 34.100 / 51. 34.100 libavcodec 53. 55.100 / 53. 55.100 libavformat 53. 29.100 / 53. 29.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 58.100 / 2. 58.100 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 6.100 / 0. 6.100 libpostproc 51. 2.100 / 51. 2.100 Input #0, avi, from 'input/hires/vx-04690_01-026s.avi': Metadata: encoder : Lavf53.28.100 Duration: 00:01:00.00, start: 0.000000, bitrate: 37457 kb/s Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv422p, 720x576, 25 tbr, 25 tbn, 25 tbc Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s [buffer @ 0x9024c40] w:720 h:576 pixfmt:yuv422p tb:1/1000000 sar:0/1 sws_param: [buffersink @ 0x901cc40] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out' [scale @ 0x901cfa0] w:720 h:576 fmt:yuv422p -> w:720 h:576 fmt:yuv420p flags:0x4 Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt' [ac3 @ 0x901b080] channel_layout not specified [ac3 @ 0x901b080] No channel layout specified. The encoder will guess the layout, but it might be incorrect. Output #0, dvd, to 'out/026s-ffmpeg.mpg': Metadata: encoder : Lavf53.29.100 Stream #0:0: Video: mpeg2video, yuv420p, 720x576, q=2-31, 4000 kb/s, 90k tbn, 25 tbc Stream #0:1: Audio: ac3, 48000 Hz, stereo, flt, 192 kb/s Stream mapping: Stream #0:0 -> #0:0 (ffv1 -> mpeg2video) Stream #0:1 -> #0:1 (pcm_s16le -> ac3) Press [q] to stop, [?] for help [mpeg2video @ 0x9017f80] rc buffer underflow frame= 1500 fps= 24 q=2.0 Lsize= 30798kB time=00:00:59.96 bitrate=4207.8kbits/s video:28827kB audio:1406kB global headers:0kB muxing overhead 1.868384%
Peter B. <pb <at> das-werkstatt.com> writes:
Is this also reproducible with FFmpeg?
I've now tried with FFmpeg (git version: N-36728-g794006f), and the duration is fine - so it's mencoder-specific.
(The following discussion should probably be moved to ffmpeg-user or trac.)
However, there's an interesting issue caused by FFmpeg: The first frame of the video is extremely ugly pixelated:
Does this disappear with ffmpeg -threads 1 -i ... -threads 1 out/ffmpeg.mpg ? (with only one of the "-threads 1 ?) Carl Eugen
Zitat von Carl Eugen Hoyos <cehoyos@ag.or.at>:
However, there's an interesting issue caused by FFmpeg: The first frame of the video is extremely ugly pixelated:
Does this disappear with ffmpeg -threads 1 -i ... -threads 1 out/ffmpeg.mpg ? (with only one of the "-threads 1 ?)
I've tried both cases: "-threads 1" before input and output file. Separately. Still receiving the "rc buffer underflow" warning. As suggested, I'll move this issue to ffmpeg-user. About the mencoder mpeg-duration issue: Anyone else got any hints/infos about why the generated MPEGs are too short? Regards, Pb
On 1/12/12 10:09 AM, "Peter B." <pb@das-werkstatt.com> wrote:
Zitat von Carl Eugen Hoyos <cehoyos@ag.or.at>:
However, there's an interesting issue caused by FFmpeg: The first frame of the video is extremely ugly pixelated:
Does this disappear with ffmpeg -threads 1 -i ... -threads 1 out/ffmpeg.mpg ? (with only one of the "-threads 1 ?)
I've tried both cases: "-threads 1" before input and output file. Separately. Still receiving the "rc buffer underflow" warning.
As suggested, I'll move this issue to ffmpeg-user.
About the mencoder mpeg-duration issue: Anyone else got any hints/infos about why the generated MPEGs are too short?
Regards, Pb
It's PAL and the aspect ratio for the source is obviously wrong. I didn't see any significant difference in duration between input and output when I performed this conversion. http://dl.dropbox.com/u/42718751/vx-04690_01-026s.mpg mencoder vx-04690_01-026s.avi -oac lavc -channels 2 -o vx-04690_01-026s.mpg -demuxer lavf -ovc lavc -lavcopts acodec=ac3:abitrate=320:vqscale=1:mbd=0:vcodec=mpeg2video:aspect=16/9:keyint =15:vrc_buf_size=1835:vbitrate=7000:vratetol=7000:vrc_maxrate=7500:vrc_minra te=5000 -mc 0.1 -vf scale=720:480 -of mpeg -mpegopts format=dvd:tsaf:muxrate=40000 -fps 25 -ofps 25 Laine Lee
L. Lee wrote:
It's PAL and the aspect ratio for the source is obviously wrong. The source is archive material, where 16:9 material was stored in 4:3. That's quite common with older production equipment. As it's an important rule not to alter archive material, I've left the aspect ratio untouched to preserve what is found on the tape :)
I didn't see any significant difference in duration between input and output when I performed this conversion.
Thanks for checking it out! I've checked your video, and: Yes, the duration is correct (=1500 frames). Which mencoder/mplayer revision did you use for your conversion? I'm using the version: "MEncoder SVN-r34537-4.4.5" (which is a very recent SVN checkout)
mencoder vx-04690_01-026s.avi -oac lavc -channels 2 -o vx-04690_01-026s.mpg -demuxer lavf -ovc lavc -lavcopts acodec=ac3:abitrate=320:vqscale=1:mbd=0:vcodec=mpeg2video:aspect=16/9:keyint =15:vrc_buf_size=1835:vbitrate=7000:vratetol=7000:vrc_maxrate=7500:vrc_minra te=5000 -mc 0.1 -vf scale=720:480 -of mpeg -mpegopts format=dvd:tsaf:muxrate=40000 -fps 25 -ofps 25
I've used exactly your commandline and according to ffprobe my resulting MPEG is only 59 seconds. Again, 25 frames too short :( Here's the commands and uncut output of my transcoding: // ------------------------------- $ mencoder client/mpeg-duration/input/vx-04690_01-026s.avi -oac lavc -channels 2 -o 026s-169.mpg -demuxer lavf -ovc lavc -lavcopts acodec=ac3:abitrate=320:vqscale=1:mbd=0:vcodec=mpeg2video:aspect=16/9:keyint=25:vrc_buf_size=1835:vbitrate=7000:vratetol=7000:vrc_maxrate=7500:vrc_minrate=5000 -mc 0.1 -vf scale=720:480 -of mpeg -mpegopts format=dvd:tsaf:muxrate=40000 -fps 25 -ofps 25 Press any key to continue... MEncoder SVN-r34537-4.4.5 (C) 2000-2012 MPlayer Team success: format: 0 data: 0x0 - 0x10bea1d0 libavformat version 53.29.100 (internal) libavformat file format detected. [lavf] stream 0: video (ffv1), -vid 0 [lavf] stream 1: audio (pcm_s16le), -aid 0 VIDEO: [FFV1] 720x576 24bpp 25.000 fps 0.0 kbps ( 0.0 kbyte/s) [V] filefmt:35 fourcc:0x31564646 size:720x576 fps:25.000 ftime:=0.0400 Input fps will be interpreted as 25.000 instead. ========================================================================== Opening audio decoder: [pcm] Uncompressed PCM audio decoder AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000) Selected audio codec: [pcm] afm: pcm (Uncompressed PCM) ========================================================================== PACKET SIZE: 2048 bytes, deltascr: 11059 libavcodec version 53.54.100 (internal) Opening video filter: [expand osd=1] Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1 Opening video filter: [scale w=720 h=480] ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffv1] vfm: ffmpeg (FFV1 (lossless codec)) ========================================================================== [ac3 @ 0x8b215c0]channel_layout not specified [ac3 @ 0x8b215c0]No channel layout specified. The encoder will guess the layout, but it might be incorrect. Limiting audio preload to 0.4s. Increasing audio density to 4. Movie-Aspect is undefined - no prescaling applied. [swscaler @ 0x8a9d9e0]BICUBIC scaler, from yuv422p to yuv420p using MMX2 videocodec: libavcodec (720x480 fourcc=3267706d [mpg2]) [VE_LAVC] Using constant qscale = 1.000000 (VBR). [mpeg2video @ 0x8b215c0]Warning min_rate > 0 but min_rate != max_rate isn't recommended! [swscaler @ 0x8a9d9e0]Warning: dstStride is not aligned! ->cannot do aligned memory accesses anymore [swscaler @ 0x8a9d9e0]Warning: data is not aligned! This can lead to a speedloss Writing header... INITV: 0.200, 0.160, fps: 25.000 Pos: 60.0s 1500f (99%) 32.22fps Trem: 0min 38mb A-V:0.044 [5061:320] Flushing video frames. Writing index... Overhead: 1.642% (652169 / 39720055) Writing header... Video stream: 5061.373 kbit/s (632671 B/s) size: 37960301 bytes 60.000 secs 1500 frames Audio stream: 320.000 kbit/s (40000 B/s) size: 2400000 bytes 60.000 secs // ------------------------ $ ffprobe 026s-169.mpg ffprobe version N-36728-g794006f Copyright (c) 2007-2012 the FFmpeg developers built on Jan 12 2012 09:16:04 with gcc 4.4.5 configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-postproc --enable-swscale --enable-avfilter --enable-pthreads --enable-bzlib --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-zlib --enable-libopenjpeg --enable-decoder=png --enable-encoder=png --enable-libdirac --enable-libschroedinger libavutil 51. 34.100 / 51. 34.100 libavcodec 53. 55.100 / 53. 55.100 libavformat 53. 29.100 / 53. 29.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 58.100 / 2. 58.100 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 6.100 / 0. 6.100 libpostproc 51. 2.100 / 51. 2.100 [mpeg @ 0x9dbe320] max_analyze_duration 5000000 reached at 5000000 Input #0, mpeg, from '026s-169.mpg': Duration: 00:00:59.00, start: 0.240000, bitrate: 5474 kb/s Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 32:27 DAR 16:9], 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 320 kb/s
On 1/13/12 7:12 AM, "Peter B." <pb@das-werkstatt.com> wrote:
Which mencoder/mplayer revision did you use for your conversion? I'm using the version: "MEncoder SVN-r34537-4.4.5" (which is a very recent SVN checkout)
SVN-r34537-4.2.1 I recently fixed a problem by downloading and building complete source from scratch instead of phase compiling. I don't know if that might affect yours, of course. Laine
Zitat von "L. Lee" <llee040@sbcglobal.net>:
On 1/13/12 7:12 AM, "Peter B." <pb@das-werkstatt.com> wrote:
Which mencoder/mplayer revision did you use for your conversion? I'm using the version: "MEncoder SVN-r34537-4.4.5" (which is a very recent SVN checkout)
SVN-r34537-4.2.1
I recently fixed a problem by downloading and building complete source from scratch instead of phase compiling. I don't know if that might affect yours, of course.
I've now fetched the most recent SVN version (r34577) from scratch, compiled it and: Again, the MPEG is too short :( I'm quite puzzled, how you've managed that your MPEG has the correct length - with exactly the same mencoder version I'm using. I'm having this problem with more than just *my* mencoder version: 1) MEncoder 1.0rc3-4.4.4 (Debian Squeeze - official package) 2) MEncoder Sherpya-SVN-r34401-4.6.2 (Windows 7) 3) MEncoder SVN-r34577-4.4.5 Here's commandline and uncut output from my latest attempt. The commandline used should exactly match the one, successfully used by Lee: // ------------------------- $ mencoder client/mpeg-duration/input/vx-04690_01-026s.avi -oac lavc -channels 2 -o 026s-169.mpg -demuxer lavf -ovc lavc -lavcopts acodec=ac3:abitrate=320:vqscale=1:mbd=0:vcodec=mpeg2video:aspect=16/9:keyint=25:vrc_buf_size=1835:v bitrate=7000:vratetol=7000:vrc_maxrate=7500:vrc_minrate=5000 -mc 0.1 -vf scale=720:480 -of mpeg -mpegopts format=dv d:tsaf:muxrate=40000 -fps 25 -ofps 25 // ------------------------- MEncoder SVN-r34577-4.4.5 (C) 2000-2012 MPlayer Team success: format: 0 data: 0x0 - 0x10bea1d0 libavformat version 53.29.100 (internal) libavformat file format detected. [lavf] stream 0: video (ffv1), -vid 0 [lavf] stream 1: audio (pcm_s16le), -aid 0 VIDEO: [FFV1] 720x576 24bpp 25.000 fps 0.0 kbps ( 0.0 kbyte/s) [V] filefmt:35 fourcc:0x31564646 size:720x576 fps:25.000 ftime:=0.0400 Input fps will be interpreted as 25.000 instead. ========================================================================== Opening audio decoder: [pcm] Uncompressed PCM audio decoder AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000) Selected audio codec: [pcm] afm: pcm (Uncompressed PCM) ========================================================================== PACKET SIZE: 2048 bytes, deltascr: 11059 libavcodec version 53.55.105 (internal) Opening video filter: [expand osd=1] Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1 Opening video filter: [scale w=720 h=480] ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffv1] vfm: ffmpeg (FFV1 (lossless codec)) ========================================================================== [ac3 @ 0x8b23de0]channel_layout not specified [ac3 @ 0x8b23de0]No channel layout specified. The encoder will guess the layout, but it might be incorrect. Limiting audio preload to 0.4s. Increasing audio density to 4. Movie-Aspect is undefined - no prescaling applied. [swscaler @ 0x8aa0160]BICUBIC scaler, from yuv422p to yuv420p using MMX2 videocodec: libavcodec (720x480 fourcc=3267706d [mpg2]) [VE_LAVC] Using constant qscale = 1.000000 (VBR). [mpeg2video @ 0x8b23de0]Warning min_rate > 0 but min_rate != max_rate isn't recommended! [swscaler @ 0x8aa0160]Warning: dstStride is not aligned! ->cannot do aligned memory accesses anymore [swscaler @ 0x8aa0160]Warning: data is not aligned! This can lead to a speedloss Writing header... INITV: 0.200, 0.160, fps: 25.000 Pos: 60.0s 1500f (99%) 20.65fps Trem: 0min 38mb A-V:0.044 [5061:320] Flushing video frames. Writing index... Overhead: 1.642% (652169 / 39720055) Writing header... Video stream: 5061.373 kbit/s (632671 B/s) size: 37960301 bytes 60.000 secs 1500 frames Audio stream: 320.000 kbit/s (40000 B/s) size: 2400000 bytes 60.000 secs // ------------------------- $ ffprobe 026s-169.mpg // ------------------------- ffprobe version N-36728-g794006f Copyright (c) 2007-2012 the FFmpeg developers built on Jan 12 2012 09:16:04 with gcc 4.4.5 configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-postproc --enable-swscale --enable-avfilter --enable-pthreads --enable-bzlib --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-zlib --enable-libopenjpeg --enable-decoder=png --enable-encoder=png --enable-libdirac --enable-libschroedinger libavutil 51. 34.100 / 51. 34.100 libavcodec 53. 55.100 / 53. 55.100 libavformat 53. 29.100 / 53. 29.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 58.100 / 2. 58.100 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 6.100 / 0. 6.100 libpostproc 51. 2.100 / 51. 2.100 [mpeg @ 0x931d320] max_analyze_duration 5000000 reached at 5000000 Input #0, mpeg, from '026s-169.mpg': Duration: 00:00:59.00, start: 0.240000, bitrate: 5474 kb/s Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 32:27 DAR 16:9], 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 320 kb/s
Zitat von "L. Lee" <llee040@sbcglobal.net>:
SVN-r34537-4.2.1
I recently fixed a problem by downloading and building complete source from scratch instead of phase compiling. I don't know if that might affect yours, of course.
On which operating system (and which version) have you created the MPEG with the correct duration? Thanks, Pb
On 1/16/12 3:51 AM, "Peter B." <pb@das-werkstatt.com> wrote:
Zitat von "L. Lee" <llee040@sbcglobal.net>:
SVN-r34537-4.2.1
I recently fixed a problem by downloading and building complete source from scratch instead of phase compiling. I don't know if that might affect yours, of course.
On which operating system (and which version) have you created the MPEG with the correct duration?
Thanks, Pb
___
I'm using Mac OS X - Lion (10.7.2) and Mac OS X Developer Tools 4.2 I simply open a Terminal window and enter "svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer", then change to the mplayer directory and "./configure --cc=gcc-4.2", then "sudo make install". In all honesty, I'm somewhat confused by the results I've observed for the developer tools. I'm told that "--cc=gcc-4.2" shouldn't be necessary, but I can't build without it. What's more, I can't build unless I install Mac OS X Developer tools 4.2 on top of version 4.2.1, which was released as an update. Uninstalling Developer tools, and reinstalling to latest versIon doesn't let "./configure" work even if I specify "--cc=gcc-4.2". I then run the 4.2 installer over 4.2.1 without changing anything first, then running "./configure" without "--cc=gcc-4.2" doesn't work but including "--cc=gcc-4.2" does. My current version is MEncoder SVN-r34561-4.2.1 I don't see how this will help much, but if you have a Mac to fool around with, maybe you can help me determine why I'm not getting the expected functionality from Developer tools 4.2.1. Thanks. Laine Lee
Zitat von "L. Lee" <llee040@sbcglobal.net>:
I'm using Mac OS X - Lion (10.7.2) and Mac OS X Developer Tools 4.2 [...] I don't see how this will help much, but if you have a Mac to fool around with, maybe you can help me determine why I'm not getting the expected functionality from Developer tools 4.2.1.
Thanks for this information! Unfortunately, I don't happen to have a Mac around to fool with, so I can't be of any help to you :( Sorry. Regards, Pb
participants (3)
-
Carl Eugen Hoyos -
L. Lee -
Peter B.