Linux - Bash command to compress video

December 2016


I would like to create a script to compress any video file format. Flv, these videos are contained in a directory.

I already have the command to perform the compression using the ffmpeg program.

Here is the command:

"ffmpeg-i video.wmv-ar 22050-ab 32-f flv-s 400x300 video.flv.

I would like to apply this command to all the videos in the current directory except for the video already. Flv, the video file names are not known in advance.


You can try the following command:
cd /your_directory
for i in *.wmv; do ffmpeg -i "${i}" -ar 22050 -ab 32 -f flv -s 400x300 "${i%.wmv}.flv"; done


Thanks to jipicy for this tip on the forum.

Related :

This document entitled « Linux - Bash command to compress video » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.