Opened 10 years ago
Closed 10 years ago
#4565 closed defect (fixed)
MP2 in AVI (possibly) wrong frame_size/blkalign
Reported by: | darkyp | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | unspecified | Keywords: | mp2 |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
The background: I'm transcoding DVB MPEG2 Video stream on the Raspberry platform to H.264 and the audio is left as is (various types of MP2 audio) then both streams are muxed in the AVI container using libavformat.
The files play fine in most players, however some will play the audio stutteringly. VirtualDubMod 1.5.10.1 will complain about audio being VBR though it is CBR. If I manually hexedit the AVI and just fix the header with the proper values the files will play fine and VDub will not produce the warning.
I looked in the source and I think this could be a problem with ff_put_wav_header or a combination with av_get_audio_frame_duration. For MP2 audio streams blkalign = frame_size = 1152 (hard coded) while I think if the encoder has reported block_align ff_put_wav_header might use it for MP2 audio.
Am I wrong in assuming that the wav header block align should be different for the following types of MP2 audio:
Bitrate: 64000, Sample rate: 48000, Channels: 1 Frame size: 192
Bitrate: 160000, Sample rate: 48000, Channels: 2 Frame size: 480
Bitrate: 192000, Sample rate: 48000, Channels: 2 Frame size: 576
Attachments (1)
Change History (12)
comment:1 by , 10 years ago
Keywords: | wav header removed |
---|---|
Priority: | important → normal |
comment:3 by , 10 years ago
Thanks for the comments.
http://92.247.92.99/dbg_1.avi - original file created using the libavformat library. This will play stutteringly in VLC 2.0.8 (Windows). However it will play fine in WMP 11 (WinXP, using FFDShow Audio decoder rev4496, default Avi Splitter)
http://92.247.92.99/dbg_1.mod.avi - this will play fine on both. Produced by remuxing with VDub from dbg_1.avi.
I'll try to post a ffmpeg command line, though I'm using the library.
comment:4 by , 10 years ago
Command line: ffmpeg.exe -i dbg_1.mod.avi -vcodec copy -acodec copy dbg_1.avi
dbg_1.mod.avi plays fine in VLC, dbg_1.avi stutters.
comment:5 by , 10 years ago
To make this a valid ticket, please provide the command line that allows to reproduce the issue you are seeing together with the complete, uncut console output.
comment:6 by , 10 years ago
atic\bin>ffmpeg -i dbg_1.mod.avi -vcodec copy -acodec copy dbg_1.avi > log.txt ffmpeg version N-72211-g451be67 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca -- enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena ble-decklink --enable-zlib libavutil 54. 23.101 / 54. 23.101 libavcodec 56. 39.101 / 56. 39.101 libavformat 56. 33.101 / 56. 33.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 16.101 / 5. 16.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, avi, from 'dbg_1.mod.avi': Metadata: encoder : VirtualDubMod 1.5.10.1 (build 2366/release) Duration: 00:00:48.08, start: 0.000000, bitrate: 398 kb/s Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p, 320x240, 227 k b/s, 12.50 fps, 12.50 tbr, 12.50 tbn, 25 tbc Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 160 k b/s Output #0, avi, to 'dbg_1.avi': Metadata: ISFT : Lavf56.33.101 Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 320x240, q=2-31, 227 kb/s, 12.50 fps, 12.50 tbr, 12.50 tbn, 12.50 tbc Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, 160 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 597 fps=0.0 q=-1.0 Lsize= 2335kB time=00:00:48.08 bitrate= 397.9kbits /s video:1331kB audio:934kB subtitle:0kB other streams:0kB global headers:0kB muxin g overhead: 3.126330%
btw, why console redirection does not work on the win platform?
by , 10 years ago
Attachment: | patchmp2.diff added |
---|
comment:8 by , 10 years ago
Whoa, hats off to you guys! I just registered and frankly did not expect that level of cooperation.
I'm sure the patch will do as that is pretty much the way I calc block_align in the enc/AVCodecContext structure. It will take sometime however for me to test it as I used a readily available binary library on the raspi and will have to setup the build environment first in order to compile and test. If you do not close this now I'll write when ready again.
Thank you!
comment:9 by , 10 years ago
Now, that's an interesing one (at least for me). The binary I have on the raspi is avformat version 54.20.4 (seems that it is from Libav 9.18). We have there riff.c that must have been changed to riffenc.c later. Anyway, the lines there are:
if (enc->codec_id == AV_CODEC_ID_MP2 || enc->codec_id == AV_CODEC_ID_MP3) { /* this is wrong, but it seems many demuxers do not work if this is set correctly */ blkalign = frame_size; //blkalign = 144 * enc->bit_rate/enc->sample_rate;
Just recommending, in case Juango patch is approved, to have the above comment included but with the inversed sense.
Out of curiousity: are there any documented demuxer that have problems with the correct setting for blkalign?
comment:11 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
A variant of the patch was finally applied in a213e57cef82aefb57f1b2233f913081df153c7b - thank you for the report!
To make this a valid ticket, please provide a command line that allows to reproduce it together with the complete, uncut console output.