Opened 6 months ago

Last modified 6 months ago

#7267 new defect

Interlaced ProRes output has chroma assigned to wrong fields

Reported by: jsevakis Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: prores
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: Any interlaced source clip (tested with Blu-ray .m2ts, UtVideo?, others) will convert to ProRes? QuickTime? file without complaint. However, if you analyze the output ProRes? closely (or later attempt to IVTC it or separatefields() in AVIsynth), you will notice that the chroma is being assigned to the wrong frames or fields.
How to reproduce: Encode any interlaced clip (animation is a good test), and encode using -vcodec prores to a .mov file. Analyze the result.

% ffmpeg -i input -c:v prores -profile:v 3 output
ffmpeg version 3.x, 4.0.1
(used pre-built binaries on Mac and Windows)

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (2)

MBOpening-Separatefields1.png (191.3 KB) - added by jsevakis 6 months ago.
separatefields() in AVIsynth of ProRes? output file #1
MBOpening-Separatefields2.png (271.5 KB) - added by jsevakis 6 months ago.
Another separatefields() sample. The chroma seems to lag behind by one field.

Download all attachments as: .zip

Change History (9)

Changed 6 months ago by jsevakis

separatefields() in AVIsynth of ProRes? output file #1

Changed 6 months ago by jsevakis

Another separatefields() sample. The chroma seems to lag behind by one field.

comment:1 Changed 6 months ago by cehoyos

Please test current FFmpeg git head and please provide a short input file and the command line you tested together with the complete, uncut console output to make this a valid ticket.

comment:2 Changed 6 months ago by jsevakis

OK, tested with current git head (git-2018-06-19-a990184). Command line was:
ffmpeg -i /Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts -c:v prores -profile:v 3 /Volumes/Media/MarmaladeBoyTest.mov -report

Source file is here: https://www.dropbox.com/s/vf3og9jtqn4e5lg/00036.m2ts?dl=0

Console output is below. Please let me know if you need anything else.

ffmpeg started on 2018-06-20 at 13:14:35
Report written to "ffmpeg-20180620-131435.log"
Command line:
ffmpeg -i /Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts -c:v prores -profile:v 3 /Volumes/Media/MarmaladeBoyTest.mov -report
ffmpeg version git-2018-06-19-a990184 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-a990184 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-gpl --enable-chromaprint --enable-frei0r --enable-libass --enable-libbluray --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --enable-libsrt --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 --enable-nonfree
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 20.103 / 58. 20.103
  libavformat    58. 17.100 / 58. 17.100
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 25.100 /  7. 25.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Splitting the commandline.
Reading option '-i' ... matched as input url with argument '/Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'prores'.
Reading option '-profile:v' ... matched as option 'profile' (set profile) with argument '3'.
Reading option '/Volumes/Media/MarmaladeBoyTest.mov' ... 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 /Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts.
Successfully parsed a group of options.
Opening an input file: /Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts.
[NULL @ 0x7f8eb6029000] Opening '/Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts' for reading
[file @ 0x7f8eb5807a00] Setting default whitelist 'file,crypto'
[mpegts @ 0x7f8eb6029000] Format mpegts probed with size=2048 and score=50
[mpegts @ 0x7f8eb6029000] stream=0 stream_type=2 pid=1011 prog_reg_desc=HDMV
[mpegts @ 0x7f8eb6029000] stream=1 stream_type=81 pid=1100 prog_reg_desc=HDMV
[mpegts @ 0x7f8eb6029000] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:2
[mpeg2video @ 0x7f8eb681d800] Format yuv420p chosen by get_format().
[mpegts @ 0x7f8eb6029000] max_analyze_duration 5000000 reached at 5024000 microseconds st:1
[mpegts @ 0x7f8eb6029000] After avformat_find_stream_info() pos: 0 bytes read:4558992 seeks:2 frames:296
Input #0, mpegts, from '/Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts':
  Duration: 00:00:16.02, start: 4200.000000, bitrate: 6533 kb/s
  Program 1 
    Stream #0:0[0x1011], 137, 1/90000: Video: mpeg2video (Main) (HDMV / 0x564D4448), yuv420p(tv, top first), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x1100], 159, 1/90000: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
Successfully opened the file.
Parsing a group of options: output url /Volumes/Media/MarmaladeBoyTest.mov.
Applying option c:v (codec name) with argument prores.
Applying option profile:v (set profile) with argument 3.
Successfully parsed a group of options.
Opening an output file: /Volumes/Media/MarmaladeBoyTest.mov.
[file @ 0x7f8eb4600140] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 16 logical cores
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> prores (native))
  Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[graph_1_in_0_1 @ 0x7f8eb5903c80] Setting 'time_base' to value '1/48000'
[graph_1_in_0_1 @ 0x7f8eb5903c80] Setting 'sample_rate' to value '48000'
[graph_1_in_0_1 @ 0x7f8eb5903c80] Setting 'sample_fmt' to value 'fltp'
[graph_1_in_0_1 @ 0x7f8eb5903c80] Setting 'channel_layout' to value '0x3'
[graph_1_in_0_1 @ 0x7f8eb5903c80] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
[format_out_0_1 @ 0x7f8eb5904340] Setting 'sample_fmts' to value 'fltp'
[format_out_0_1 @ 0x7f8eb5904340] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[AVFilterGraph @ 0x7f8eb59032c0] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[mpeg2video @ 0x7f8eb7000000] Format yuv420p chosen by get_format().
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[graph 0 input from stream 0:0 @ 0x7f8eb4503540] Setting 'video_size' to value '720x480'
[graph 0 input from stream 0:0 @ 0x7f8eb4503540] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x7f8eb4503540] Setting 'time_base' to value '1/90000'
[graph 0 input from stream 0:0 @ 0x7f8eb4503540] Setting 'pixel_aspect' to value '8/9'
[graph 0 input from stream 0:0 @ 0x7f8eb4503540] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x7f8eb4503540] Setting 'frame_rate' to value '30000/1001'
[graph 0 input from stream 0:0 @ 0x7f8eb4503540] w:720 h:480 pixfmt:yuv420p tb:1/90000 fr:30000/1001 sar:8/9 sws_param:flags=2
[format @ 0x7f8eb4503a00] Setting 'pix_fmts' to value 'yuv422p10le'
[auto_scaler_0 @ 0x7f8eb4504400] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0x7f8eb4504400] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x7f8eb4503a00] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x7f8eb4503140] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[auto_scaler_0 @ 0x7f8eb4504400] w:720 h:480 fmt:yuv420p sar:8/9 -> w:720 h:480 fmt:yuv422p10le sar:8/9 flags:0x4
Output #0, mov, to '/Volumes/Media/MarmaladeBoyTest.mov':
  Metadata:
    encoder         : Lavf58.17.100
    Stream #0:0, 0, 1/30000: Video: prores (apch / 0x68637061), yuv422p10le, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc58.20.103 prores
    Stream #0:1, 0, 1/48000: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.20.103 aac
Clipping frame in rate conversion by 0.000008
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
frame=  197 fps=0.0 q=-0.0 size=   41472kB time=00:00:07.01 bitrate=48405.0kbits/s speed=  14x    
frame=  367 fps=348 q=-0.0 size=   79872kB time=00:00:12.71 bitrate=51461.2kbits/s speed=12.1x    
[out_0_0 @ 0x7f8eb45038c0] EOF on sink link out_0_0:default.
[out_0_1 @ 0x7f8eb59040c0] EOF on sink link out_0_1:default.
No more output streams to write to, finishing.
frame=  480 fps=365 q=-0.0 Lsize=  102880kB time=00:00:16.00 bitrate=52674.6kbits/s speed=12.2x    
video:102629kB audio:237kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.014464%
Input file #0 (/Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts):
  Input stream #0:0 (video): 480 packets read (11928075 bytes); 480 frames decoded; 
  Input stream #0:1 (audio): 500 packets read (384000 bytes); 500 frames decoded (768000 samples); 
  Total: 980 packets (12312075 bytes) demuxed
Output file #0 (/Volumes/Media/MarmaladeBoyTest.mov):
  Output stream #0:0 (video): 480 frames encoded; 480 packets muxed (105091720 bytes); 
  Output stream #0:1 (audio): 750 frames encoded (768000 samples); 751 packets muxed (242201 bytes); 
  Total: 1231 packets (105333921 bytes) muxed
980 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7f8eb46002c0] Statistics: 2 seeks, 405 writeouts
[aac @ 0x7f8eb7007e00] Qavg: 7752.693
[AVIOContext @ 0x7f8eb5807b80] Statistics: 17639568 bytes read, 2 seeks

comment:3 follow-up: Changed 6 months ago by cehoyos

  • Component changed from ffmpeg to avcodec
  • Keywords interlaced chroma removed
  • Version changed from unspecified to git-master

Can you confirm that the issue is not reproducible with these two command lines?

$ ffmpeg -i 00036.m2ts -c:v prores -profile:v 3 -vcodec prores_ks -flags +ildct out1.mov
$ ffmpeg -i 00036.m2ts -c:v prores -profile:v 3 -vcodec prores_ks out2.mov

comment:4 in reply to: ↑ 3 Changed 6 months ago by jsevakis

Replying to cehoyos:

Can you confirm that the issue is not reproducible with these two command lines?

$ ffmpeg -i 00036.m2ts -c:v prores -profile:v 3 -vcodec prores_ks -flags +ildct out1.mov
$ ffmpeg -i 00036.m2ts -c:v prores -profile:v 3 -vcodec prores_ks out2.mov

Still happens with both, I'm afraid. Let me know if you need a console log from either of them.

comment:5 follow-up: Changed 6 months ago by kierank

Needs vf=scale:interl=1, I've already mention that interlaced files need interlaced upsampling but this was blocked by Michael.

comment:6 in reply to: ↑ 5 Changed 6 months ago by jsevakis

Replying to kierank:

Needs vf=scale:interl=1, I've already mention that interlaced files need interlaced upsampling but this was blocked by Michael.

By jove, that did it! Much thanks!

Here is the successful string:

ffmpeg -i /Volumes/GeneralData/FFXC_9014_3/BDMV/STREAM/00036.m2ts -vf scale=interl=1 -c:v prores -profile:v 3 /Volumes/Media/MarmaladeBoyTest4.mov

So, here's the ultimate question: is this a bug and something that should be automatic when sensing an interlaced input clip, or just an omission in the manual?

comment:7 Changed 6 months ago by kierank

It should be automatic but as mentioned it was blocked by another developer.

Note: See TracTickets for help on using tickets.