Try   HackMD

FFmpeg:快速轉檔小工具 ConvertionTool

FFmpeg 是一個可以執行音訊和視訊多種格式的錄影、轉檔、串流功能自由軟體,這邊筆記一下如何用 .bat 批次檔製作簡易且快速的 .mp4 轉 .mp3 轉檔小工具(提取影片中音樂)。

〔Step 1〕先下載並且解壓縮這個:FFmpeg

- 這是 FFmpeg 官網 提供的 4.4 版本 FFmpeg 的 .7z 壓縮包載點
- 下載後解壓,裡面有三個執行檔,需要的用到的只有 ffmpeg.exe
- 順便推薦一款介面乾淨簡潔的壓縮 / 解壓縮軟體:Bandizip

〔Step 2〕開新資料夾(ConvertionTool)放入ffmpeg.exe

- 新資料夾路徑開在哪裡都行。這邊把資料夾命名 ConvertionTool
- 然後把 ffmpeg.exe 執行檔放在該資料夾裡面

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


〔Step 3〕右鍵新建記事本,在新文字文件中複製貼上以下這段:

這是 .mp4 轉 .mp3 的命令,本篇都以這段為範例。

@echo off for /f "tokens=*" %%* in ('dir /b *.mp4') do call :action %%~n* echo 轉檔執行成功 goto :eof :action ffmpeg -i %*.mp4 -acodec libmp3lame -ar 44100 -ab 320k %*.mp3

如果要 .avi .flv .mov 轉音檔可以參考這個命令(用 .avi 把 .mp4 部分替換掉),以此類推。

@echo off for /f "tokens=*" %%* in ('dir /b *.avi') do call :action %%~n* echo 轉檔執行成功 goto :eof :action ffmpeg -i %*.avi -acodec libmp3lame -ar 44100 -ab 320k %*.mp3

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


〔Step 4〕把新文字文件另存為mp4_to_mp3.bat

記得檢視裡面的副檔名要打勾讓它顯示副檔名,這樣存檔的時候才能把 .txt 存成 .bat,如果沒有勾選的話怎麼存檔案格式都會是文字文件。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


〔Step 5〕把 mp4 影片放入ConvertionTool資料夾,雙擊 bat 檔

把想要轉換的 .mp4 影片檔放到 ConvertionTool 資料夾中,直接雙擊 mp4_to_mp3.bat 批次檔,會跳出CMD視窗開始運行FFmpeg轉檔指令,運行過程不用理它,轉檔完畢會自動關閉這個CMD視窗。跑完會在 ConvertionTool 資料夾當中自動生成轉換好的 .mp3 音檔。

這樣就可以成功將影片檔轉成音檔了。同理也可以自行更改 .bat 當中的指令進行影片檔案格式互相轉換(比如 .mov 轉成 .mp4)。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →



〔ConvertionTool〕現成小工具

如果上面教學還是看不懂或操作有障礙可以載下面這個↓
我已經做好的轉檔小工具:ConvertionTool 載點

這是另一篇在環境變數裡安裝 FFmpeg 並且可以用 CMD 命令轉檔的教學:
https://hackmd.io/@withhhsong/FFmpegMp4Convertion


: : 20210420 : : 與松 withhhsong : :

tags: ffmpeg withhhsong tutorials