Live Chat!

video converter - ffmpeg

* * * *   2 votes

September 25th, 2006 mysurface Posted in Misc, chmod, ffmpeg | Hits: 10357 |

I get to know this command because my mplayer having problem playing flv downloaded from youtube. Therefore I google it and found that it is a command line can actually convert it into mpg.

To convert flv, let say myvideo.flv to myvideo.mpg, you can do this:

ffmpeg -i myvideo.flv -ar 22050 -b 500 -s 320x240 myvideo.mpg

I check out man for ffmpeg, i couldn’t find at my local machine and I search from the internet, it is quite brief.
Anyway, -i is input, -ar is to set audio sample rate to 22050 Hz, -b is to make it DIVX compatible -s defines its video size.

I turn it into script so that it is easy to trigger next time.

#!/bin/sh
if [ -n "$1" -a -n "$2" ]
then
ffmpeg -i $1 -ar 22050 -b 500 -s 320×240 $2
else
echo “Usage: `basename $0` source.flv target.mpg”
fi

if [-n "$1" -a -n "$2"] is actually check to see if source and destination video is not specified, then display the usage.

Copy these line into a text file call flv2mpg and change it to executable by doing this

chmod a+x flv2mpg

So next time if want to convert to mpg, just do this

./flv2mpg myvideo.{flv,mpg}

8 Responses to “video converter - ffmpeg”

  1. I tried doing that but it said that the file is truncated and/or corrupted… and im not really sure what to do…

  2. And it says permission denied…

  3. File truncated or corrupted probably means your flv, I am not sure, you didn’t mention what have you did to get this.

    Same to permission denied, it probably means you haven’t chmod to the script? or other reason..

  4. [...] -i is input file, -ar is audio rate in Hz. Just a slides of time, and you are done. And good thing about command line is you can put that into a bash script to do a batch converts. Related Posts video converter - ffmpeg I get to know this command because my mplayer having problem playing flv downloaded from youtube. Therefore I google it … [...]

  5. hi..
    i have tried this but its saying that “fmpeg.exe has encountered a problem and needs to close. We are sorry for the inconvenience.”

  6. Your script is OK. I worked perfectly with me. Thanks!

  7. [...] beberapa situs yang membahas topik ini, antara lain adalah Linux By Examples yang membahas bagaimana “membungkus” ffmpeg menjadi sebuah skrip yang mudah [...]

  8. PSP Video Says:

    Awesome post. Thanks for the info, very useful

Leave a Reply