ffmpeg (オーディオストリーム 2 つ + ビデオストリーム 1 つ) -vf/-af/-filter および -filter_complex は、同じストリームで一緒に使用することはできません。

ffmpeg (オーディオストリーム 2 つ + ビデオストリーム 1 つ) -vf/-af/-filter および -filter_complex は、同じストリームで一緒に使用することはできません。

スクリーンビデオと2つのオーディオストリーム(マイクから1つ、アナログモニタから1つ)をキャプチャしようとしています。

    ffmpeg -video_size "$__screen_size__" \
        -framerate 50 \
        -thread_queue_size 512 -f x11grab -i :0.0+0,0 \
        -thread_queue_size 512 -f pulse -i "$__input_mic__" \
        -thread_queue_size 512 -f pulse -i "$__output_monitor__" \
        -filter_complex amerge \
        -ac 2 \
        -vcodec libx264rgb -crf 0 -preset:v ultrafast \
        -acodec pcm_s16le \
        -af aresample=async=1:first_pts=0 \
        -async 1 \
        -y \
        "$__output__"

問題は、ffmpegが1つのストリームで同時に2つのフィルタを使用することについて文句を言うことです。

Filtergraph 'aresample=async=1:first_pts=0' was specified through the
 -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph.
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.

ただし、以下のスクリプト(マイクを構成するオーディオストリームが1つしかありません)は、オーディオストリームをマージする必要がない場合に正しく機能します。

    ffmpeg -video_size "$__screen_size__" \
        -framerate 50 \
        -thread_queue_size 512 -f x11grab -i :0.0+0,0 \
        -thread_queue_size 512 -f pulse -i "$__input_mic__" \
        -vcodec libx264rgb -crf 0 -preset:v ultrafast \
        -acodec pcm_s16le \
        -af aresample=async=1:first_pts=0 \
        -async 1 \
        -y \
        "$__output__"

デフォルトでは、以下を削除します。

        -thread_queue_size 512 -f pulse -i "$__output_monitor__" \
        -filter_complex amerge \
        -ac 2 \

上記の項目を削除し-af aresample=async=1:first_pts=0て維持すると、オーディオとビデオは同期されません。

基本的に、遅延なしでオーディオストリームをマージしたいと思います。

ベストアンサー1

単一フィルタグラフにすべてのフィルタを割り当てる必要があります。

-filter_complex [1]aresample=async=1:first_pts=0[a];[2]aresample=async=1:first_pts=0[b];[a][b]amerge

おすすめ記事