tag:blogger.com,1999:blog-22466154767626162932023-11-15T05:46:41.304-08:00FFMPEG CommandsOne of the best command line video conversion tool.jaferihttp://www.blogger.com/profile/04602834776567397401noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-2246615476762616293.post-68563058095148171742008-10-09T20:57:00.000-07:002008-10-09T20:57:09.981-07:00FFMPEG Commands: FFMPEG useful commands<a href="http://ffmpeg-commands.blogspot.com/2008/06/ffmpeg-useful-commands.html#links">FFMPEG Commands: FFMPEG useful commands</a>jaferihttp://www.blogger.com/profile/04602834776567397401noreply@blogger.com1tag:blogger.com,1999:blog-2246615476762616293.post-26636758692227352082008-06-27T03:32:00.000-07:002009-07-28T08:55:07.039-07:00FFMPEG useful commands<!-- Include the Google Friend Connect javascript library. --><br /><script type="text/javascript" src="http://www.google.com/friendconnect/script/friendconnect.js"></script><br /><!-- Define the div tag where the gadget will be inserted. --><br /><div id="div-4464258488353644512"></div><br /><!-- Render the gadget into a div. --><br /><script type="text/javascript"><br />var skin = {};<br />skin['BORDER_COLOR'] = '#cccccc';<br />skin['ENDCAP_BG_COLOR'] = '#e0ecff';<br />skin['ENDCAP_TEXT_COLOR'] = '#333333';<br />skin['ENDCAP_LINK_COLOR'] = '#0000cc';<br />skin['ALTERNATE_BG_COLOR'] = '#ffffff';<br />skin['CONTENT_BG_COLOR'] = '#ffffff';<br />skin['CONTENT_LINK_COLOR'] = '#0000cc';<br />skin['CONTENT_TEXT_COLOR'] = '#333333';<br />skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';<br />skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';<br />skin['CONTENT_HEADLINE_COLOR'] = '#333333';<br />skin['POSITION'] = 'top';<br />skin['DEFAULT_COMMENT_TEXT'] = '- add your comment here -';<br />skin['HEADER_TEXT'] = 'Comments';<br />google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */);<br />google.friendconnect.container.renderSocialBar(<br /> { id: 'div-4464258488353644512',<br /> site: '18245000900326247366',<br /> 'view-params':{"scope":"SITE","features":"video,comment","showWall":"true"}<br /> },<br /> skin);<br /></script><br /><br /><span style="color: rgb(51, 102, 102);font-size:180%;" ><span style="font-weight: bold;">F</span></span><span style="color: rgb(51, 102, 102);">FMPEG</span> is a very power full tool for video manipulation. Mostly developers use the different command to convert video from one format to another e.g ( avi to flv ) . Mostly developers search different type of command via search engines e.g google.com . Exert of FFMPEG use the different parameters for different scenarios. The purpose of this blog to write down common command that will be very useful while developing video sites.<br /><br /><span style="font-weight: bold; color: rgb(51, 102, 255);">1- Live Stream Conversion</span><br /><br /><span style="font-weight: bold;"><span style="font-size:85%;">In Window</span><br /><br /></span><span style="font-size:85%;"><span style="color: rgb(153, 51, 153);">ffmpeg.exe -i http://serveraddress/streamvideo.asf -target ntsc-dvd -aspect 1.3333 -s 176x108 yourvideo.flv</span></span><br /><br /><span style="font-size:85%;"><span style="font-weight: bold;">In Linux</span></span><br /><br /><span style="color: rgb(153, 51, 153);font-size:85%;" >exec('/user/bin/ffmpeg -i http://serveraddress/streamvideo.asf -target ntsc-dvd -aspect 1.3333 -s 176x108 yourvideo.flv');<br /><br /><span style="color: rgb(51, 102, 255);font-size:100%;" ><span style="font-weight: bold;">2- Creat Movie from Images<br /><br /></span></span></span><span style="color: rgb(153, 0, 0); font-weight: bold;">Note:</span><span style="font-weight: bold;"> </span>Your folder contain images with discrete unique name e.g image1, image2, image3.....<br /><span style="font-weight: bold;"><span style="font-size:85%;">In Window</span><br /><br /></span><span style="color: rgb(153, 51, 153);font-size:85%;" >ffmpeg.exe -r 2 -i images/image%d.jpg -ar 22050 -s 320x240 -aspect 4:3 -f flv ' yourflvname.flv<br /></span><br /><span style="font-size:85%;"><span style="font-weight: bold;">In Linux</span></span><br /><br /><span style="color: rgb(153, 51, 153);font-size:85%;" >exec('/usr/local/bin/ffmpeg -r 2 -i images/image%d.jpg -ar 22050 -s 320x240 -aspect 4:3 -yourflvname. flv '.$movie_Store_Path,$output,$return);<br /></span><span style="color: rgb(153, 51, 153);font-size:85%;" ><br /><span style="color: rgb(51, 102, 255);font-size:100%;" ><span style="font-weight: bold;">3- Get the single Frame of Specific movie Time</span></span><br /><br />$curFrameTime = "00:00:05";<br />exec('/usr/local/bin/ffmpeg -i yourfile.flv -an -ss '.$curFrameTime.' -an -r 1 -vframes 1 images/img%d.jpg');<br /><br /><span style="color: rgb(51, 102, 255); font-weight: bold;">4- Get multiple frames from movie</span><br />exec('/usr/local/bin/ffmpeg -i ./yourfile.wmv -an -ss 00:00:01 -t 00:01:31 -r 10 -s 550x450 -aspect 5:3 ./img/%d.png',$output,$result);<br /><br /><span style="font-size:100%;"><span style="color: rgb(51, 102, 255); font-weight: bold;">4- Avi to flv Conversion<br /><br /></span></span>exec('/usr/local/bin/ffmpeg -i ./youravifile.avi -pass 2 -s 448x336 -ab 56k -ar 22050 -ac 1 -vcodec flv -b 500k -g 160 -cmp 3 -subcmp 3 -mbd 2 -flags aic+cbp+mv0+mv4+trell -y yourfilename.flv',$output,$result);<br /><br /></span><span style="font-weight: bold; color: rgb(51, 102, 255);">5-Remove the Audio Stream</span><p> Let's say you have recorded a video that has a lot of background noise and undesired commentary, so you decide to remove the audio component of the video completely. To accomplish this, all you have to do is add the -an option to the command line, and FFmpeg automatically removes all audio from the output. Keep in mind that using this option negates any other option that affects the audio stream. </p><p> So, in our example, to remove the audio component, we would run the following command: </p><pre class="programlisting"><span style="color: rgb(153, 51, 153);font-size:100%;" >exec('/usr/local/bin/ffmpeg</span><span style="color: rgb(153, 51, 153);"><span style="font-size:100%;"> </span>-i InputFile.mpg -an -b 1200 OutputFile.avi');<br /><br /></span><span style="font-size:100%;"><br /><span style="color: rgb(0, 0, 0); font-weight: bold;"></span></span><span style="font-weight: bold; color: rgb(0, 0, 0);font-family:georgia;font-size:130%;" >5-Remove the Video Stream</span><br /></pre><p> Let's say you downloaded a news video from the Net that you want to listen to on your iPod on the way to work, but in order to do that, you have to remove the video component from the output file. FFmpeg allows you to remove the video component of the file completely by adding the -vn option to the command line. Using this option negates any other option that affects the video stream. </p><p> So, in our example, to remove the video component and save the audio as a 256kbps MP3 file, we would run the following command: </p><span style="color: rgb(153, 51, 153);font-size:100%;" >exec('/usr/local/bin/</span><span style="color: rgb(153, 51, 153);"><span style="font-size:85%;">ffmpeg -i InputFile.mpg -vn -ab 256 OutputFile.mp3</span>');</span><br /><br /><h5>6-Extracting sound from a video, and save it as Mp3<br /><span style="font-weight: normal;"> This is very easy command to extract audio from video file .</span><br /><br /><span style="color: rgb(153, 51, 0); font-weight: normal;"> ffmpeg -i inputVideo.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 outputFile.mp3</span></h5><br />Mencoder:<br /><br /><span style="font-weight: bold;">7.Combine two flv using mencoder</span><br />A very simple command to combine two flv.<br />mencoder.exe -<span class="hilite">fps</span> 29.97 1.<span class="hilite">flv</span> -fps 29.97 2.flv -o combine.flv -of lavf -ovc copy -oac copy<br /><br /><span style="font-weight: bold;">8-Remove the video from file.</span><br /><pre class="programlisting">In order to remove video from file; ffmpeg allow to remove video component completely by<br />adding -vn in command line.<br /><br />ffmpeg -i InputFile.mpg -vn -ab 256 OutputFile.mp3</pre><br /><br /><span style="font-weight: bold;">9- How to get Movie Time using FFMPEG</span><br /><br />Following is very useful PHP function to get the movie duration.<br /><br /><br />function duration($videofile)<br />{<br />ob_start();<br />passthru("ffmpeg.exe -i \"". $videofile . "\" 2>&1");<br />$duration = ob_get_contents();<br />ob_end_clean();<br />preg_match('/Duration: (.*?),/', $duration, $matches);<br />$duration = $matches[1];<br />return($duration);<br />}<br /><br /><span style="color: rgb(255, 102, 102);"><span style="font-weight: bold;">Note:</span> If you have recorded file using flash media server or RED5; then you have to again convert file ( flv to flv ) using FFMPEG. </span><br /><br /><br /><span style="font-weight: bold;">Note:</span> If some one need window version of FFMPEG and MENCODER, just to mail me .<br /><span>smile110 (at) gmail (dot) com</span><br /><br /><a href='http://www.kidzcartoons.com' title='kids cartoons'>kids cartoons</a><br /><br><br /><a href='http://www.paksnaps.com' title='Visit Pakistan'>Visit Pakistan</a><br /><br /><br /><script type='text/javascript' src='http://www.aboutus.org/KidzCartoons.com?format=widget'></script>jaferihttp://www.blogger.com/profile/04602834776567397401noreply@blogger.com7