Skip to main content

transcoding

#copy all audio into h264 mp4 video with static image (useful for playing back audio with video players (shows cover while playing))

for i in *.mp3; 
do ffmpeg -loop 1 -i image-file.jpg -i $i -c:a copy -c:v h264 -q:v 255 -shortest -y -s cif -pix_fmt yuv420p mp4/$i.mp4; done #audio_to_mp4

Make h264 mp4 video loop from gif looping it 4 times (fix if width / height aren't divisible by 2)

for i in *.*; do ffmpeg -stream_loop 4 -i $i -q:v 0 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" $i.mp4; done #gif_trunc

Make a 5 second h264 mp4 video from static images with resize

for i in *.*; do ffmpeg.exe -loop 1 -t 5 -i $i -pix_fmt yuv420p -vf "scale=-2:1080" -q:v 0 $i.mp4 -y; done #static_resize

Make a 5 second h264 mp4 video from static images no resize (fix if width / height aren't divisible by 2)

for i in *.*; do ffmpeg.exe -loop 1 -t 5 -i $i -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -q:v 0 $i.mp4 -y; done; #static_trunc

Show all file resolutions in a directory

for i in *.*; do ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 $i; done #list_sizes