transcoding from variable framerate MP4 to avi, a/v sync problem - video stream much shorter
Hello everybody. I'm trying make an all-in-one transcoder for any types of video, for web streaming. The output is AVC/AAC in MP4 container. For that i use the following techique: 1. Encode input to avc/aac and remux it to avi container. (mencoder) 2. Demux audio and video steams into separate files 3. Mux to mp4 with gpac MP4Box I ran into problem with an input mp4 file having variable framerate. The sample command for stage 1 is: mencoder -af volnorm=2 -oac faac -faacopts br=98:mpeg=4:object=2 -channels 2 -srate 44100 -ovc x264 -x264encopts bitrate=500:subq=5:frameref=6:cabac:threads=auto:bframes=3:b_pyramid=normal:weight_b -ofps 30000/1001 -vf pp=hb/vb/lb,dsize=960:720:0,scale=-8:-8,harddup infile.mp4 -o tmp.avi The input file is about 10 minutes long and has more then 4500 frames. Mencoder continues up to ~780-th frame, and then tells: Too many audio packets in the buffer: (4096 in 1067205 bytes). Maybe you are playing a non-interleaved stream/file or the codec failed? For AVI files, try to force non-interleaved mode with the -ni option. The result file is 28 seconds long, and a video stream is fast forward.. Audio stream is at normal speed. I had similar problem with encodinf VBR vmw files, and it was solved by adding source max frame rate with -ofps option. However this doesn't work with mp4 source. Any help would be much appreciated. Thanks. Input file mediainfo: Format : MPEG-4 Format profile : Base Media / Version 2 Codec ID : mp42 File size : 21.0 MiB Duration : 11mn 4s Overall bit rate : 265 Kbps Encoded date : UTC 2011-05-23 07:40:27 Tagged date : UTC 2011-05-23 07:41:00 Writing application : HandBrake 0.9.5 2011010300 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High@L3.1 Format settings, CABAC : Yes Format settings, ReFrames : 4 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 11mn 4s Bit rate mode : Variable Bit rate : 164 Kbps Nominal bit rate : 300 Kbps Width : 960 pixels Height : 600 pixels Display aspect ratio : 1.600 Frame rate mode : Variable Frame rate : 6.802 fps Minimum frame rate : 0.595 fps Maximum frame rate : 29.970 fps Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.042 Stream size : 13.0 MiB (62%) Writing library : x264 core 112 Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=70 / keyint_min=6 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=abr / mbtree=1 / bitrate=300 / ratetol=1.0 / qcomp=0.60 / qpmin=3 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Encoded date : UTC 2011-05-23 07:40:27 Tagged date : UTC 2011-05-23 07:41:00 Color primaries : BT.601-6 525, BT.1358 525, BT.1700 NTSC, SMPTE 170M Transfer characteristics : BT.709-5, BT.1361 Matrix coefficients : BT.601-6 525, BT.1358 525, BT.1700 NTSC, SMPTE 170M Audio ID : 2 Format : AAC Format/Info : Advanced Audio Codec Format profile : LC Codec ID : 40 Duration : 11mn 4s Bit rate mode : Variable Bit rate : 98.6 Kbps Maximum bit rate : 128 Kbps Channel(s) : 1 channel Channel positions : Front: C Sampling rate : 48.0 KHz Compression mode : Lossy Stream size : 7.81 MiB (37%) Language : English Encoded date : UTC 2011-05-23 07:40:27 Tagged date : UTC 2011-05-23 07:41:00 Output mediainfo: Format : AVI Format/Info : Audio Video Interleave File size : 915 KiB Duration : 26s 378ms Overall bit rate : 284 Kbps Writing application : MEncoder SVN-r32726-4.4.3 Writing library : MPlayer Video ID : 0 Format : AVC Format/Info : Advanced Video Codec Format profile : High@L3.1 Format settings, CABAC : Yes Format settings, ReFrames : 6 frames Codec ID : h264 Duration : 25s 859ms Bit rate : 174 Kbps Nominal bit rate : 164 Kbps Width : 960 pixels Height : 608 pixels Display aspect ratio : 1.599 Frame rate : 29.970 fps Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.010 Stream size : 550 KiB (60%) Writing library : x264 core 110 r1820 fdcf2ae Encoding settings : cabac=1 / ref=6 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=5 / psy=1 / psy_rd=0.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=164 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Audio ID : 1 Format : 706D Codec ID : 706D Duration : 26s 378ms Bit rate : 98.1 Kbps Channel(s) : 1 channel Sampling rate : 44.1 KHz Stream size : 316 KiB (35%) Interleave, duration : 23 ms (0.68 video frame) Interleave, preload duration : 2107 ms
On 7/30/11 3:01 PM, "SilentShade" <lifeemulation@gmail.com> wrote:
Hello everybody. I'm trying make an all-in-one transcoder for any types of video, for web streaming. The output is AVC/AAC in MP4 container. For that i use the following techique: 1. Encode input to avc/aac and remux it to avi container. (mencoder) 2. Demux audio and video steams into separate files 3. Mux to mp4 with gpac MP4Box
I ran into problem with an input mp4 file having variable framerate. The sample command for stage 1 is: mencoder -af volnorm=2 -oac faac -faacopts br=98:mpeg=4:object=2 -channels 2 -srate 44100 -ovc x264 -x264encopts bitrate=500:subq=5:frameref=6:cabac:threads=auto:bframes=3:b_pyramid=normal:we ight_b -ofps 30000/1001 -vf pp=hb/vb/lb,dsize=960:720:0,scale=-8:-8,harddup infile.mp4 -o tmp.avi
Have you tried specifying a demuxer (-demuxer lavf, for example)?
participants (2)
-
L. Lee -
SilentShade