<?xml version="1.0" encoding="UTF-8"?>
<snippet>
  <account-id type="integer">2</account-id>
  <body>This is a short tutorial on how to quickly get up to speed with FLV movie creation (transcoding) and viewing (Flash player).

I tried to install ffmpeg using ports and fink, but had problems. The instructions I found &quot;here&quot;:http://www.macosxhints.com/article.php?story=20061220082125312 work though. 

The following is my adaptation of the instruction, where I show you how to install both ffmpeg and flvtool2.

First, download ffmpegx, which contains ffmpeg from &quot;http://ffmpegx.com/download.html&quot;:http://ffmpegx.com/download.html

Then, mount the .dmg file, navigate to the mounted disk, and control-click on the ffmpegX application (ffmpegX.app), choose Show Package Contents from the pop-up menu, and copy the ffmpeg binary to, for example, /tmp.

Now execute the following commands in a terminal shell:
&lt;code&gt;
# Move ffmpeg to /usr/local/bin:
sudo mv /tmp/ffmpeg /usr/local/bin/

# Change owner and make executable
sudo chown root:wheel /usr/local/bin/ffmpeg
sudo chmod 755 /usr/local/bin/ffmpeg
&lt;/code&gt;

You're now ready to use ffmpeg; the following command lists all the supported input and output formats:

&lt;code&gt;
ffmpeg -formats
&lt;/code&gt;

Use the following command to transcode an AVI to FLV (Flash video) format:
&lt;code&gt;
fmpeg -i mymovie.avi -s 320x240 -ar 44100 -r 12 mymovie.flv
cat mymovie.flv | flvtool2 -U stdin mymovie.flv
&lt;/code&gt;

To add metadata to the FLV file&amp;mdash;such as video length, which is required for the Flash player progress bar&amp;mdash;you need to install &quot;flvtool2&quot;:http://rubyforge.org/projects/flvtool2/.

This is done with the following command (note this requires Ruby and RubyGems, which are not part of all OSX Leopard installations):
&lt;code&gt;
sudo gem install flvtool2
&lt;/code&gt;

Now add the metadata to the FLV file:
&lt;code&gt;
flvtool2 -UP mymovie.flv
&lt;/code&gt;

To test the FLV movie you just created, download and extract &quot;FlowPlayer&quot;:http://flowplayer.org  to your folder of choice. Now create a page that loads your FLV movie; note that you need to update the paths:
&lt;code&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;../flowplayer/html/swfobject.js&quot;&gt;&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;div id=&quot;flowplayerholder&quot;&gt;
		This will be replaced by the player. 
	&lt;/div&gt;
	
&lt;script type=&quot;text/javascript&quot;&gt;
// &lt;![CDATA[
var fo = new SWFObject(&quot;../flowplayer/FlowPlayerDark.swf&quot;, &quot;FlowPlayer&quot;, &quot;468&quot;, &quot;350&quot;, &quot;7&quot;, &quot;#000000&quot;, true);
	// need this next line for local testing, it's optional if your swf is on the same domain as your html page
	fo.addParam(&quot;allowScriptAccess&quot;, &quot;always&quot;);
	fo.addVariable(&quot;config&quot;, &quot;{ countryCode: 'fi', playList: [ {overlayId: 'play' }, { url: '/mockup/mymovie.flv' } ], initialScale: 'scale',  fullScreenScriptURL: 'fullscreen.js' }&quot;);
	fo.write(&quot;flowplayerholder&quot;);
// ]]&gt;
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;/code&gt;

I've &quot;been told&quot;:http://www.macosxhints.com/article.php?story=20060923203722112&amp;query=dec that &quot;mencoder&quot;:http://www2.mplayerhq.hu/MPlayer/releases/ produces higher quality FLV videos, so lets compare the mencoder output to ffmpeg by first downloading and extracting mencoder to /tmp.

Now move mencoder to /usr/local/bin:

&lt;code&gt;
sudo mv /tmp/mencoder /usr/local/bin/

sudo chown root:wheel /usr/local/bin/mencoder
sudo chmod 755 /usr/local/bin/mencoder
&lt;/code&gt;

Next transcode the video to FLV format using mencoder:
&lt;code&gt;
mencoder mymovie.avi -ofps 12 -o mymovie.flv -of lavf -lavfopts \
i_certify_that_my_video_stream_does_not_use_b_frames -oac lavc -lavcopts \
acodec=mp3:abitrate=32 -srate 22050  -ovc lavc -lavcopts vcodec=flv:\
vbitrate=100:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:\
vmax_b_frames=0:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:qns=2 \
-vop scale=360:240
&lt;/code&gt;

View the video in the Flash player; you should notice the difference in quality...

For even higher quality encode the videos using the H.264 format, which FlowPlayer also supports; instructions can be found &quot;here&quot;:http://www.brad-x.com/2007/05/19/yet-another-linuxnix-video-h264-howto/.</body>
  <comments-count type="integer">0</comments-count>
  <created-at type="datetime">2008-02-06T22:18:11+02:00</created-at>
  <id type="integer">132</id>
  <language-id type="integer">131</language-id>
  <rendered-body>&lt;p&gt;This is a short tutorial on how to quickly get up to speed with  FLV  movie creation (transcoding) and viewing (Flash player).&lt;/p&gt;


	&lt;p&gt;I tried to install ffmpeg using ports and fink, but had problems. The instructions I found &lt;a href=&quot;http://www.macosxhints.com/article.php?story=20061220082125312&quot;&gt;here&lt;/a&gt; work though.&lt;/p&gt;


	&lt;p&gt;The following is my adaptation of the instruction, where I show you how to install both ffmpeg and flvtool2.&lt;/p&gt;


	&lt;p&gt;First, download ffmpegx, which contains ffmpeg from &lt;a href=&quot;http://ffmpegx.com/download.html&quot;&gt;http://ffmpegx.com/download.html&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Then, mount the .dmg file, navigate to the mounted disk, and control-click on the ffmpegX application (ffmpegX.app), choose Show Package Contents from the pop-up menu, and copy the ffmpeg binary to, for example, /tmp.&lt;/p&gt;


	&lt;p&gt;Now execute the following commands in a terminal shell:
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; Move ffmpeg to /usr/local/bin:&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; sudo mv /tmp/ffmpeg /usr/local/bin/
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; Change owner and make executable&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   5 &lt;/span&gt; sudo chown root:wheel /usr/local/bin/ffmpeg
&lt;span class=&quot;line-numbers&quot;&gt;   6 &lt;/span&gt; sudo chmod 755 /usr/local/bin/ffmpeg
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;You&amp;#8217;re now ready to use ffmpeg; the following command lists all the supported input and output formats:&lt;/p&gt;


	&lt;p&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; ffmpeg -formats
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Use the following command to transcode an  AVI  to  FLV  (Flash video) format:
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; fmpeg -i mymovie.avi -s 320x240 -ar 44100 -r 12 mymovie.flv
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; cat mymovie.flv &lt;span class=&quot;Operator&quot;&gt;|&lt;/span&gt; flvtool2 -U stdin mymovie.flv
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;To add metadata to the  FLV  file&amp;mdash;such as video length, which is required for the Flash player progress bar&amp;mdash;you need to install &lt;a href=&quot;http://rubyforge.org/projects/flvtool2/&quot;&gt;flvtool2&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This is done with the following command (note this requires Ruby and RubyGems, which are not part of all  OSX  Leopard installations):
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; sudo gem install flvtool2
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Now add the metadata to the  FLV  file:
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; flvtool2 -UP mymovie.flv
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;To test the  FLV  movie you just created, download and extract &lt;a href=&quot;http://flowplayer.org&quot;&gt;FlowPlayer&lt;/a&gt;  to your folder of choice. Now create a page that loads your  FLV  movie; note that you need to update the paths:
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; 	&lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; 		&lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;script type=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;text/javascript&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;../flowplayer/html/swfobject.js&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;/script&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; 	&lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;/head&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   5 &lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   6 &lt;/span&gt; 	&lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;div id=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;flowplayerholder&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   7 &lt;/span&gt; 		This will be replaced by the player. 
&lt;span class=&quot;line-numbers&quot;&gt;   8 &lt;/span&gt; 	&lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;/div&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;   9 &lt;/span&gt; 	
&lt;span class=&quot;line-numbers&quot;&gt;  10 &lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;script type=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;text/javascript&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Operator&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  11 &lt;/span&gt; // &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Operator&quot;&gt;!&lt;/span&gt;[CDATA[
&lt;span class=&quot;line-numbers&quot;&gt;  12 &lt;/span&gt; var fo = new SWFObject(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;../flowplayer/FlowPlayerDark.swf&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;FlowPlayer&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;468&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;350&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;7&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;#000000&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, true)&lt;span class=&quot;Operator&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  13 &lt;/span&gt; 	// need this next line &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; local testing, it&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;s optional if your swf is on the same domain as your html page&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  14 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;	fo.addParam(&amp;quot;allowScriptAccess&amp;quot;, &amp;quot;always&amp;quot;);&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  15 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;	fo.addVariable(&amp;quot;config&amp;quot;, &amp;quot;{ countryCode: &lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;fi&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;, playList: [ {overlayId: &lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;play&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt; }, { url: &lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;/mockup/mymovie.flv&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt; } ], initialScale: &lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;scale&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;,  fullScreenScriptURL: &lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;fullscreen.js&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt; }&amp;quot;);&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  16 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;	fo.write(&amp;quot;flowplayerholder&amp;quot;);&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  17 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;// ]]&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  18 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  19 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;line-numbers&quot;&gt;  20 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve &lt;a href=&quot;http://www.macosxhints.com/article.php?story=20060923203722112&amp;#38;query=dec&quot;&gt;been told&lt;/a&gt; that &lt;a href=&quot;http://www2.mplayerhq.hu/MPlayer/releases/&quot;&gt;mencoder&lt;/a&gt; produces higher quality  FLV  videos, so lets compare the mencoder output to ffmpeg by first downloading and extracting mencoder to /tmp.&lt;/p&gt;


	&lt;p&gt;Now move mencoder to /usr/local/bin:&lt;/p&gt;


	&lt;p&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; sudo mv /tmp/mencoder /usr/local/bin/
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; 
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; sudo chown root:wheel /usr/local/bin/mencoder
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; sudo chmod 755 /usr/local/bin/mencoder
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Next transcode the video to  FLV  format using mencoder:
&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; mencoder mymovie.avi -ofps 12 -o mymovie.flv -of lavf -lavfopts \
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; i_certify_that_my_video_stream_does_not_use_b_frames -oac lavc -lavcopts \
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; acodec=mp3:abitrate=32 -srate 22050  -ovc lavc -lavcopts vcodec=flv:\
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; vbitrate=100:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:\
&lt;span class=&quot;line-numbers&quot;&gt;   5 &lt;/span&gt; vmax_b_frames=0:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:qns=2 \
&lt;span class=&quot;line-numbers&quot;&gt;   6 &lt;/span&gt; -vop scale=360:240
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;View the video in the Flash player; you should notice the difference in quality&amp;#8230;&lt;/p&gt;


	&lt;p&gt;For even higher quality encode the videos using the H.264 format, which FlowPlayer also supports; instructions can be found &lt;a href=&quot;http://www.brad-x.com/2007/05/19/yet-another-linuxnix-video-h264-howto/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</rendered-body>
  <title>How to install ffmpeg, mencoder and flvtool2 on Mac OSX Leopard, convert an AVI to FLV, and view the FLV video with FlowPlayer</title>
  <updated-at type="datetime">2008-07-08T22:02:24+03:00</updated-at>
</snippet>
