使用complex_filter對影片進行時移時影片品質較差

使用complex_filter對影片進行時移時影片品質較差

我正在使用一個有效的複雜過濾器,但是當我稍微改變它時,我得到的結果品質很差。這個版本似乎運作正常:

[0:v]scale=640:480 [temp0];
[0:v] setpts=PTS-STARTPTS-1/TB, scale=128x96 [firsthistory];
[0:v] setpts=PTS-STARTPTS-1/TB, scale=128x96 [secondhistory];
[temp0][firsthistory] overlay=shortest=1:x=480:y=28  [temp1];
[temp1][secondhistory] overlay=shortest=1:x=480:y=139

這是拍攝視頻,然後在右側放置兩個子螢幕疊加層,顯示視頻在時間上向前移動。為了設定字幕的時間提前,我使用 setpts=PTS-STARTPTS-n/TB,其中 n 是移動時間的秒數。這可行,但老實說我不懂。

無論如何,當 n=1 時,這是有效的。如果我進一步向前移動視頻,則生成的視頻品質很差。視訊輸出不穩定,例如使用以下 n=2,4:

[0:v]scale=640:480 [temp0];
[0:v] setpts=PTS-STARTPTS-2/TB, scale=128x96 [firsthistory];
[0:v] setpts=PTS-STARTPTS-4/TB, scale=128x96 [secondhistory];
[temp0][firsthistory] overlay=shortest=1:x=480:y=28  [temp1];
[temp1][secondhistory] overlay=shortest=1:x=480:y=139

完整的 ffmpeg 參數是

'-i',
'b77b24e5-27a6-459b-aa11-8f79e0162659.mpeg',
'-filter_complex',
'[0:v]scale=640:480 [temp0];[0:v] setpts=PTS-STARTPTS-2/TB, scale=128x96 [firsthistory];[0:v] setpts=PTS-STARTPTS-4/TB, scale=128x96 [secondhistory];[temp0][firsthistory] overlay=shortest=1:x=480:y=28  [temp1];[temp1][secondhistory] overlay=shortest=1:x=480:y=139',
'-c:v',
'libvpx',
'-b:v',
'1M',
'-c:a',
'libvorbis',
'-vf',
'scale=960:-1',
'50649689680c6e5976d1d7fb3fd603259c2ab6e0.webm'

答案1

我最終沒有使用 setpts 來延遲覆蓋視頻。相反,我從同一個文件中獲取多個輸入,其中一些輸入使用 -itsoffset 進行時移。參數:

'-i',
'2c15d5be-2b61-4c0d-b394-7f3d45f6ca7f.mpeg',
'-itsoffset',
-6,
'-i',
'2c15d5be-2b61-4c0d-b394-7f3d45f6ca7f.mpeg',
'-itsoffset',
-3,
'-i',
'2c15d5be-2b61-4c0d-b394-7f3d45f6ca7f.mpeg',
'-filter_complex',
'[0:v] scale=640:480 [temp0];[1:v] scale=128x96 [firsthistory];[2:v] scale=128x96 [secondhistory];[temp0][firsthistory] overlay=x=480:y=28  [temp1];[temp1][secondhistory] overlay=x=480:y=144',
'-c:v',
'libvpx',
'-b:v',
'1M',
'-c:a',
'libvorbis',
'-vf',
'scale=960:-1',
'50649689680c6e5976d1d7fb3fd603259c2ab6e0.webm'

相關內容