H.264、HEVC、VP9、AV1、Proresのビットストリームフィルタで色関係のまとめ。各コーデックで出力したときにcolor_range、color_primaries、color_trc、color_spaceの情報を書き込む。
オプションでの色の設定。
色の情報の扱いについて
H.264、HEVC
以下のコマンドですべての内容を調べられるが設定値までは載っていない。H.264、HEVCもほとんど同じ。
ffmpeg -h bsf=h264_metadata
ffmpeg -h bsf=hevc_metadata
セクションのE.2.1と、テーブルE-3、E-4、E-5を参照:
H.264 : Advanced video coding for generic audiovisual services
FFmpeg Bitstream Filters Documentation : h264_metadata
セクションのE.3.1と、テーブルE.3、E.4、E.5を参照:
H.265 : High efficiency video coding
FFmpeg Bitstream Filters Documentation : hevc_metadata
ffmpeg -i input -c:v libx264 -bsf:v h264_metadata=colour_primaries=1:transfer_characteristics=1:matrix_coefficients=1 -c:a copy output.mp4
ffmpeg -i input -c:v libx265 -bsf:v hevc_metadata=colour_primaries=1:transfer_characteristics=1:matrix_coefficients=1 -c:a copy output.mp4
- colour_primaries[int]
- 1:BT.709
- 4:BT.470 System M
- 5:BT.601 PAL
- 6:BT.601 NTSC
- 7:SMPTE 240M
- 8:Generic film
- 9:BT.2020
- 10:XYZ, smpte428, smpte428_1
- 11:DCI P3, smpte431
- 12:Display P3, smpte432
- transfer_characteristics[int]
- 1:BT.709
- 4:BT.470 System M
- 5:BT.470 System B/G
- 6:BT.601
- 7:SMPTE 240M
- 8:Linear
- 9:Logarithmic (100:1)
- 10:Logarithmic (316.22777:1)
- 11:xvYCC
- 12:BT.1361
- 13:sRGB/sYCC
- 14:BT.2020 (10-bit)
- 15:BT.2020 (12-bit)
- 16:PQ
- 17:SMPTE
- 18:HLG
- matrix_coefficients[int]
- 1:BT.709
- 5:BT.470 System B/G
- 6:BT.601
- 7:SMPTE 240M
- 8:YCgCo
- 9:BT.2020 non-constant
- 10:BT.2020 constant
- 11:Y’D’zD’x
- 12:Chromaticity-derived non-constant
- 13:Chromaticity-derived constant
- 14:ICtCp
VP9
RGBに設定されているフレームは、暗黙のうちにフルレンジに設定され、プロファイルの0と2とは互換性がない。
ffmpeg -h bsf=vp9_metadata
FFmpeg Bitstream Filters Documentation : vp9_metadata
ffmpeg -i input -c:v libvpx-vp9 -crf 30 -b:v 0 -qmin 3 -qmax 40 -bsf:v vp9_metadata=color_space=bt709:color_range=tv -c:a libopus -b:a 96k output.webm
- color_space
- unknown
- bt601
- bt709
- smpte170
- smpte240
- bt2020
- rgb
- color_range
- tv
- pc
AV1
colorのスペルがH.264、HEVCのcolourでないことに注意。
ffmpeg -h bsf=av1_metadata
セクションの6.4.2を参照:
AV1 Bitstream & Decoding Process Specification : Color config semantics
FFmpeg Bitstream Filters Documentation : av1_metadata
ffmpeg -i input -c:v libaom-av1 -crf 30 -b:v 0 -strict experimental -bsf:v av1_metadata=color_primarie=1:transfer_characteristics=1:matrix_coefficients=1 -c:a copy output.mkv
- color_primaries[int]
- 1:BT.709
- 4:BT.470 System M
- 5:BT.601 PAL
- 6:BT.601 NTSC
- 7:SMPTE 240M
- 8:Generic film
- 9:BT.2020
- 10:XYZ, smpte428, smpte428_1
- 11:DCI P3, smpte431
- 12:Display P3, smpte432
- transfer_characteristics[int]
- 1:BT.709
- 4:BT.470 System M
- 5:BT.470 System B/G
- 6:BT.601
- 7:SMPTE 240M
- 8:Linear
- 9:Logarithmic (100:1)
- 10:Logarithmic (316.22777:1)
- 11:xvYCC
- 12:BT.1361
- 13:sRGB/sYCC
- 14:BT.2020 (10-bit)
- 15:BT.2020 (12-bit)
- 16:PQ
- 17:SMPTE
- 18:HLG
- matrix_coefficients[int]
- 1:BT.709
- 5:BT.470 System B/G
- 6:BT.601
- 7:SMPTE 240M
- 8:YCgCo
- 9:BT.2020 non-constant
- 10:BT.2020 constant
- 11:Y’D’zD’x
- 12:Chromaticity-derived non-constant
- 13:Chromaticity-derived constant
- 14:ICtCp
Prores
Proresの承認関係の話:
- Apple ProRes について – Apple サポート
- Apple ProRes や ProRes RAW の使用が承認されている製品 – Apple サポート
- VEGASのProResはApple未承認だが違法ではなかった件 | 映像知識のメモ帳
Proresコーデックはprores、prores_aw、prores_ksの3種類あるが、prores、prores_ksはほとんど同じと考え、prores_ksだけ4444プロファイルに対応していて設定できる内容が多い。
エンコード設定の例。10ビット422で出力する。
ffmpeg -i input -c:v prores_ks -profile 4444xq -vendor Lavc -pix_fmt yuv422p10 -c:a copy prores_ks.mkv
ffmpeg -h encoder=prores_ks
- -mbs_per_slice[int]
既定値:8
範囲:1から8まで - -profile[int]
- -1, auto:既定値
- 0, proxy:apco
- 1, lt:apcs
- 2, standard:acpn
- 3, hq:apch
- 4, 4444:ap4h
- 5, 4444xq:ap4x
- -vendor[string]
vendor IDの指定。文字は4バイト限定。apl0にするとAppleエンコーダから出力したIDになる
既定値:Lavc - -bits_per_mb[int]
1つのマクロブロックあたりに求めるビット数
既定値:0
範囲:0から8192まで - -quant_mat[int]
定量化マトリクスの指定 - -1, auto:既定値
- 0, proxy
- 2, lt
- 3, standard
- 4, hq
- 6, default
- -alpha_bits[int]
アルファチャンネルのビット数
既定値:16
範囲:0(無効)、8、16
- Encode/VFX – FFmpeg
- FFmpeg Codecs Documentation : ProRes
- FFmpeg Prores explained. – One Last Time
- encoding – What are the differences between the three bundled ffmpeg prores encoders? – Video Production Stack Exchange
ffmpeg -h bsf=prores_metadata
FFmpeg Bitstream Filters Documentation : prores_metadata
ffmpeg -i input -c:v prores_ks -profile 4444xq -vendor Lavc -pix_fmt yuv422p10 -bsf:v prores_metadata=color_primarie=1:color_trc=1:colorspace=1 -c:a copy prores_ks.mkv
- color_primarie[int]
- -1, auto:既定値
- 0, unknown
- 1, bt709
- 5, bt470bg
- 6, smpte170m
- 9, bt2020
- 11, smpte431
- 12, smpte432
- color_trc[int]
- -1, auto:既定値
- 0, unknown
- 1, bt709
- 16, smpte2084
- 18, arib-std-b67
- colorspace[int]
- -1, auto:既定値
- 0, unknown
- 1, bt709
- 6, smpte170m
- 9, bt2020nc