Opened 2 years ago
Last modified 21 months ago
#9826 open defect
AVI muxer issue
Reported by: | ProWo | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | unspecified | Keywords: | avi muxer |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description (last modified by )
Summary of the bug:
I have noticed that the FFmpeg AVI muxer creates non-compliant Avi files.
Checking these files with AviHex shows errors.
The files still play fine with most software players.
Older hardware players (e.g. DVD players with USB port) can not play them.
If you mux to mkv and then mux this mkv file to AVI with Avidemux, this new Avi file is compliant.
How to reproduce:
ffmpeg started on 2022-07-09 at 15:01:21
Report written to "ffmpeg-20220709-150121.log"
Log level: 48
Command line:
ffmpeg -i Sample_Videostream.mkv -i Sample_Audiostream.ac3 -c copy output.avi -report
ffmpeg version 5.0.1-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --ena libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Splitting the commandline.
Reading option '-i' ... matched as input url with argument 'Sample_Videostream.mkv'.
Reading option '-i' ... matched as input url with argument 'Sample_Audiostream.ac3'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'output.avi' ... matched as output url.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url Sample_Videostream.mkv.
Successfully parsed a group of options.
Opening an input file: Sample_Videostream.mkv.
[NULL @ 0000027d94fce900] Opening 'Sample_Videostream.mkv' for reading
[file @ 0000027d94fcef40] Setting default whitelist 'file,crypto,data'
[matroska,webm @ 0000027d94fce900] Format matroska,webm probed with size=2048 and score=100
st:0 removing common factor 1000000 from timebase
[matroska,webm @ 0000027d94fce900] Before avformat_find_stream_info() pos: 633 bytes read:32768 seeks:0 nb_streams:1
[mpeg4 @ 0000027d94ff7700] Format yuv420p chosen by get_format().
[matroska,webm @ 0000027d94fce900] All info found
[matroska,webm @ 0000027d94fce900] After avformat_find_stream_info() pos: 4458 bytes read:32768 seeks:0 frames:1
Input #0, matroska,webm, from 'Sample_Videostream.mkv':
Metadata:
ENCODER : Lavf59.16.100
Duration: 00:00:38.37, start: 0.300000, bitrate: 734 kb/s
Stream #0:0, 1, 1/1000: Video: mpeg4 (Simple Profile), yuv420p(tv, progressive), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn
Metadata:
ENCODER : Lavc59.18.100 libxvid
DURATION : 00:00:38.371000000
Successfully opened the file.
Parsing a group of options: input url Sample_Audiostream.ac3.
Successfully parsed a group of options.
Opening an input file: Sample_Audiostream.ac3.
[NULL @ 0000027d94febec0] Opening 'Sample_Audiostream.ac3' for reading
[file @ 0000027d94fcedc0] Setting default whitelist 'file,crypto,data'
[ac3 @ 0000027d94febec0] Format ac3 probed with size=16384 and score=51
[ac3 @ 0000027d94febec0] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[ac3 @ 0000027d94febec0] All info found
[ac3 @ 0000027d94febec0] Estimating duration from bitrate, this may be inaccurate
[ac3 @ 0000027d94febec0] After avformat_find_stream_info() pos: 90112 bytes read:98304 seeks:0 frames:50
Input #1, ac3, from 'Sample_Audiostream.ac3':
Duration: 00:00:37.98, start: 0.000000, bitrate: 448 kb/s
Stream #1:0, 50, 1/90000: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Successfully opened the file.
Parsing a group of options: output url output.avi.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: output.avi.
[file @ 0000027d9506eec0] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
[avi @ 0000027d950702c0] reserve_index_space:0 master_index_max_size:256
[avi @ 0000027d950702c0] duration_est:36000.000, filesize_est:2.1GiB, master_index_max_size:256
Output #0, avi, to 'output.avi':
Metadata:
ISFT : Lavf59.16.100
Stream #0:0, 0, 1001/60000: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p(tv, progressive), 720x480 [SAR 8:9 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 59.94 tbn
Metadata:
ENCODER : Lavc59.18.100 libxvid
DURATION : 00:00:38.371000000
Stream #0:1, 0, 4/125: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream mapping:
Press [q] to stop, ? for help
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
frame= 1 fps=0.0 q=-1.0 size= 10kB time=00:00:00.01 bitrate=4819.3kbits/s speed= 152x
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
No more output streams to write to, finishing.
frame= 1141 fps=0.0 q=-1.0 Lsize= 5598kB time=00:00:38.05 bitrate=1205.1kbits/s speed=5.14e+03x
video:3429kB audio:2077kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.667069%
Input file #0 (Sample_Videostream.mkv):
Input stream #0:0 (video): 1141 packets read (3511176 bytes);
Total: 1141 packets (3511176 bytes) demuxed
Input file #1 (Sample_Audiostream.ac3):
Input stream #1:0 (audio): 1187 packets read (2127104 bytes);
Total: 1187 packets (2127104 bytes) demuxed
Output file #0 (output.avi):
Output stream #0:0 (video): 1141 packets muxed (3511176 bytes);
Output stream #0:1 (audio): 1187 packets muxed (2127104 bytes);
Total: 2328 packets (5638280 bytes) muxed
[AVIOContext @ 0000027d94ffaa80] Statistics: 5732302 bytes written, 10 seeks, 30 writeouts
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0000027d94fed2c0] Statistics: 3523267 bytes read, 0 seeks
[AVIOContext @ 0000027d94fec180] Statistics: 2127104 bytes read, 0 seeks
NB output.avi in the commandline = Sample_muxed_with_ffmpeg_to_avi.avi
Files:
https://files.videohelp.com/u/292773/Sample_Videostream.mkv https://files.videohelp.com/u/292773/Sample_Audiostream.ac3 https://files.videohelp.com/u/292773/Sample_muxed_with_ffmpeg_to_avi.avi https://files.videohelp.com/u/292773/Sample_muxed_with_ffmpeg_to_mkv.mkv https://files.videohelp.com/u/292773/Sample_muxed_with_ffmpeg_to_mkv_then_with_avidemux_to_avi.avi http://www.gero-net.de/avihex/avihex253.zip
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Change History (19)
comment:1 by , 2 years ago
Status: | new → open |
---|
comment:2 by , 2 years ago
Description: | modified (diff) |
---|
follow-up: 4 comment:3 by , 2 years ago
Resolution: | → invalid |
---|---|
Status: | open → closed |
comment:4 by , 2 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Replying to Elon Musk:
Missing info like what is not compliant in produced files.
Maybe this pictures helps:
https://files.videohelp.com/u/292773/error_non_compliant.jpg
https://files.videohelp.com/u/292773/success_compliant.jpg
comment:5 by , 2 years ago
Status: | reopened → open |
---|
comment:6 by , 2 years ago
No, it should be RIFF, not LIFF.
https://docs.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference
P.S.Apparently AviHex does not do it, sigh.
So the differnces is that 30 30 37 34 4A 55 4E 4B 18 becomes 30 30 37 34 4A 55 4E 4B 64 (only last byte changes), 49 41 53 31 04 00 00 00 75 6E 64 becomes 49 41 53 31 EC FF FF FF 75 6E 64 and 00 00 00 00 00 00 00 00 00 4C 49 53 54 26 00 becomes 00 04 00 00 00 00 00 00 00 4C 49 53 54 26 00.
User came from here https://forum.videohelp.com/threads/406301-FFmpeg-AVI-muxer-creates-non-compliant-Avi-files#post2662071
comment:7 by , 2 years ago
The ffmpeg AVI muxer writes 00002000-0000-0010-8000-00AA00389B71 as Codec ID (for a AC3 5.1 audio file).
If the same ffmpeg muxes the same file to MKV instead, this Codec ID is A_AC3.
Maybe this is the problem ...
comment:8 by , 2 years ago
mkv uses same Codec ID for EAC3 and AC3, at least per spec. In practice some use different Codec ID for EAC3: https://github.com/ietf-wg-cellar/matroska-specification/issues/230#issuecomment-424413939
Nothing like this happens in avi.
comment:9 by , 2 years ago
clsid from doom9 has pointed out an interesting thing. he writes:
"The problem seems to be that the RIFF AudioFormat Tag header (strf) in your file is using WAVEFORMATEXTENSIBLE format instead of WAVEFORMATEX.Some (older) software may not support that"
And really, ffmpeg writes FFFE (WAVEFORMATEXTENSIBLE), instead of 2000 (WAVEFORMATEX).
The file muxed to AVI with ffmpeg:
and the file muxed with avidemux:
(these codes are written in reverse in the file)
another picture of the differences:
WAVEFORMATEXTENSIBLE is no problem for newer players, but older players, especially hardware players, cannot do anything with it.
Since the AVI container is mainly used by older devices, the Ffmeg AVI muxer should be reset to WAVEFORMATEX for compatibility reasons.
I have not yet found a solution for the problem with the errors in the file structure.
follow-up: 11 comment:10 by , 2 years ago
Resolution: | → wontfix |
---|---|
Status: | open → closed |
Your software/hardware is obsolete. Not a bug, this is feature.
comment:11 by , 2 years ago
Replying to Elon Musk:
Your software/hardware is obsolete. Not a bug, this is feature.
I do not agree. Thousands have old DVD players with USB slots that can only play mpeg1, mpeg2 and mpeg4 video with mp2, mp3 and ac3 audio, as AVI file.
FFmpeg should be able to provide a solution for these users.
An active developer should look at this and then decide if the AVI muxer should be fixed or not.
comment:12 by , 2 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
comment:13 by , 2 years ago
Status: | reopened → open |
---|
comment:14 by , 2 years ago
I suggest an new avi format filter/switch, with which the ffmpeg AVI muxer writes the old audio ID 0x2000, without this filter the new audio ID 0xFFFE is written with the corresponding GUID 0002000-0000-0010-8000-00AA00389B71.
So the downward compatibility is guaranteed and the new features are preserved.
follow-up: 16 comment:15 by , 2 years ago
Resolution: | → duplicate |
---|---|
Status: | open → closed |
This a duplicate #9244.
comment:16 by , 2 years ago
comment:17 by , 2 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
comment:18 by , 2 years ago
Status: | reopened → open |
---|
comment:19 by , 21 months ago
I wrote a patch that should probably help with the problem if you use the "-write_channel_mask false" switch.
https://trac.ffmpeg.org/attachment/ticket/9244/tiket9244_patch_1.diff
Missing info like what is not compliant in produced files.