Created
July 28, 2024 12:21
-
-
Save ybagheri/3b1136b3abe6b4a2006ab01efaa1fab4 to your computer and use it in GitHub Desktop.
How do you convert an entire directory with ffmpeg?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
link: https://stackoverflow.com/questions/38449239/converting-all-the-mp4-audio-files-in-a-folder-to-mp3-using-ffmpeg | |
# Windows | |
# first create a folder with name outputs inside video folder | |
FOR /F "tokens=*" %G IN ('dir /b *.mp4') DO ffmpeg -i "%G" -acodec mp3 "outputs\%~nG.mp3" | |
## convert lower quality and size | |
FOR /F "tokens=*" %G IN ('dir /b *.mp4') DO ffmpeg -i "%G" -acodec mp3 -ab 64000 -ar 22050 "outputs\%~nG.mp3" | |
# Linux, MacOS | |
#For converting only .mp4 files: | |
mkdir outputs | |
for f in *.mp4; do ffmpeg -i "$f" -c:a libmp3lame "outputs/${f%.mp4}.mp3"; done | |
#For converting .m4a, .mov, and .flac: | |
mkdir outputs | |
for f in *.{m4a,mov,flac}; do ffmpeg -i "$f" -c:a libmp3lame "outputs/${f%.*}.mp3"; done | |
#For converting anything use the "*" wildcard: | |
mkdir outputs | |
for f in *; do ffmpeg -i "$f" -c:a libmp3lame "outputs/${f%.*}.mp3"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment