入力フレームがインターレース、プログレッシブ、トップフィールドファースト(tff)、ボトムフィールドファースト(bff)のどれであるかを調べるidet(interlace detect type) フィルタの使い方。また、隣り合うフレーム間で重複するフィールド(テレシネのサイン)も調べられる。

櫛状態を調べる方法にfieldmatchフィルタのcombdbgでデバグログを調べることもできる。
前後フィールドを考慮して逆テレシネするfieldmatch

基本コマンド

ffmpeg -i input.ts -vf idet -an -f null -

metadataフィルタを使ってテキストに出力する方法もある。
ffmpeg -i input -vf idet,metadata=mode=print:file=foo.txt -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

ファイルサイズの小さいログの出力例。
ffmpeg -i input.ts -vf idet -an -f null - > idet.txt 2>&1

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 v:0 -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.single.bff,lavfi.idet.single.progressive,lavfi.idet.single.undetermined,lavfi.idet.multiple.current_frame,lavfi.idet.multiple.tff,lavfi.idet.multiple.bff,lavfi.idet.multiple.progressive,lavfi.idet.multiple.undetermined -of csv > output.csv

上の表示順は順番を入れ替えても以下の順番で表示される。

lavfi.idet.multiple.progressive
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.single.bff
lavfi.idet.single.progressive
lavfi.idet.single.undetermined
lavfi.idet.multiple.current_frame
lavfi.idet.multiple.tff
lavfi.idet.multiple.bff
lavfi.idet.multiple.undetermined

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 は複数の過去フレームを参照する。

  • multiple.progressive
    multiple-frame detection を使って progressive の累積フレーム数
  • 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.undetermined
    multiple-frame detection を使って undetermined の累積フレーム数

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)