請問使用FFmpeg把mp4檔改位元率後加ASS字幕輸出成mp4問題

我按照網路上教學想用N卡加速轉檔,然後改位元率加ASS字幕輸出成mp4,指令如下
ffmpeg -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i invideo.mp4 -c:v h264_nvenc -vf "ass='ass檔名.ass'" -b:v 6000K -b:a 192K -ar 44100 outvideo.mp4
然後指令輸出都會失敗出現

請問使用FFmpeg把mp4檔改位元率後加ASS字幕輸出成mp4問題

想問是什麼原因???還是說只能分開做,先把視頻轉檔成我要的位元率後輸出視頻A,然後在輸出視頻A加入ass字幕輸出視頻B,這樣子弄,順便問一下我上面的指令要怎麼設定批次轉檔bat,不好意思新手所以問題多,請多多包涵,謝謝
視頻....
mss77520 wrote:
我按照網路上教學想用N...(恕刪)


以研究出來了!!謝謝各位
拿掉 -hwaccel cuvid 其他原封不動就行

"-hwaccel cuvid" 會讓decode完的frame留在GPU memory裡繼續處理, 直到encode完才搬到系統memory, 如此可減少了memory的搬動而提高效率; 然而, NV的硬體不支援上字幕, 所以decode完的frame需傳回系統memory讓CPU處理, 因此必須移除這參數

詳請可參考這裡, 在"Hardware accelerated transcoding with FFmpeg"這個段落

至於批次處理, 通常是搭配FOR使用, 批次擋範例如下, 會把目錄下所有的mp4, 如001.mp4加上001.aas輸出到output目錄下的000_w_sub.mp4

mkdir output
for %%i in (*.mp4) do (
ffmpeg -y -vsync 0 -c:v h264_cuvid -i %%i -vf "ass=%%~ni.ass" -b:v 6000K -b:a 192K -ar 44100 -c:v h264_nvenc output\%%~ni_w_sub.mp4
)
1tac wrote:
拿掉 -hwaccel...(恕刪)



我是拿掉前面-vsync 0 -hwaccel cuvid -c:v h264_cuvid 這一整串,原來只要拿掉那兩個就好,太感謝了,批次處理的指令也很謝謝你的幫忙
1tac
留下"-c:v h264_cuvid"是為了用硬體解碼, 如果拿掉就變成用ffmpeg內建的h264 decoder解碼, 也就是軟解
建議詳見4F連結的"Mixing CPU and GPU processing"段落
另外可參考ffmpeg wiki
ffmpeg -vsync 0 -c:v h264_cuvid -i invideo.mp4 -vf "ass='ass檔名.ass',hwupload_cuda" -c:v h264_nvenc -b:v 6000K -b:a 192K -ar 44100 outvideo.mp4
硬解,cpu上字幕後上傳frame硬壓
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208356, current: 206206; changing to 208357. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208357, current: 206206; changing to 208358. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208358, current: 206206; changing to 208359. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208359, current: 206206; changing to 208360. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208360, current: 206206; changing to 208361. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208361, current: 206206; changing to 208362. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208362, current: 206206; changing to 208363. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208363, current: 206206; changing to 208364. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208364, current: 206206; changing to 208365. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208365, current: 206206; changing to 208366. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208366, current: 206206; changing to 208367. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208367, current: 206206; changing to 208368. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Non-monotonous DTS in output stream 0:0; previous: 208368, current: 206206; changing to 208369. This may result in incorrect timestamps in the output file.
[mp4 @ 0000028c199dc000] Invalid DTS: 370370 PTS: 209209 in output stream 0:0, replacing by guess


最近合併一部字幕視頻出現這個,只有在合併那一部才會遇到這個問題,想問一下是什麼問題?謝謝

我的指令如下
mkdir ..\transfer
for /r %%a in (*.mp4) do ffmpeg -y -vsync 0 -c:v h264_cuvid -i "%%a" -c:v h264_nvenc -vf "subtitles=filename='%%~na.ass'" -b:v 6000K -b:a 192K -ar 44100 "..\transfer\%%~na".mp4
j800930
你的ass時間軸有沒有問題?不做內嵌字幕的動作而是對原始mp4作重編碼還會報時間戳錯誤?
文章分享
評分
評分
複製連結

今日熱門文章 網友點擊推薦!