入力フレームがインターレース、プログレッシブ、トップフィールドファースト(tff)、ボトムフィールドファースト(bff) のどれであるかを調べる idet
(interlace detect type) フィルタの使い方。また、隣り合うフレーム間で重複するフィールド(テレシネのサイン)も調べられる。
基本コマンド
ffmpeg -i input.ts -vf idet -an -f null -
出力ログ例
Repeated Fields: Neither: 267 Top: 17 Bottom: 17
Single frame detection: TFF: 135 BFF: 0 Progressive: 44 Undetermined: 122
Multi frame detection: TFF: 279 BFF: 0 Progressive: 0 Undetermined: 22
ffplay で drawtext
フィルタを使って描写しながら再生
ffplay -i input.ts -vf idet,drawtext=fontfile='C\://WINDOWS/Fonts/arial.ttf':text='repeated.current_frame" "%{metadata\:lavfi.idet.repeated.current_frame}':fontsize=32:borderw=2:bordercolor=white
ffplay -i input.ts -vf idet,drawtext=fontfile='C\://WINDOWS/Fonts/arial.ttf':textfile=idet.txt:fontsize=32:borderw=2:bordercolor=white:line_spacing=2
ffprobe でログ出力。packet_tags で idet
フィルタ内容の順番を入れ換えても順番が入れ替わらない
ffprobe -v error -f lavfi -i movie=input.ts,idet -select_streams 0:v -show_entries packet=pts_time -show_entries packet_tags=lavfi.idet.repeated.current_frame,lavfi.idet.repeated.neither,lavfi.idet.repeated.top,lavfi.idet.repeated.bottom,lavfi.idet.single.current_frame,lavfi.idet.single.tff,lavfi.idet.multiple.tff,lavfi.idet.single.bff,lavfi.idet.multiple.current_frame,lavfi.idet.multiple.bff,lavfi.idet.single.progressive,lavfi.idet.multiple.progressive,lavfi.idet.single.undetermined,lavfi.idet.multiple.undetermined -of csv > output.csv
half_life を 1000 を右にして左右に再生する
ffplay -i input.ts -vf "split[a],idet,drawtext=fontfile='C\://WINDOWS/Fonts/arial.ttf':textfile=idet.txt:fontsize=32:borderw=2:bordercolor=white:line_spacing=2[b];[a]idet=half_life=1000,drawtext=fontfile='C\://WINDOWS/Fonts/arial.ttf':textfile=idet.txt:fontsize=32:borderw=2:bordercolor=white:line_spacing=2,crop=iw/2:ih:0:0,[b]overlay=W/2:0"
公式ドキュメント:FFmpeg Filters Documentation : idet
オプション
- intl_thres[float]
インターレース検出の閾値
既定値:1.04
範囲:-1 から FLT_MAX まで - prog_thres[float]
プログレッシブ検出の閾値
既定値:1.5
範囲:-1 から FLT_MAX まで - rep_thres[float]
重複検出の閾値
既定値:3
範囲:-1 から FLT_MAX まで - half_life[float]
統計で累積に対するフレームの寄与設定。既定値の 0 ではすべてのフレームに最後まで 1.0 ずつ加算される。0 に近いほど累積値が小さくなり少数で加算され、大きい値ほど 1.0 に近い値で加算される。-1 は 0 とおそらく同じ
既定値:0
範囲:-1 から FLT_MAX まで - analyze_interlaced_flag[int]
インターレースフラグが正確かどうかを判断するために使用するフレームの数を設定する。指定した値を超えたフレーム数は検出を止める
既定値:0(全フレーム)
範囲:0 から INT_MAX まで
メタデータ
Single frame detection は隣り合うフレームだけを参照する。Multiple frame detection は複数の過去フレームを参照する。
- repeated.current_frame
現在のフレームはどちらのフィールドが1つ前のフレームと比較して重複しているか
“neither”(どちらでもない), “top”, or “bottom” - repeated.neither
重複していないフィールドの累積フレーム数 - repeated.top
1つ前のフレームを比較して重複した tff の累積フレーム数 - repeated.bottom
1つ前のフレームを比較して重複した bff の累積フレーム数 - single.current_frame
single-frame detection を使って現在のフレームタイプを調べる
“tff” (top field first), “bff” (bottom field first), “progressive”, or “undetermined”(不明) - single.tff
single-frame detection を使って tff の累積フレーム数 - single.bff
single-frame detection を使って bff の累積フレーム数 - single.progressive
single-frame detection を使って progressive の累積フレーム数 - single.undetermined
single-frame detection を使って undetermined の累積フレーム数 - multiple.current_frame
multiple-frame detection を使って現在のフレームタイプを調べる
“tff” (top field first), “bff” (bottom field first), “progressive”, or “undetermined”(不明) - multiple.tff
multiple-frame detection を使って tff の累積フレーム数 - multiple.bff
multiple-frame detection を使って bff の累積フレーム数 - multiple.progressive
multiple-frame detection を使って progressive の累積フレーム数 - multiple.undetermined
multiple-frame detection を使って undetermined の累積フレーム数