
如何使用 FFmpeg 從視訊檔案中移除音軌?
答案1
您可以使用以下-an
標誌刪除音訊:
input_file=example.mkv
output_file=example-nosound.mkv
ffmpeg -i $input_file -c copy -an $output_file
這個 ffmpeg 標誌已記錄這裡。
答案2
您可能不想重新編碼影片(一個緩慢且有損的過程),因此請嘗試:
input_file=example.mkv
output_file=example-nosound.mkv
ffmpeg -i $input_file -vcodec copy -an $output_file
(注意一些 Linux 發行版現在附帶ffmpeg 的 avconv 分支)
答案3
avconv -i [input_file] -vcodec copy -an [output_file]
ffmpeg
如果由於現有的而無法安裝,avconv
請嘗試。
答案4
您還可以使用-map
選項來ffmpeg
更好地控制最終影片容器中的具體內容。
舉例來說,您的視訊檔案my_video.mp4
是這樣組成的:
Input #0
Stream #0:0 Video: h264
Stream #0:1 Audio: English
Stream #0:2 Audio: German
Stream #0:3 Audio: Japanese
Stream #0:4 Audio: Spanish
Stream #0:5 Audio: Italian
去除全部音軌(就像-an
選項一樣):
ffmpeg -i my_video.mp4 -map 0 -map -0:a -c copy my_video.noaudio.mp4`
-map 0
取得整個輸入(視訊、音訊、字幕、元資料、章節等)。
-map -0:a
刪除所有音軌來自輸入 0(注意-
符號)。
-c copy
按原樣複製,無需重新編碼。
要刪除日本人和西班牙語曲目:
ffmpeg -i my_video.mp4 -map 0 -map -0:3 -map -0:4 -c copy my_video.nojap.noesp.mp4`
-map -0:3
從輸入 0 中刪除第三個軌道,即日文音訊。
-map -0:4
從輸入 0 中刪除第四個音軌,即西班牙語音訊。
刪除所有音軌,但義大利語:
ffmpeg -i my_video.mp4 -map 0 -map -0:a -map 0:5 -c copy my_video.ita.mp4`
-map -0:a
刪除輸入 0 中的所有
-map 0:5
音軌-
。
當處理多個文件時,這也非常有用。
例如當:
- 從一個文件中抓取音頻
- 來自另一首的音軌
- 來自第三個的字幕和元數據