With ffmpeg and bash this is really easy. Also .flv and .mpeg are easily interchangeable by all other video codecs supported by ffmpeg:
#!/bin/bash ##convert all videos of $srctype type to $desttype type encoding SRCCODEC="flv" DESTCODEC="mpeg" for i in *.$SRCCODEC; do echo echo -n "################### " echo -n "will convert \"$i\"" echo " ###################" echo ffmpeg -i "${i}" -y "${i%%.${SRCCODEC}}.${DESTCODEC}" && rm -vf "$i" done
Note that this includes removing the original video file only after a successful recode run overwriting existing destination files (-y option). The interesting part is this: ${i%%.${SRCCODEC}}
. It removes the source’s postfix, i.e. file extension. You could save this as a text file, say convert_all_videos_in_pwd.sh
and chmod +x filename
. I have my own scripts go to ~/bin which I include in $PATH
via ~/.bashrc
. If you do so you would typically call this within the videos’ directory including logging all output and errors to convert.log
, i.e. redirecting STDOUT
(= file descriptor 1) and STDERR
(= file descriptor 2) via &>
:
convert_all_videos_in_pwd.sh &> convert_all.log &
If you want to see the output you could use tail -f logfile
or read more on redirection and duplication. You could also do all that in a single command line:
for i in *.flv; do echo converting $i; ffmpeg -i "${i}" -y "${i%%.flv}.mpeg" && rm -vf "$i"; done