[FFmpeg-trac] #11182(undetermined:new): testyuvsrc and yuv444p->rgba->yuv44p conversion result in huge difference

FFmpeg trac at avcodec.org
Sun Sep 8 21:29:05 EEST 2024


#11182: testyuvsrc and yuv444p->rgba->yuv44p conversion result in huge difference
-------------------------------------+-------------------------------------
             Reporter:  Andrew-R     |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:  colorspace   |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 How to reproduce:
 {{{
 bash-5.1$ /dev/shm/ffmpeg/ffmpeg -f lavfi -color_range 2 -i yuvtestsrc
 -frames 1 -r 25 -vf format=rgba,format=yuv444p -color_range 2 /dev/shm
 /yuv-mpeg-rgba-yuv444p.y4m -debug log
 ffmpeg version N-115741-g8a314e3f11 Copyright (c) 2000-2024 the FFmpeg
 developers
   built with gcc 11.2.0 (GCC)
   configuration: --disable-debug
   libavutil      59. 36.100 / 59. 36.100
   libavcodec     61. 12.100 / 61. 12.100
   libavformat    61.  5.101 / 61.  5.101
   libavdevice    61.  2.100 / 61.  2.100
   libavfilter    10.  2.102 / 10.  2.102
   libswscale      8.  2.100 /  8.  2.100
   libswresample   5.  2.100 /  5.  2.100
  matched as AVOption 'debug' with argument 'log'.
 Trailing option(s) found in the command: may be ignored.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Successfully parsed a group of options.
 Parsing a group of options: input url yuvtestsrc.
 Applying option f (force container format (auto-detected otherwise)) with
 argument lavfi.
 Successfully parsed a group of options.
 Opening an input file: yuvtestsrc.
 detected 4 logical cores
 [Parsed_yuvtestsrc_0 @ 0xb791780] size:320x240 rate:25/1
 duration:-1.000000 sar:1/1
 [AVFilterGraph @ 0xb790fc0] query_formats: 2 queried, 3 merged, 0 already
 done, 0 delayed
 [lavfi @ 0xb790900] All info found
 Input #0, lavfi, from 'yuvtestsrc':
   Duration: N/A, start: 0.000000, bitrate: N/A
   Stream #0:0, 1, 1/25: Video: wrapped_avframe, 1 reference frame,
 yuv444p(pc), 320x240 [SAR 1:1 DAR 4:3], 0/1, 25 fps, 25 tbr, 25 tbn
 Successfully opened the file.
 Parsing a group of options: output url /dev/shm/yuv-mpeg-rgba-yuv444p.y4m.
 Applying option frames (set the number of frames to output) with argument
 1.
 Applying option r (override input framerate/convert to given output
 framerate (Hz value, fraction or abbreviation)) with argument 25.
 Applying option vf (alias for -filter:v (apply filters to video streams))
 with argument format=rgba,format=yuv444p.
 Successfully parsed a group of options.
 Opening an output file: /dev/shm/yuv-mpeg-rgba-yuv444p.y4m.
 [out#0/yuv4mpegpipe @ 0xb7cdb40] No explicit maps, mapping streams
 automatically...
 [vost#0:0/wrapped_avframe @ 0xb7ce340] Created video stream from input
 stream 0:0
 [AVFilterGraph @ 0xb7cf940] Setting 'pix_fmts' to value 'rgba'
 [AVFilterGraph @ 0xb7cf940] Setting 'pix_fmts' to value 'yuv444p'
 File '/dev/shm/yuv-mpeg-rgba-yuv444p.y4m' already exists. Overwrite? [y/N]
 y
 [file @ 0xb7d1f40] Setting default whitelist 'file,crypto,data'
 Successfully opened the file.
 Stream mapping:
   Stream #0:0 -> #0:0 (wrapped_avframe (native) -> wrapped_avframe
 (native))
 [vost#0:0/wrapped_avframe @ 0xb7ce340] Starting thread...
 [vf#0:0 @ 0xb7cf5c0] Starting thread...
 [vist#0:0/wrapped_avframe @ 0xb7cd580] [dec:wrapped_avframe @ 0xb7d1240]
 Starting thread...
 [in#0/lavfi @ 0xb790680] Starting thread...
 Press [q] to stop, [?] for help
 [AVFilterGraph @ 0xf4100a40] Setting 'pix_fmts' to value 'rgba'
 [AVFilterGraph @ 0xf4100a40] Setting 'pix_fmts' to value 'yuv444p'
 [graph -1 input from stream 0:0 @ 0xf4101f80] Setting 'video_size' to
 value '320x240'
 [graph -1 input from stream 0:0 @ 0xf4101f80] Setting 'pix_fmt' to value
 '5'
 [graph -1 input from stream 0:0 @ 0xf4101f80] Setting 'time_base' to value
 '1/25'
 [graph -1 input from stream 0:0 @ 0xf4101f80] Setting 'pixel_aspect' to
 value '1/1'
 [graph -1 input from stream 0:0 @ 0xf4101f80] Setting 'colorspace' to
 value '2'
 [graph -1 input from stream 0:0 @ 0xf4101f80] Setting 'range' to value '2'
 [graph -1 input from stream 0:0 @ 0xf4101f80] Setting 'frame_rate' to
 value '25/1'
 [graph -1 input from stream 0:0 @ 0xf4101f80] w:320 h:240 pixfmt:yuv444p
 tb:1/25 fr:25/1 sar:1/1 csp:unknown range:pc
 [auto_scale_0 @ 0xf4103d80] w:iw h:ih flags:'' interl:0
 [Parsed_format_0 @ 0xf41015c0] auto-inserting filter 'auto_scale_0'
 between the filter 'graph -1 input from stream 0:0' and the filter
 'Parsed_format_0'
 [auto_scale_1 @ 0xf410e940] w:iw h:ih flags:'' interl:0
 [Parsed_format_1 @ 0xf41018c0] auto-inserting filter 'auto_scale_1'
 between the filter 'Parsed_format_0' and the filter 'Parsed_format_1'
 [AVFilterGraph @ 0xf4100a40] query_formats: 4 queried, 3 merged, 6 already
 done, 0 delayed
 [swscaler @ 0xf4119040] [swscaler @ 0xf4122480] Forcing full internal H
 chroma due to input having non subsampled chroma
 [swscaler @ 0xf4119040] [swscaler @ 0xf413c140] Forcing full internal H
 chroma due to input having non subsampled chroma
 [swscaler @ 0xf4119040] [swscaler @ 0xf4155600] Forcing full internal H
 chroma due to input having non subsampled chroma
 [swscaler @ 0xf4119040] [swscaler @ 0xf416f2c0] Forcing full internal H
 chroma due to input having non subsampled chroma
 [swscaler @ 0xf4119040] [swscaler @ 0xf4188780] Forcing full internal H
 chroma due to input having non subsampled chroma
 [auto_scale_0 @ 0xf4103d80] w:320 h:240 fmt:yuv444p csp:unknown range:pc
 sar:1/1 -> w:320 h:240 fmt:rgba csp:gbr range:pc sar:1/1 flags:0x00000004
 [auto_scale_0 @ 0xf4103d80] [framesync @ 0xf4103e14] Selected 1/25 time
 base
 [auto_scale_0 @ 0xf4103d80] [framesync @ 0xf4103e14] Sync level 1
 [auto_scale_1 @ 0xf410e940] w:320 h:240 fmt:rgba csp:gbr range:pc sar:1/1
 -> w:320 h:240 fmt:yuv444p csp:unknown range:pc sar:1/1 flags:0x00000004
 [auto_scale_1 @ 0xf410e940] [framesync @ 0xf410ea14] Selected 1/25 time
 base
 [auto_scale_1 @ 0xf410e940] [framesync @ 0xf410ea14] Sync level 1
 [graph -1 input from stream 0:0 @ 0xf4101f80] video frame properties
 congruent with link at pts_time: 0
 Output #0, yuv4mpegpipe, to '/dev/shm/yuv-mpeg-rgba-yuv444p.y4m':
   Metadata:
     encoder         : Lavf61.5.101
   Stream #0:0, 0, 1/25: Video: wrapped_avframe, 1 reference frame,
 yuv444p(pc, progressive), 320x240 [SAR 1:1 DAR 4:3], 0/1, q=2-31, 200
 kb/s, 25 fps, 25 tbn
       Metadata:
         encoder         : Lavc61.12.100 wrapped_avframe
 [out#0/yuv4mpegpipe @ 0xb7cdb40] Starting thread...
 [out#0/yuv4mpegpipe @ 0xb7cdb40] sq: send 0 ts 0.04
 [out#0/yuv4mpegpipe @ 0xb7cdb40] sq: 0 frames_max 1 reached
 [out#0/yuv4mpegpipe @ 0xb7cdb40] sq: finish 0; head ts 0.04
 [out#0/yuv4mpegpipe @ 0xb7cdb40] sq: finish queue
 [out#0/yuv4mpegpipe @ 0xb7cdb40] sq: receive 0 ts 0.04 queue head 0 ts
 0.04
 [vf#0:0 @ 0xb7cf5c0] All consumers returned EOF
 [vost#0:0/wrapped_avframe @ 0xb7ce340] Encoder thread received EOF
 [vost#0:0/wrapped_avframe @ 0xb7ce340] Terminating thread with return code
 0 (success)
 [out#0/yuv4mpegpipe @ 0xb7cdb40] All streams finished
 [out#0/yuv4mpegpipe @ 0xb7cdb40] Terminating thread with return code 0
 (success)
 [out#0/yuv4mpegpipe @ 0xb7cdb40] sq: 0 EOF
 [out#0/yuv4mpegpipe @ 0xb7cdb40] sq: finish queue
 [vf#0:0 @ 0xb7cf5c0] Terminating thread with return code 0 (success)
 [vist#0:0/wrapped_avframe @ 0xb7cd580] [dec:wrapped_avframe @ 0xb7d1240]
 Decoder returned EOF, finishing
 [vist#0:0/wrapped_avframe @ 0xb7cd580] [dec:wrapped_avframe @ 0xb7d1240]
 Terminating thread with return code 0 (success)
 [vist#0:0/wrapped_avframe @ 0xb7cd580] All consumers of this stream are
 done
 [in#0/lavfi @ 0xb790680] All consumers are done
 [in#0/lavfi @ 0xb790680] Terminating thread with return code 0 (success)
 [AVIOContext @ 0xb7cfc00] Statistics: 230473 bytes written, 0 seeks, 1
 writeouts
 [out#0/yuv4mpegpipe @ 0xb7cdb40] Output file #0 (/dev/shm/yuv-mpeg-rgba-
 yuv444p.y4m):
 [out#0/yuv4mpegpipe @ 0xb7cdb40]   Output stream #0:0 (video): 1 frames
 encoded; 1 packets muxed (308 bytes);
 [out#0/yuv4mpegpipe @ 0xb7cdb40]   Total: 1 packets (308 bytes) muxed
 [out#0/yuv4mpegpipe @ 0xb7cdb40] video:0KiB audio:0KiB subtitle:0KiB other
 streams:0KiB global headers:0KiB muxing overhead: 74728.896104%
 frame=    1 fps=0.0 q=-0.0 Lsize=     225KiB time=00:00:00.04
 bitrate=46094.6kbits/s speed=3.08x
 [in#0/lavfi @ 0xb790680] Input file #0 (yuvtestsrc):
 [in#0/lavfi @ 0xb790680]   Input stream #0:0 (video): 19 packets read
 (5852 bytes); 10 frames decoded; 0 decode errors;
 [in#0/lavfi @ 0xb790680]   Total: 19 packets (5852 bytes) demuxed
 }}}
 ====

 compare with file made with this command:
 {{{
 bash-5.1$ /dev/shm/ffmpeg/ffmpeg -f lavfi -color_range 2 -i yuvtestsrc
 -frames 1 -r 25 -color_range 2 /dev/shm/yuv-mpeg-yuv444p.y4m -debug log
 ffmpeg version N-115741-g8a314e3f11 Copyright (c) 2000-2024 the FFmpeg
 developers
   built with gcc 11.2.0 (GCC)
   configuration: --disable-debug
   libavutil      59. 36.100 / 59. 36.100
   libavcodec     61. 12.100 / 61. 12.100
   libavformat    61.  5.101 / 61.  5.101
   libavdevice    61.  2.100 / 61.  2.100
   libavfilter    10.  2.102 / 10.  2.102
   libswscale      8.  2.100 /  8.  2.100
   libswresample   5.  2.100 /  5.  2.100
  matched as AVOption 'debug' with argument 'log'.
 Trailing option(s) found in the command: may be ignored.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Successfully parsed a group of options.
 Parsing a group of options: input url yuvtestsrc.
 Applying option f (force container format (auto-detected otherwise)) with
 argument lavfi.
 Successfully parsed a group of options.
 Opening an input file: yuvtestsrc.
 detected 4 logical cores
 [Parsed_yuvtestsrc_0 @ 0xca3b700] size:320x240 rate:25/1
 duration:-1.000000 sar:1/1
 [AVFilterGraph @ 0xca3af80] query_formats: 2 queried, 3 merged, 0 already
 done, 0 delayed
 [lavfi @ 0xca3a8c0] All info found
 Input #0, lavfi, from 'yuvtestsrc':
   Duration: N/A, start: 0.000000, bitrate: N/A
   Stream #0:0, 1, 1/25: Video: wrapped_avframe, 1 reference frame,
 yuv444p(pc), 320x240 [SAR 1:1 DAR 4:3], 0/1, 25 fps, 25 tbr, 25 tbn
 Successfully opened the file.
 Parsing a group of options: output url /dev/shm/yuv-mpeg-yuv444p.y4m.
 Applying option frames (set the number of frames to output) with argument
 1.
 Applying option r (override input framerate/convert to given output
 framerate (Hz value, fraction or abbreviation)) with argument 25.
 Successfully parsed a group of options.
 Opening an output file: /dev/shm/yuv-mpeg-yuv444p.y4m.
 [out#0/yuv4mpegpipe @ 0xca77d80] No explicit maps, mapping streams
 automatically...
 [vost#0:0/wrapped_avframe @ 0xca78580] Created video stream from input
 stream 0:0
 File '/dev/shm/yuv-mpeg-yuv444p.y4m' already exists. Overwrite? [y/N] y
 [file @ 0xca7b900] Setting default whitelist 'file,crypto,data'
 Successfully opened the file.
 Stream mapping:
   Stream #0:0 -> #0:0 (wrapped_avframe (native) -> wrapped_avframe
 (native))
 [vost#0:0/wrapped_avframe @ 0xca78580] Starting thread...
 [vf#0:0 @ 0xca79800] Starting thread...
 [vist#0:0/wrapped_avframe @ 0xca77740] [dec:wrapped_avframe @ 0xca7ac00]
 Starting thread...
 [in#0/lavfi @ 0xca3a640] Starting thread...
 Press [q] to stop, [?] for help
 [graph -1 input from stream 0:0 @ 0xf41016c0] Setting 'video_size' to
 value '320x240'
 [graph -1 input from stream 0:0 @ 0xf41016c0] Setting 'pix_fmt' to value
 '5'
 [graph -1 input from stream 0:0 @ 0xf41016c0] Setting 'time_base' to value
 '1/25'
 [graph -1 input from stream 0:0 @ 0xf41016c0] Setting 'pixel_aspect' to
 value '1/1'
 [graph -1 input from stream 0:0 @ 0xf41016c0] Setting 'colorspace' to
 value '2'
 [graph -1 input from stream 0:0 @ 0xf41016c0] Setting 'range' to value '2'
 [graph -1 input from stream 0:0 @ 0xf41016c0] Setting 'frame_rate' to
 value '25/1'
 [graph -1 input from stream 0:0 @ 0xf41016c0] w:320 h:240 pixfmt:yuv444p
 tb:1/25 fr:25/1 sar:1/1 csp:unknown range:pc
 [AVFilterGraph @ 0xf4100a40] query_formats: 3 queried, 6 merged, 0 already
 done, 0 delayed
 [graph -1 input from stream 0:0 @ 0xf41016c0] video frame properties
 congruent with link at pts_time: 0
 Output #0, yuv4mpegpipe, to '/dev/shm/yuv-mpeg-yuv444p.y4m':
   Metadata:
     encoder         : Lavf61.5.101
   Stream #0:0, 0, 1/25: Video: wrapped_avframe, 1 reference frame,
 yuv444p(pc, progressive), 320x240 [SAR 1:1 DAR 4:3], 0/1, q=2-31, 200
 kb/s, 25 fps, 25 tbn
       Metadata:
         encoder         : Lavc61.12.100 wrapped_avframe
 [out#0/yuv4mpegpipe @ 0xca77d80] Starting thread...
 [out#0/yuv4mpegpipe @ 0xca77d80] sq: send 0 ts 0.04
 [out#0/yuv4mpegpipe @ 0xca77d80] sq: 0 frames_max 1 reached
 [out#0/yuv4mpegpipe @ 0xca77d80] sq: finish 0; head ts 0.04
 [out#0/yuv4mpegpipe @ 0xca77d80] sq: finish queue
 [out#0/yuv4mpegpipe @ 0xca77d80] sq: receive 0 ts 0.04 queue head 0 ts
 0.04
 [vf#0:0 @ 0xca79800] All consumers returned EOF
 [vost#0:0/wrapped_avframe @ 0xca78580] Encoder thread received EOF
 [vost#0:0/wrapped_avframe @ 0xca78580] Terminating thread with return code
 0 (success)
 [out#0/yuv4mpegpipe @ 0xca77d80] sq: 0 EOF
 [out#0/yuv4mpegpipe @ 0xca77d80] sq: finish queue
 [vf#0:0 @ 0xca79800] Terminating thread with return code 0 (success)
 [vist#0:0/wrapped_avframe @ 0xca77740] [dec:wrapped_avframe @ 0xca7ac00]
 Decoder returned EOF, finishing
 [vist#0:0/wrapped_avframe @ 0xca77740] All consumers of this stream are
 done
 [in#0/lavfi @ 0xca3a640] All consumers are done
 [in#0/lavfi @ 0xca3a640] Terminating thread with return code 0 (success)
 [vist#0:0/wrapped_avframe @ 0xca77740] [dec:wrapped_avframe @ 0xca7ac00]
 Terminating thread with return code 0 (success)
 [out#0/yuv4mpegpipe @ 0xca77d80] All streams finished
 [out#0/yuv4mpegpipe @ 0xca77d80] Terminating thread with return code 0
 (success)
 [AVIOContext @ 0xca76a00] Statistics: 230473 bytes written, 0 seeks, 1
 writeouts
 [out#0/yuv4mpegpipe @ 0xca77d80] Output file #0 (/dev/shm/yuv-mpeg-
 yuv444p.y4m):
 [out#0/yuv4mpegpipe @ 0xca77d80]   Output stream #0:0 (video): 1 frames
 encoded; 1 packets muxed (308 bytes);
 [out#0/yuv4mpegpipe @ 0xca77d80]   Total: 1 packets (308 bytes) muxed
 [out#0/yuv4mpegpipe @ 0xca77d80] video:0KiB audio:0KiB subtitle:0KiB other
 streams:0KiB global headers:0KiB muxing overhead: 74728.896104%
 frame=    1 fps=0.0 q=-0.0 Lsize=     225KiB time=00:00:00.04
 bitrate=46094.6kbits/s speed=9.44x
 [in#0/lavfi @ 0xca3a640] Input file #0 (yuvtestsrc):
 [in#0/lavfi @ 0xca3a640]   Input stream #0:0 (video): 19 packets read
 (5852 bytes); 10 frames decoded; 0 decode errors;
 [in#0/lavfi @ 0xca3a640]   Total: 19 packets (5852 bytes) demuxed

 }}}


 I compared two files using YUView (requires qt5):
 https://github.com/IENT/YUView

 I also tried to define colorimetry info harder:

 bash-5.1$ /dev/shm/ffmpeg/ffmpeg -f lavfi -color_range 2 -color_primaries
 bt709  -colorspace bt709 -color_trc bt709  -i yuvtestsrc -frames 1 -r 25
 -vf format=rgba,scale,format=yuv444p,scale -color_range 2 -color_primaries
 bt709  -colorspace bt709 -color_trc bt709  /dev/shm/yuv-mpeg-rgba-
 yuv444p.y4m -debug log

 but it does not change outcome
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/11182>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list