Hi

Heres how to extract the audio from a single video file

Bash:
ffmpeg -i infile.mp4 -vn -c:a copy outfile.m4a

batch extract audio from video files

Bash:
find -s . -type f -name "*.mp4" -exec sh -c \
'ffmpeg -i "${0}" -vn -c:a copy "${0%.*}.m4a"' \
"{}" \;

 
Hi

extract the video track from a video file

Bash:
ffmpeg -i infile.mp4 -an -c:v copy outfile.mp4

batch extract video tracks from all the mp4s in the current directory

Bash:
find -s . -type f -name "*.mp4" -exec sh -c \
'ffmpeg -i "${0}" -an -c:v copy "${0%.*}-extracted.mp4"' \
"{}" \;

 
You can use ffmpeg to change the audio rate of a file,
for example change the audio from 48000 to 44100

change audio rate to 44100

Bash:
ffmpeg -i infile.mp4 -ar 44100 outfile.mp4

change audio rate to 44100 batch process

Bash:
find -s . -type f -name "*.mp4" -exec sh -c \
'ffmpeg -i "${0}" -ar 44100 "${0%.*}-audiorate.mp4"' \
"{}" \;

 
You can convert stereo file to mono with ffmpeg

Bash:
ffmpeg -i infile.mp4 -ac 1 outfile.mp4

convert stereo to mono batch process

Bash:
find -s . -type f -name "*.mp4" -exec sh -c \
'ffmpeg -i "${0}" -ac 1 "${0%.*}-mono.mp4"' \
"{}" \;

 
change a videos frame rate to 30fps

Bash:
ffmpeg -i infile.mp4 -filter:v fps=fps=30 outfile.mp4

change frame rate batch process to 30fps

Bash:
find -s . -type f -name "*.mp4" -exec sh -c \
'ffmpeg -i "${0}" -filter:v fps=fps=30 "${0%.*}-framerate.mp4"' \
"{}" \;

 
resize a video to 1080p with ffmpeg and the scale and pad filters

Bash:
ffmpeg -i infile.mp4 -vf "scale=-1:1080,pad=1920:ih:(ow-iw)/2" outfile.mp4

scale and pad a video to 1080 batch process

Bash:
find -s . -type f -name "*.mp4" -exec sh -c \
'ffmpeg -i "${0}" -vf "scale=-1:1080,pad=1920:ih:(ow-iw)/2" "${0%.*}-1080.mp4"' \
"{}" \;

 
You can concatenate ( join ) video files together with ffmpeg

If you have media files with exactly the same codec
and codec parameters you can concatenate them

Create a list of all the mp4s in the current directory to concatenate

Bash:
printf "file '%s'\n" *.mp4 > list.txt

You can edit the list.txt file and change the order videos you want to concatenate

play the list with ffplay to check the order of the videos before you concatenate them

Bash:
ffplay -f concat -i list.txt

Use ffmpeg to concatenate the list of videos in the text file

Bash:
ffmpeg -f concat -i list.txt -c copy outfile.mp4

 
Back
Top