diff --git a/src/cmake/testing.cmake b/src/cmake/testing.cmake index 0bbc77c716..113b993242 100644 --- a/src/cmake/testing.cmake +++ b/src/cmake/testing.cmake @@ -250,6 +250,9 @@ macro (oiio_add_all_tests) ENABLEVAR ENABLE_FITS IMAGEDIR fits-images URL http://www.cv.nrao.edu/fits/data/tests/) + oiio_add_tests (ffmpeg + ENABLEVAR ENABLE_FFMPEG + FOUNDVAR FFmpeg_FOUND) oiio_add_tests (gif FOUNDVAR GIF_FOUND ENABLEVAR ENABLE_GIF IMAGEDIR oiio-images/gif URL "Recent checkout of OpenImageIO-images") diff --git a/src/doc/builtinplugins.rst b/src/doc/builtinplugins.rst index 847010c9d4..fa5d7212e7 100644 --- a/src/doc/builtinplugins.rst +++ b/src/doc/builtinplugins.rst @@ -1433,6 +1433,9 @@ Some special attributes are used for movie files: * - ``ffmpeg:TimeCode`` - string - Start time timecode + * - ``CICP`` + - int[4] + - Coding-independent code points to describe the color profile. diff --git a/src/ffmpeg.imageio/ffmpeginput.cpp b/src/ffmpeg.imageio/ffmpeginput.cpp index 7cfaf601b2..ae1be13b7d 100644 --- a/src/ffmpeg.imageio/ffmpeginput.cpp +++ b/src/ffmpeg.imageio/ffmpeginput.cpp @@ -180,9 +180,9 @@ ffmpeg_input_imageio_create() // QuickTime / MOV // raw MPEG-4 video // MPEG-1 Systems / MPEG program stream -OIIO_EXPORT const char* ffmpeg_input_extensions[] = { - "avi", "mov", "qt", "mp4", "m4a", "3gp", "3g2", "mj2", "m4v", "mpg", nullptr -}; +OIIO_EXPORT const char* ffmpeg_input_extensions[] + = { "avi", "mov", "qt", "mp4", "m4a", "3gp", + "3g2", "mj2", "m4v", "mpg", "mkv", nullptr }; OIIO_PLUGIN_EXPORTS_END @@ -531,6 +531,12 @@ FFmpegInput::open(const std::string& name, ImageSpec& spec) m_spec.attribute("oiio:BitsPerSample", m_codec_context->bits_per_raw_sample); m_spec.attribute("ffmpeg:codec_name", m_codec_context->codec->long_name); + /* The ffmpeg enums are documented to match CICP values, except the color range. */ + const int cicp[4] + = { m_codec_context->color_primaries, m_codec_context->color_trc, + m_codec_context->colorspace, + m_codec_context->color_range == AVCOL_RANGE_MPEG ? 0 : 1 }; + m_spec.attribute("CICP", TypeDesc(TypeDesc::INT, 4), cicp); m_nsubimages = m_frames; spec = m_spec; m_filename = name; diff --git a/testsuite/ffmpeg/ref/out-ffmpeg-6.1.txt b/testsuite/ffmpeg/ref/out-ffmpeg-6.1.txt new file mode 100644 index 0000000000..82b00b1a10 --- /dev/null +++ b/testsuite/ffmpeg/ref/out-ffmpeg-6.1.txt @@ -0,0 +1,87 @@ +Reading ref/vp9_display_p3.mkv +ref/vp9_display_p3.mkv : 192 x 108, 3 channel, uint8 FFmpeg movie + 7 subimages: 192x108 [u8,u8,u8] + subimage 0: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: E65FAFBDA14543571188F8A84F75E1567E13148C + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 1: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 8D54A542C4E6A47A4F8829993001786BA62288DF + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 2: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 8D54A542C4E6A47A4F8829993001786BA62288DF + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 3: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 8D54A542C4E6A47A4F8829993001786BA62288DF + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 4: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: D9B0B8782048AEE24C4DF767E2B0969EBAB9D36B + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 5: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: C6B5666BB0A937A59762B8FE846BF50FED40889E + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 6: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 63516D95A1BB56E9E9483F9BCFC4305851A8BC54 + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 diff --git a/testsuite/ffmpeg/ref/out-ffmpeg8.0.txt b/testsuite/ffmpeg/ref/out-ffmpeg8.0.txt new file mode 100644 index 0000000000..988ef28210 --- /dev/null +++ b/testsuite/ffmpeg/ref/out-ffmpeg8.0.txt @@ -0,0 +1,87 @@ +Reading ref/vp9_display_p3.mkv +ref/vp9_display_p3.mkv : 192 x 108, 3 channel, uint8 FFmpeg movie + 7 subimages: 192x108 [u8,u8,u8] + subimage 0: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: C882152FF48CB068931C2710175659A9D0493C08 + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 1: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 1E2EB62F7BDD2DAC5C6FBDE582EE19978DC7C290 + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 2: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 1E2EB62F7BDD2DAC5C6FBDE582EE19978DC7C290 + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 3: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 1E2EB62F7BDD2DAC5C6FBDE582EE19978DC7C290 + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 4: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 35565DB895AB1CA413192B7F25A1890718CFC0F5 + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 5: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 338C9A82B74CE3B291DAD6564AE7C060AE6D9267 + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 + subimage 6: 192 x 108, 3 channel, uint8 FFmpeg movie + SHA-1: 90BC91EAA745A9C897EEDEC0D34BAAF1D40B1C7C + channel list: R, G, B + CICP: 12, 1, 1, 1 + DATE: "2025/09/13 21:58:33" + ENCODER: "Lavf61.7.100" + FramesPerSecond: 24/1 (24) + SCENE: "Scene" + ffmpeg:codec_name: "Google VP9" + oiio:BitsPerSample: 0 + oiio:Movie: 1 + oiio:subimages: 7 diff --git a/testsuite/ffmpeg/ref/vp9_display_p3.mkv b/testsuite/ffmpeg/ref/vp9_display_p3.mkv new file mode 100644 index 0000000000..b98a42fa3b Binary files /dev/null and b/testsuite/ffmpeg/ref/vp9_display_p3.mkv differ diff --git a/testsuite/ffmpeg/run.py b/testsuite/ffmpeg/run.py new file mode 100755 index 0000000000..06b8436b80 --- /dev/null +++ b/testsuite/ffmpeg/run.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +# Copyright Contributors to the OpenImageIO project. +# SPDX-License-Identifier: Apache-2.0 +# https://github.com/AcademySoftwareFoundation/OpenImageIO + +imagedir = "ref/" +files = [ "vp9_display_p3.mkv" ] +for f in files: + command = command + info_command (os.path.join(imagedir, f))