Linux - Bash command to compress video

May 2017




Issue


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.

Solution


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

Note


Thanks to jipicy for this tip on the forum.

Related


Published by aakai1056. Latest update on February 10, 2010 at 08:28 AM by aakai1056.
This document, titled "Linux - Bash command to compress video," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).