Convert video files to FLV using FFMPEG command
FFMPEG is a most popular command line tool to convert media files such as audio, video and images from one format to another. We are going to learn ffmpeg command usage to convert other media format to current most popular streaming FLV format. FFMPEG is cross platform tool and does not require any Gui, support several command line options to control your conversion. The other video format can not be played directly in web browser. A right way to publish your videos for viewing in a browser is using FLV wide acceptable format.
How to convert / FFMPEG usage command
Convert other video format to FLV
ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320×240 video.flv
-i input file name
-ar audio sampling rate in Hz
-ab audio bit rate in kbit/s
-f output format
-s output dimension
Convert other video to FLV with metadata
This require flvtool2 tool to be installed on your box.
ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320×240 – | flvtool2 -U stdin video.flv
Convert FLV vidoe to jpg image sequence
This command used to extract frame image sequence.
ffmpeg -i video.flv -an -r 1 -y -s 320×240 video%d.jpg
-i Input file name
-an disable audio
-r fps
-y overwrite file
-s output dimension
Convert particular frame to jpg
Return one particular jpeg image of the frame based on start and end time.
ffmpeg -i video.flv -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 320×240 video%d.jpg
-ss record start time
-t record end time last for
Return first frame of video as jpeg image.
ffmpeg -i video.flv -vcodec png -vframes 1 -an -f rawvideo -s 320×240 video%d.jpg
Read Related Post
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.



March 12th, 2008 at 1:53 am
hi
i follwed the steps of compiling FFmpeg for windows and it works fine whithout errors
put whine i type the convert commant
(ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320×240 video.flv)
i have this message
‘ffmpeg’ is not recognized as an internal or external command,
operable program or batch file.
??????
March 12th, 2008 at 2:01 am
This simply mean ffmpeg command not available within the environment path. Please try command with full path of ffmpeg like (c:\ffmpeg\ffmpeg.exe -i video.avi -ar 22050 -ab 32 -f flv -s 320×240 video.flv) or you can add ffmpeg path in environment path setting under windows.
Hope this help you.
Bala Krishna
March 12th, 2008 at 3:00 am
thanks for replay but
(
The system cannot find the path specified)
i searched the c:\
and i didn’t find any ffmpeg.exe
just i found the folder?
May 13th, 2008 at 9:43 pm
hi dear i am using this uber uploader on linux uploading is gone mysql daainseration we are doing i have seen all commands to convert files but i want t know that inwhich file of uberuploader we need to plance these files.
thanks
May 14th, 2008 at 1:57 am
Hi Sandeep,
Uber uploader only used to upload files on your server with progress bar. you need to write these command on file on which you are transferring control after upload finish. Usually, this file name and path defined in uber config file. look at uber config file in cgi-bin directory with .pbm extension.
Thanks
August 27th, 2008 at 11:26 pm
we have implemented this concept . but the problem retains in the clarity of the video … the original video which we have played in windows media player is 100% video size and it looks good…
after we have converted to flv and played it in flash player… it has been tampered…
we suspect the ffmpeg is capturing the video file with fullscreen mode of windows media player , because when we
played the original video with full screen mode in windows media player , the output of the video was blurred.
could you please tell me how to overcome this issue.
August 29th, 2008 at 6:00 pm
hello,
Iam converting the .mov fie to .flv file.
But the problem is, it can not be convert to flv .No output comes.
Just an empty page come.
I checked my php.ini.the FFMPEG must be enabled.
Iam using the following code for conversion.
function converttoflv( $in, $out )
{
$cmd = exec(“ffmpeg -i $in -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6 $out”);
}
Please I need the quick and Kind reply as soon as possible…
Thanks and regards
Manikandan.T
January 9th, 2009 at 11:42 pm
I am trying to convert vedio file to swf/flv using ffmpeg in asp.net but it is not generating any swf/flv and image file. Can you please help me. my code is below:
protected void btnsub_Click(object sender, EventArgs e)
{
if (FileUpload1 != null || FileUpload1.PostedFile != null)
{
postedfilename = FileUpload1.PostedFile.FileName;
SavePath = AppDomain.CurrentDomain.BaseDirectory + “Video\\”;
string NewFName = postedfilename;
NewFName = NewFName.Substring(NewFName.LastIndexOf(“\\”) + 1, NewFName.Length – NewFName.LastIndexOf(“.”)) +”.”+ NewFName.Substring(NewFName.LastIndexOf(“.”) + 1);
Filenamewithpath = SavePath + NewFName;
//Save The file
FileUpload1.PostedFile.SaveAs(Filenamewithpath);
//Start Converting
string inputfile, outputfile, filargs;
string withoutext;
//Get the file name without Extension
withoutext = Path.GetFileNameWithoutExtension(Filenamewithpath);
//Input file path of uploaded image
inputfile = SavePath + NewFName;
//output file format in swf
outputfile = SavePath + “SWF\\” + withoutext + “.swf”;
//file orguments for FFMEPG
filargs = “-i ” + inputfile + ” -ar 22050 ” + outputfile;
string spath;
spath = Server.MapPath(“.”);
Process proc;
proc = new Process();
proc.StartInfo.FileName = spath + “\\ffmpeg\\ffmpeg.exe”;
proc.StartInfo.Arguments = filargs;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.RedirectStandardOutput = false;
try
{
proc.Start();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
proc.WaitForExit();
proc.Close();
//Create Thumbs
string thumbpath, thumbname;
string thumbargs;
string thumbre;
thumbpath = AppDomain.CurrentDomain.BaseDirectory + “Video\\Thumb\\”;
thumbname = thumbpath + withoutext + “%d” + “.jpg”;
thumbargs = “-i ” + inputfile + ” -vframes 1 -ss 00:00:07 -s 150×150 ” + thumbname;
Process thumbproc = new Process();
thumbproc = new Process();
thumbproc.StartInfo.FileName = spath + “\\ffmpeg\\ffmpeg.exe”;
thumbproc.StartInfo.Arguments = thumbargs;
thumbproc.StartInfo.UseShellExecute = false;
thumbproc.StartInfo.CreateNoWindow = false;
thumbproc.StartInfo.RedirectStandardOutput = false;
try
{
thumbproc.Start();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
thumbproc.WaitForExit();
thumbproc.Close();
File.Delete(inputfile);
Savedetails();
lblmsg.Text = “Video Uploaded Successfully”;
hyp.Visible = true;
hyp.NavigateUrl = “Play.aspx”;
}
}
Regards
ww_anowar
February 3rd, 2009 at 10:14 am
Any hints for converting a directory of JPEG (*.jpg) to FLV?
February 9th, 2009 at 11:42 pm
I need to get the video in the same quality of input file after video conversion and the size of the converted file near or same to the input file.
Can anyone help me please?, I lost more time in this.
This is the code I used for conversion
exec(“../ffmpeg -i 1.mov -sameq -f flv -vcodec flv -b 400kb -s 614×400 -qmin 1 -qmax 31 -acodec libmp3lame -ar 22050 -ac 1 1.flv”);
After conversion quality of the video is ok, but the size of the flv file (1.flv) converted is large in size.
If I remove the -sameq from the above syntax , problem of huge size of converted flv file
(1.flv) will solve , then the quality of the video is poor.
March 3rd, 2009 at 11:06 pm
Hey
I am using the ffmpeg to convert the video from other format to flv. It is not working well it buffers too much in the player.some time it stop for some time. Please help me to set it
Thanks
Rohit
March 4th, 2009 at 6:27 am
Hi Rohit,
Thanks for you comments. There is nothing to do with ffmpeg in this regards. There are several reason to buffer video continuously. 1) slower web server response time. 2) Play with you video player setting.
FFMPEG only used to convert video from one format to another format and video encoding purpose. It does not play any role in video playing.
March 4th, 2009 at 10:06 pm
I want to make screenshot of a ‘.mov’ file on a regular time interval. for example if movies is 10 minute long then I want to make its 60 screenshots on every 10 second duration. Kindly help
March 9th, 2009 at 9:23 am
Hey
Any tell me how i can get good quality of video. I have used ffmpeg in iceagevideo.com. Picture is some pixled in this, it is not clear , Any one tell me how i can get the good quality of video
March 18th, 2009 at 11:09 pm
hello friends,
when I run the following command on linux comand prompt I get the flv file output but when I run this command using php’s exec or system function, then there is no output file in the specified directory.
> ffmpeg -i /var/www/html/Project/app/webroot/files/videos/20090319900790169Sample.avi -ar 22050 -ab 32 -f flv -s 320×240 /var/www/html/Project/app/webroot/files/videos/testyimvf.flv
Here is what I get when run command through linux command prompt..
——————————————————————————————————————————————————————————
[root@CentOS52 ~]# ffmpeg -i /var/www/html/Project/app/webroot/files/videos/20090319900790169Sample.avi -ar 22050 -ab 32 -f flv -s 320×240 /var/www/html/Project/app/webroot/files/videos/test.flv
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2006 Fabrice Bellard, et al.
configuration: –prefix=/usr –libdir=/usr/lib –mandir=/usr/share/man –incdir=/usr/include/ffmpeg –enable-mp3lame –enable-libogg –enable-vorbis –enable-faad –enable-faac –enable-libgsm –enable-xvid –enable-x264 –enable-a52 –enable-a52bin –enable-dts –enable-pp –enable-shared –enable-pthreads –enable -gpl –disable-strip
libavutil version: 49.1.0
libavcodec version: 51.28.0
libavformat version: 51.7.0
built on Mar 29 2007 01:44:55, gcc: 4.1.1 20070105 (Red Hat 4.1.1-52)
Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (30000/1) -> 25.00 (25/1)
Input #0, avi, from ‘/var/www/html/Project/app/webroot/files/videos/20090319900790169Sample.avi’:
Duration: 00:00:46.5, start: 0.000000, bitrate: 902 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 608×272, 25.00 fps(r)
Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s
Output #0, flv, to ‘/var/www/html/Project/app/webroot/files/videos/test.flv’:
Stream #0.0: Video: flv, yuv420p, 320×240, q=2-31, 200 kb/s, 25.00 fps(c)
Stream #0.1: Audio: mp3, 22050 Hz, stereo, 32 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
mdb:487, lastbuf:0 skiping granule 0
mdb:487, lastbuf:0 skiping granule 0
mdb:487, lastbuf:0 skiping granule 1
mdb:487, lastbuf:0 skiping granule 1
mdb:481, lastbuf:348 skiping granule 0
mdb:481, lastbuf:348 skiping granule 0
[mp3 @ 0x5ff2184]lame: output buffer too small (buffer index: 1986, free bytes:318)
frame= 1163 q=19.4 Lsize= 1597kB time=46.5 bitrate= 281.2kbits/s
video:1369kB audio:182kB global headers:0kB muxing overhead 2.983522%
—————————————————————————————————————————————————————————————
Does anyone knows why I am not getting the output file when I run the same command through Php’s exec() function. I do get “success” as a return value through this function but no output file.
Thank you in advance
April 7th, 2009 at 3:14 am
Thank you so much….Its grt!!! Helped me a lot!!!!
May 3rd, 2009 at 8:36 am
Very good article and discussion. Sounds like a lot of people are being helped. I am not a video expert. There seem to be some questions about the command line – thought should offer a small thought. I use biterscripting (http://www.biterscripting.com/install.html for free install) for command line execution of anything these days.
If I were to use Bala Krishna’s original command (ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320×240 video.flv), and call in in batch, I would use the following script.
# Collect a list of .avi files.
var str l ; lf -rn “*.avi” “some folder” > $l
while ($l “”)
do
var str i ; lex “1″ $l > $i
# $i is input file. Create the corresponding .flv output file name.
var str o ; sal -p “^.avi^l” “.flv” $i > $o
# Input file is $i, output file is $o. Call ffmpeg.
system ffmpeg ” -i ” (“\”"+$i+”\”") -ar 22050 -ab 32 -f flv -s 320×240 (“\”"+$o+”\”")
done
Richard
June 12th, 2009 at 7:07 pm
Hello Bala,
Very helpful article.
I have incorporate it and .flv file is creadted in a server but the size is 0 KB.
exec($ffmpegPath . ” -i ” . $srcFile . ” -ar ” . $srcAR . ” -ab ” . $srcAB . ” -f flv -s ” . $srcWidth . “x” . $srcHeight . ” ” . $destFile . ” | ” . $flvtool2Path . ” -U stdin ” . $destFile);
exec($ffmpegPath . ” -i ” . $srcFile . ” -ar ” . $srcAR . ” -ab ” . $srcAB . ” -f flv -s ” . $srcWidth . “x” . $srcHeight . ” ” . $destFile );
Can you tell me why the creating .flv file size is 0KB.
It s a urgent.
Thanks,
Ujjwal,
Kolkata, India
June 14th, 2009 at 9:38 pm
I used “ffmpeg -i video.wmv -ar 22050 -ab 32 -f flv -s 320×240 video.flv” command to convert but I got this error message.
FFmpeg version SVN-r15815, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: –enable-memalign-hack –enable-postproc –enable-swscale –enable-gpl –enable-libfaac –enable-libfaad –enable-libgs
enable-libvorbis –enable-libtheora –enable-libx264 –enable-libxvid –disable-ffserver –disable-vhook –enable-avisynth –enable-pthr
libavutil 49.12. 0 / 49.12. 0
libavcodec 52. 3. 0 / 52. 3. 0
libavformat 52.23. 1 / 52.23. 1
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 6. 1 / 0. 6. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Nov 13 2008 10:28:29, gcc: 4.2.4 (TDM-1 for MinGW)
Seems stream 2 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
Input #0, asf, from ‘video.wmv’:
Duration: 00:33:34.18, start: 3.417000, bitrate: 108 kb/s
Stream #0.0: Audio: 0x000a, 16000 Hz, mono, s16, 12 kb/s
Stream #0.1: Video: wmv3, yuv420p, 240×180, 17 kb/s, 1000.00 tb(r)
Stream #0.2: Video: wmv3, yuv420p, 240×180, 81 kb/s, 25.00 tb(r)
Stream #0.3: Data: 0×0000, 8 kb/s
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, flv, to ‘video.flv’:
Stream #0.0: Video: flv, yuv420p, 320×240, q=2-31, 200 kb/s, 25.00 tb(c)
Stream #0.1: Audio: libmp3lame, 22050 Hz, mono, s16, 0 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Stream #0.0 -> #0.1
Unsupported codec (id=86055) for input stream #0.0
Please help me.
July 21st, 2009 at 1:36 am
Hi Bala,
I have one flv file and I want to convert it to mp3. I tried it with ffmpeg and it shows segmentation fault. Then I tried another flv file which I downloaded from youtube. It worked fine and I got the correct mp3. The first flv file is one which I created by Flash Media Server. I wrote one AS program for recording sound from Microphone. That way, I got the flv file and I need to convert it to mp3. Can u plz help me in this matter?
August 3rd, 2009 at 7:09 am
hi,
Is it possible to convert swf to flv or avi using ffmpeg if so could u please tell me how..!!??
Thanks in advance,
Venkat.
August 4th, 2009 at 12:09 pm
Hi,
Is it possible to convert swf to flv using ffmpeg..
if so could you please tell me how
for me it is saying that the swf i am trying to convert is unsupported compressed format…
Please help
thanks in advance,
venkat
August 24th, 2009 at 7:54 am
Goo dpost. Well done mate. Spot on!!!!
Keep up the good work!!
September 8th, 2009 at 10:25 am
Hi
I need to convert swf in to flv and then make thumbnail of the same….we have managed to convert other formats into FLV but we need swf also to be converted…
September 23rd, 2009 at 12:47 am
How can I convert a VNC session to swf file.?? Any clues.?
November 6th, 2009 at 12:52 am
Hi
When am running this command
ffmpeg -i sample.avi -ar 22050 -ab 32 -f flv -s 320×240 | /usr/local/src/flvtool2 -Ustdout videosample.flv
am getting thi errors
bash: /usr/local/src/flvtool2: No such file or directory
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration:
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
built on Apr 3 2009 16:20:21, gcc: 4.1.2 20071124 (Red Hat 4.1.2-42)
Input #0, avi, from ‘sample.avi’:
Duration: 00:02:00.52, start: 0.000000, bitrate: 1283 kb/s
Stream #0.0: Video: msmpeg4, yuv420p, 384×288, 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 320 kb/s
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
At least one output file must be specified
please help me in resolving this error. thanks in advance !!
November 29th, 2009 at 10:43 pm
My friends often ask me the questions:which video converter should I choice?which video converter is best?when I listen to the questions,I don’t know how to answer them.But friends, I can give you some advice if you need convert video.
December 2nd, 2009 at 5:37 am
Hi,
Here is my code
&1″,$a);
if ($targetFile!=”")
echo $targetFile;
else // Required to trigger onComplete function on Mac OSX
echo ’1′;
}
?>
If i creating FLV format File size is 0 kb. If any body knows help me please.
December 2nd, 2009 at 5:38 am
Here is my code
$ffmpegObj = new ffmpeg_movie($targetFile);
$audiofrequency =makeMultipleTwo(22050);
$audiobitrate = makeMultipleTwo(32000);
$videobitrate = makeMultipleTwo(104857200);
$encodesize = makeMultipleTwo(480,360);
$flvtool2Path=”/usr/bin/flvtool2″;
exec(“ffmpeg -i “. $targetFile.” -ar “.$audiofrequency.” -ab “.$audiobitrate.” -b “.$videobitrate.” -f flv -y -s “.$encodesize.” “. $destFile . ” | ” . $flvtool2Path . ” -U stdin ” .$destFile.” 2>&1″,$a);
Flv format size is 0 kb. pls help me
January 25th, 2010 at 2:19 am
Hi,
Here is my code
exec(“C:/wamp/www/newtip/ffmpeg/ffmpeg -i C:/wamp/www/newtip/ffmpeg/videos/”.$name.” -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 320×240 C:/wamp/www/newtip/ffmpeg/images/”.$name_s.”%d.jpg”);
exec(“C:/wamp/www/newtip/ffmpeg/ffmpeg -i C:/wamp/www/newtip/ffmpeg/videos/”.$name.” -ar 22050 -ab 32 -f flv -s 320×240 C:/wamp/www/newtip/ffmpeg/players/”.$name_s.”.flv”);
It is working on local system but it is not working in server.
Can anybody tell why it is not working in server(remote system)?
help me….
January 25th, 2010 at 7:33 am
you should have permission to execute “exec” command on your server. Normally, this is normally disabled on hosting server.
January 27th, 2010 at 12:05 am
file size more than 1mb are not converting to flv.I have each of my php configuration setting correct as i can uplaod videos more than 2mb in size…plz help..
January 28th, 2010 at 12:32 am
u may chk the runtime path .may b ur runtime can not get the bat file.put the file in the server’s runtime path.like if u r working on apache tomcat ,then put it into tomcat/bin
April 29th, 2010 at 8:17 pm
I tried grabbing the RSS Feed to your website and for some reason it ain’t properly displaying in Google Chrome. Any suggestions?
April 29th, 2010 at 8:49 pm
Google chrome don’t have inbuilt rss feed viewer this is the reason you see rss feed in raw format. All feeds will looks same in chrome. Try to use in IE, FF or Opera for better viewing.
June 8th, 2010 at 5:22 am
to work flvtool2 you first need to convert any video to flv and then you can use flvtool2 on above created flv file.
command for flvtoo2 is
exec($flvtool2path -U $flvfilepath);
this command overwrite the flv file and add metadata.
June 15th, 2010 at 4:57 pm
hi bala i have just install ffmpeg on easyphp in windows enviornment and am able to convert the file as well using php. The thing is when conversion start it displays cmd window for short while but i dont want to cmd window to be displayed. First question is this normal that cmd window popup if not any solution or idea ? waiting for your reply
Thanks
June 26th, 2010 at 5:21 am
Hi, i want to convert first 15 sec of a video into different formats by using ffmpeg. complete video conversion is working fine.
help me help me helpme