#11164 closed defect (worksforme)
visual macroblock error with mpeg2video encoding
| Reported by: | dave rice | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | 6.1.1 | Keywords: | mpeg2video |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description (last modified by )
Summary of the bug:
I've been using ffmpeg to create XDCam QuickTime files and found a regression or change in going from ffmpeg 5 to 6.
The simplest command I can create to demonstrate this problem is below. The ffmpeg@5 output looks fine and represents the input well, the ffmpeg@6 output shows some abundant macroblock errors.
How to reproduce:
This ffmpeg@5 output looks okay:
% ffmpeg -y -i input_that_creates_visual_error_with_ffmpeg6_but_not_5.mp4 -c:v mpeg2video -non_linear_quant 1 -qmin 1 -pix_fmt yuv422p -vtag xd5b -q:v 1 -qmax 8 good.mov
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.30)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.2_6 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input_that_creates_visual_error_with_ffmpeg6_but_not_5.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.27.100
Duration: 00:00:02.04, start: 0.000000, bitrate: 5301 kb/s
Stream #0:0[0x1](eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 2982 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
Metadata:
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'good.mov':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.27.100
Stream #0:0(eng): Video: mpeg2video (4:2:2) (xd5b / 0x62356478), yuv422p(tv, bt709, progressive), 1920x1080, q=2-31, 200 kb/s, 23.98 fps, 24k tbn (default)
Metadata:
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : Lavc59.37.100 mpeg2video
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame= 49 fps=0.0 q=1.0 Lsize= 5382kB time=00:00:01.96 bitrate=22491.4kbits/s speed=11.2x
video:5381kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.019745%
This ffmpeg@6 output has visual artifacts.
% ffmpeg -y -i input_that_creates_visual_error_with_ffmpeg6_but_not_5.mp4 -c:v mpeg2video -non_linear_quant 1 -qmin 1 -pix_fmt yuv422p -vtag xd5b -q:v 1 -qmax 8 good.mov
ffmpeg version 6.1.2 Copyright (c) 2000-2024 the FFmpeg developers
built with Apple clang version 14.0.0 (clang-1400.0.29.202)
configuration: --prefix='/opt/homebrew/Cellar/ffmpeg@6/6.1.2_1' --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input_that_creates_visual_error_with_ffmpeg6_but_not_5.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.27.100
Duration: 00:00:02.04, start: 0.000000, bitrate: 5301 kb/s
Stream #0:0[0x1](eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 2982 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
Metadata:
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'good.mov':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf60.16.100
Stream #0:0(eng): Video: mpeg2video (4:2:2) (xd5b / 0x62356478), yuv422p(tv, bt709, progressive), 1920x1080, q=2-31, 200 kb/s, 23.98 fps, 24k tbn (default)
Metadata:
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : Lavc60.31.102 mpeg2video
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
[out#0/mov @ 0x13fe04e70] video:5414kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.019627%
frame= 49 fps=0.0 q=1.0 Lsize= 5415kB time=00:00:01.96 bitrate=22627.3kbits/s speed=14.8x
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Attachments (1)
Change History (7)
by , 2 years ago
| Attachment: | input_that_creates_visual_error_with_ffmpeg6_but_not_5.mp4 added |
|---|
comment:1 by , 2 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 2 years ago
I cannot see any artifacts on ffmpeg master on windows. Also you need to use -ignore_editlist 1before -i option to actually encode all frames in the video. Funny and strange
comment:3 by , 2 years ago
I can't really reproduce this on linux, neither with 6.1.2, nor with git master. You should try to narrow down what causes this (e.g. try git master, and options such as -threads 1, -cpuflags 0)...
comment:4 by , 15 months ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
I can't reproduce this either. In fact for me the streamhash of the encoded stream (with the given commandline) is the same for 5.1, 6.1 and master.
You can reopen this ticket if you provide more information.
comment:5 by , 15 months ago
Thanks @mkver. I tried again, I'm using ffmpeg 7
`
ffmpeg -y -i input_that_creates_visual_error_with_ffmpeg6_but_not_5.mp4 -c:v mpeg2video -non_linear_quant 1 -qmin 1 -pix_fmt yuv422p -vtag xd5b -q:v 1 -qmax 8 good.mov
ffmpeg version 7.1.1 Copyright (c) 2000-2025 the FFmpeg developers
built with Apple clang version 16.0.0 (clang-1600.0.26.6)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.1.1_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 59. 39.100 / 59. 39.100
libavcodec 61. 19.101 / 61. 19.101
libavformat 61. 7.100 / 61. 7.100
libavdevice 61. 3.100 / 61. 3.100
libavfilter 10. 4.100 / 10. 4.100
libswscale 8. 3.100 / 8. 3.100
libswresample 5. 3.100 / 5. 3.100
libpostproc 58. 3.100 / 58. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input_that_creates_visual_error_with_ffmpeg6_but_not_5.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.27.100
Duration: 00:00:02.04, start: 0.000000, bitrate: 5301 kb/s
Stream #0:0[0x1](eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 2982 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
Metadata:
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream mapping:
Press [q] to stop, ? for help
Output #0, mov, to 'good.mov':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf61.7.100
Stream #0:0(eng): Video: mpeg2video (4:2:2) (xd5b / 0x62356478), yuv422p(tv, bt709, progressive), 1920x1080, q=2-31, 200 kb/s, 23.98 fps, 24k tbn (default)
Metadata:
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : Lavc61.19.101 mpeg2video
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
[out#0/mov @ 0x600003bb83c0] video:5348KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.019850%
frame= 49 fps=0.0 q=1.0 Lsize= 5349KiB time=00:00:02.00 bitrate=21886.2kbits/s speed= 11x
`
In the output, I'm looking at the frame of 00:00:00.542: in the top line of text the tops of the letters seem to have black boxes over them. On line 3 the word "Executive" has parts obscured. The word "Head" on line 2 has an odd white blocks in the lower right corner of the "H". The next frame is similar. At frame 1.293 the word "Head" again has odd shapes to it.
When I compare to the frames in the source they look very different.
comment:6 by , 14 months ago
I can't reproduce this; as I said: I can't even reproduce any change in the output of the encoder.
You should isolate whether this is a H.264 decoder regression, a scaling/pixel format conversion regression, an encoder/muxer regression or an MPEG-2 decoder regression (you didn't even say how you watch the encoded file). You should also test with -cpuflags 0 and -bitexact and -threads 1 etc.



input_that_creates_visual_error_with_ffmpeg6_but_not_5