Opened 6 years ago
Closed 5 months ago
#7437 closed enhancement (fixed)
clap atom values ignored by ffmpeg
Reported by: | kieranjol | Owned by: | |
---|---|---|---|
Priority: | wish | Component: | avformat |
Version: | git-master | Keywords: | mov cropping |
Cc: | Christian Ebert | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
Sample file - https://we.tl/t-KoBK9MnSLu
My MOV file contains a clap atom that defines the clean aperture width as 703/576, but an actual width of 720/576. QuickTime player will perform a crop and only display the 703/576 area. When remuxing to Matroska or other containers, I would have assumed that the expected behaviour would involve this cropping information being written to the remuxed file, probably using the various PixelCrop values within Matroska ( https://matroska.org/technical/specs/index.html ) Specifically, this value is stored in the QuickTime file using numerators and demoninators as such:
$ mediainfo --Details=1 clap.mov | grep clap -n10 284-ECE5C05C Clean Aperture (40 bytes) 285-ECE5C05C Header (8 bytes) 286-ECE5C05C Size: 40 (0x00000028) 287:ECE5C060 Name: clap 288-ECE5C064 apertureWidth_N: 41472 (0x0000A200) 289-ECE5C068 apertureWidth_D: 59 (0x0000003B) 290-ECE5C06C apertureHeight_N: 576 (0x00000240) 291-ECE5C070 apertureHeight_D: 1 (0x00000001) 292-ECE5C074 horizOff_N: 0 (0x00000000) 293-ECE5C078 horizOff_D: 1 (0x00000001) 294-ECE5C07C vertOff_N: 0 (0x00000000) 295-ECE5C080 vertOff_D: 1 (0x00000001)
It is somewhat related to this issue https://trac.ffmpeg.org/ticket/1485
How to reproduce:
Using my sample file - I would expect the following command to include the cropping information but it does not. ffprobe does not seem to read this cropping info, so mediainfo is useful to check the clap values. My sample was generated directly from a VHS capture using the Blackmagic Intensity Shuttle, with lots of dropped frames which doesn't relate to this issue
% $ ffmpeg -i clap.mov -c copy mkv.mkv ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.42.1) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libtesseract --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 libpostproc 55. 1.100 / 55. 1.100 Guessed Channel Layout for Input Stream #0.1 : stereo Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clap.mov': Metadata: major_brand : qt minor_version : 537199360 compatible_brands: qt creation_time : 2018-09-13T08:48:41.000000Z Duration: 00:00:01.00, start: 0.000000, bitrate: 80686 kb/s Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le(smpte170m/bt470bg/bt709, top coded first (swapped)), 720x576, 79626 kb/s, SAR 59:54 DAR 295:216, 9 fps, 25 tbr, 25k tbn, 25k tbc (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Alias Data Handler encoder : Uncompressed 10-Bit YUV timecode : 00:00:00:00 Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Alias Data Handler timecode : 00:00:00:00 Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Alias Data Handler reel_name : 001 timecode : 00:00:00:00 Output #0, matroska, to 'mkv.mkv': Metadata: major_brand : qt minor_version : 537199360 compatible_brands: qt encoder : Lavf58.12.100 Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le(smpte170m/bt470bg/bt709, top coded first (swapped)), 720x576 [SAR 59:54 DAR 295:216], q=2-31, 79626 kb/s, 9 fps, 25 tbr, 1k tbn, 25k tbc (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Alias Data Handler encoder : Uncompressed 10-Bit YUV timecode : 00:00:00:00 Stream #0:1(eng): Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Alias Data Handler timecode : 00:00:00:00 Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 9 fps=0.0 q=-1.0 Lsize= 9834kB time=00:00:00.40 bitrate=200899.4kbits/s speed=10.3x video:9720kB audio:112kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.017699%
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Change History (14)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Keywords: | mov added |
---|
Is the issue you see reproducible with current FFmpeg git head?
comment:3 by , 6 years ago
Hi Carl, yes it is. I see no evidence of crop values in the matroska file and ffprobe does not detect clean aperture values in the source
$ ./ffmpeg -i clap.mov -c copy mkv.mkv ffmpeg version N-92510-gfa08345e88 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.42.1) configuration: libavutil 56. 23.101 / 56. 23.101 libavcodec 58. 39.100 / 58. 39.100 libavformat 58. 22.100 / 58. 22.100 libavdevice 58. 6.100 / 58. 6.100 libavfilter 7. 46.100 / 7. 46.100 libswscale 5. 4.100 / 5. 4.100 libswresample 3. 4.100 / 3. 4.100 Guessed Channel Layout for Input Stream #0.1 : stereo Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clap.mov': Metadata: major_brand : qt minor_version : 537199360 compatible_brands: qt creation_time : 2018-09-13T08:48:41.000000Z Duration: 00:00:01.00, start: 0.000000, bitrate: 80686 kb/s Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le(smpte170m/bt470bg/bt709, top coded first (swapped)), 720x576, 79626 kb/s, SAR 59:54 DAR 295:216, 9 fps, 25 tbr, 25k tbn, 25k tbc (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Video Media Handler encoder : Uncompressed 10-Bit YUV timecode : 00:00:00:00 Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Sound Media Handler timecode : 00:00:00:00 Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : Time Code Media Handler reel_name : 001 timecode : 00:00:00:00 Output #0, matroska, to 'mkv.mkv': Metadata: major_brand : qt minor_version : 537199360 compatible_brands: qt encoder : Lavf58.22.100 Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le(smpte170m/bt470bg/bt709, top coded first (swapped)), 720x576 [SAR 59:54 DAR 295:216], q=2-31, 79626 kb/s, 9 fps, 25 tbr, 1k tbn, 25k tbc (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Video Media Handler encoder : Uncompressed 10-Bit YUV timecode : 00:00:00:00 Stream #0:1(eng): Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Sound Media Handler timecode : 00:00:00:00 Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 9 fps=0.0 q=-1.0 Lsize= 9834kB time=00:00:00.40 bitrate=200899.4kbits/s speed=5.21x video:9720kB audio:112kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.017719%
$ ./ffprobe -show_streams -show_format -select_streams v:0 clap.mov ffprobe version N-92510-gfa08345e88 Copyright (c) 2007-2018 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.42.1) configuration: libavutil 56. 23.101 / 56. 23.101 libavcodec 58. 39.100 / 58. 39.100 libavformat 58. 22.100 / 58. 22.100 libavdevice 58. 6.100 / 58. 6.100 libavfilter 7. 46.100 / 7. 46.100 libswscale 5. 4.100 / 5. 4.100 libswresample 3. 4.100 / 3. 4.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clap.mov': Metadata: major_brand : qt minor_version : 537199360 compatible_brands: qt creation_time : 2018-09-13T08:48:41.000000Z Duration: 00:00:01.00, start: 0.000000, bitrate: 80686 kb/s Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le(smpte170m/bt470bg/bt709, top coded first (swapped)), 720x576, 79626 kb/s, SAR 59:54 DAR 295:216, 9 fps, 25 tbr, 25k tbn, 25k tbc (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Video Media Handler encoder : Uncompressed 10-Bit YUV timecode : 00:00:00:00 Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 2 channels, s32 (24 bit), 2304 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : ?Apple Sound Media Handler timecode : 00:00:00:00 Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default) Metadata: creation_time : 2018-09-13T08:48:41.000000Z handler_name : Time Code Media Handler reel_name : 001 timecode : 00:00:00:00 Unsupported codec with id 0 for input stream 2 [STREAM] index=0 codec_name=v210 codec_long_name=Uncompressed 4:2:2 10-bit profile=unknown codec_type=video codec_time_base=1/9 codec_tag_string=v210 codec_tag=0x30313276 width=720 height=576 coded_width=720 coded_height=576 has_b_frames=0 sample_aspect_ratio=59:54 display_aspect_ratio=295:216 pix_fmt=yuv422p10le level=-99 color_range=unknown color_space=smpte170m color_transfer=bt709 color_primaries=bt470bg chroma_location=unspecified field_order=tb timecode=N/A refs=1 id=N/A r_frame_rate=25/1 avg_frame_rate=9/1 time_base=1/25000 start_pts=0 start_time=0.000000 duration_ts=25000 duration=1.000000 bit_rate=79626240 max_bit_rate=N/A bits_per_raw_sample=10 nb_frames=9 nb_read_frames=N/A nb_read_packets=N/A DISPOSITION:default=1 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:creation_time=2018-09-13T08:48:41.000000Z TAG:language=eng TAG:handler_name=Apple Video Media Handler TAG:encoder=Uncompressed 10-Bit YUV TAG:timecode=00:00:00:00 [/STREAM] [FORMAT] filename=clap.mov nb_streams=3 nb_programs=0 format_name=mov,mp4,m4a,3gp,3g2,mj2 format_long_name=QuickTime / MOV start_time=0.000000 duration=1.000000 size=10085813 bit_rate=80686504 probe_score=100 TAG:major_brand=qt TAG:minor_version=537199360 TAG:compatible_brands=qt TAG:creation_time=2018-09-13T08:48:41.000000Z [/FORMAT]
comment:4 by , 6 years ago
Hi Carl,
This handling of Clap Atom into the FFV1 Matroska is also a major factor for the BFI, as we aim to transcode MOVs to FFV1 Matroska for preservation in our repository. We would aim to retain the Clap Atom into the PixelCrop or alternative if there is a preferred approach to map clap atom to Matroska output.
All the best,
Stephen
follow-up: 6 comment:5 by , 6 years ago
Keywords: | cropping added |
---|---|
Version: | unspecified → git-master |
Regarding the title of this ticket: Do I understand correctly that the issue you see is only reproducible when remuxing to matroska?
follow-up: 7 comment:6 by , 6 years ago
Replying to cehoyos:
Regarding the title of this ticket: Do I understand correctly that the issue you see is only reproducible when remuxing to matroska?
Kind of. I think ultimately the issue is that ffmpeg does not detect clean aperture values, and when remuxing to any container, this context is lost. I am specifically interested in the mapping of these values to Matroska, and I would consider the PixelCrop values to be the suitable destination for these values. You could say that there should be a mapping to AVI/MXF etc but I don't know about those containers.
Some extra info : https://mailarchive.ietf.org/arch/msg/cellar/QL7-L5ljb4MtlnvZEUsggYsKbjc
follow-up: 8 comment:7 by , 6 years ago
Replying to kieranjol:
Replying to cehoyos:
Regarding the title of this ticket: Do I understand correctly that the issue you see is only reproducible when remuxing to matroska?
Kind of.
Really?
I think ultimately the issue is that ffmpeg does not detect clean aperture values
Can we agree that this issue is completely unrelated to matroska and the (first) issue is simply that FFmpeg ignores the clap atom in mov files?
follow-up: 9 comment:8 by , 6 years ago
Replying to cehoyos:
Replying to kieranjol:
Replying to cehoyos:
Regarding the title of this ticket: Do I understand correctly that the issue you see is only reproducible when remuxing to matroska?
Kind of.
Really?
I think ultimately the issue is that ffmpeg does not detect clean aperture values
Can we agree that this issue is completely unrelated to matroska and the (first) issue is simply that FFmpeg ignores the clap atom in mov files?
Yes, firstly - FFmpeg should be able to read the clap atom prior to this issue being fixed. I think this issue should stay open as I think there should be a mapping between clap and PixelCrop. Should I start a new issue that's just 'FFmpeg ignores clap atom'?
comment:9 by , 6 years ago
Replying to kieranjol:
Replying to cehoyos:
Replying to kieranjol:
Replying to cehoyos:
Regarding the title of this ticket: Do I understand correctly that the issue you see is only reproducible when remuxing to matroska?
Kind of.
Really?
I think ultimately the issue is that ffmpeg does not detect clean aperture values
Can we agree that this issue is completely unrelated to matroska and the (first) issue is simply that FFmpeg ignores the clap atom in mov files?
Yes, firstly - FFmpeg should be able to read the clap atom prior to this issue being fixed. I think this issue should stay open as I think there should be a mapping between clap and PixelCrop. Should I start a new issue that's just 'FFmpeg ignores clap atom'?
Just to clarify, I agree that this issue is jumping too far ahead and that the clap atom support needs to come first. The request for a mapping requires clap support. But I think the mapping is important so I'd like to leave the ticket open.
follow-up: 11 comment:10 by , 6 years ago
Component: | undetermined → avformat |
---|---|
Priority: | normal → wish |
Summary: | clap atom values ignored by ffmpeg when remuxing to matroska → clap atom values ignored by ffmpeg |
Type: | defect → enhancement |
comment:11 by , 5 years ago
Replying to cehoyos:
Please can I add a big +1 to this request Carl. Many thanks!
comment:12 by , 5 years ago
http://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/261465.html a patch that refers to this ticket was posted to ffmpeg-devel btw
comment:13 by , 3 years ago
Cc: | added |
---|
comment:14 by , 5 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Implemented in 93be6b425ebeb6cf96faf502281a4f7a1ed5138c and 32588a9394b33deed1daa6f085138997a111e8eb.
https://archive.org/details/kieran_Clap
You should be able to download the original mov here.