<p>What is the best way to transcode audio and video to show on the web?  </p>

<p>I need to do it programmatically.  I'd like to do something like YouTube or Google Video where users can upload whatever format they want, and I encode it to flv, mp3, and/or mp4.  I could do it on our server, but I would rather use an EC2 instance or even a web service.  We have a Windows 2008 server.</p>

[{'answer_id': 6969, 'author': 'JimDaniel', 'author_id': 63, 'author_profile': 'https://Stackoverflow.com/users/63', 'pm_score': 2, 'selected': False, 'text': "<p>ffmpeg can do it, its a command-line tool that uses the libavcodec. Can handle conversion of most video formats. Its license is LPGL, if that suits your needs. You can utilize it as a separate process programmatically, or if you're feeling hardcore, you can use the libavcodec library yourself to encode directly.</p>\n"}, {'answer_id': 7184, 'author': 'denis phillips', 'author_id': 748, 'author_profile': 'https://Stackoverflow.com/users/748', 'pm_score': 1, 'selected': False, 'text': "<p>Do be aware that certain parts of ffmpeg are under GPL. I believe the libpostproc module is and if I recall correctly this is used in transcoding. Make sure this license is compatible with what you're doing.</p>\n"}, {'answer_id': 7186, 'author': 'masc', 'author_id': 919, 'author_profile': 'https://Stackoverflow.com/users/919', 'pm_score': 2, 'selected': False, 'text': '<p>When you want to transcode to Flv (which is probably the best for the web) then I use this line:</p>\n\n<pre><code>ffmpeg -hq -y -i $directory/$file -r 20 -s 300x200 -deinterlace -ar 22050 $directory/$file.flv 1&gt;/dev/null 2&gt;/dev/null\n</code></pre>\n\n<p>It works very well, under linux of course :-).</p>\n'}, {'answer_id': 30446, 'author': 'Nick Haddad', 'author_id': 2813, 'author_profile': 'https://Stackoverflow.com/users/2813', 'pm_score': 1, 'selected': False, 'text': '<p>I would take a look at Main Concept\'s Reference SDK:</p>\n\n<p><a href="http://www.mainconcept.com/site/developer-products-6/pc-based-sdks-20974/reference-sdk-21221/information-21243.html" rel="nofollow noreferrer">http://www.mainconcept.com/site/developer-products-6/pc-based-sdks-20974/reference-sdk-21221/information-21243.html</a></p>\n\n<p>It is built for transcoding and, since it is a licensed SDK it doesn\'t have any of the legal issues surrounding ffmpeg/libavcodec. </p>\n'}, {'answer_id': 430518, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>kind of depends on how much you want to spend.  if this is a brand new (and mostly unfunded) idea, then go the ffmpeg route, but as you scale and look to iprove the quality, consider one of the more professional encoding tools that can be automated (Rhozet, Inlet, Digital Rapids are 3 options).</p>\n'}, {'answer_id': 430594, 'author': 'Mr.Ree', 'author_id': 37946, 'author_profile': 'https://Stackoverflow.com/users/37946', 'pm_score': 2, 'selected': False, 'text': '<p>If you are looking for GPL\'ed stuff:</p>\n\n<p>For audio mucking about, try <a href="http://sox.sourceforge.net/" rel="nofollow noreferrer">sox.</a>  Very powerful!  It does a lot!   It\'s included in most linux distributions.</p>\n\n<p>There is also the famous <a href="http://lame.sourceforge.net/" rel="nofollow noreferrer">LAME</a> for mp3 [audio] encoding.</p>\n\n<p>For video, <a href="http://www.mplayerhq.hu" rel="nofollow noreferrer">mencoder</a> is impressive!  It\'s part of the <a href="http://www.mplayerhq.hu" rel="nofollow noreferrer">mplayer</a> package.  It will handle conversions from most video formats.  Far more than I ever dreamed existed.  (For documentation, see <a href="http://www.mplayerhq.hu/DOCS/HTML/en/mencoder.html" rel="nofollow noreferrer">Chapter 9. Basic usage of MEncoder</a> and <a href="http://www.mplayerhq.hu/DOCS/HTML/en/encoding-guide.html" rel="nofollow noreferrer">Chapter 10. Encoding with MEncoder</a>.)</p>\n\n<p>It\'s somewhat more limited about what it can create.  But it does support <em>mpeg4</em>, <em>mpeg2</em>, <em>dvd-mpeg</em>, <em>flv</em>, and many others.  (While I haven\'t tried <em>flv</em> myself, google shows other folks are using it.)</p>\n\n<p>I have done things like jpeg + sound -> mpeg4 movie:</p>\n\n<pre><code>nice +20 $MENCODER mf://${JPEGFILE}  -mf w=720:h=480:fps=1/${SOUNDLENGTH}:type=jpeg -audiofile ${SOUNDFILE} -ovc lavc -oac lavc -lavcopts vcodec=mpeg4 -ofps 30000/1001 -o ${MENU_MPG}\n</code></pre>\n\n<p>Or transcode arbitrarily formated video to dvd-compatible mpeg:</p>\n\n<pre><code>nice +20 $MENCODER -edl ${EDL} -ovc lavc -oac lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=${VBITRATE}:keyint=18:acodec=ac3:abitrate=192:aspect=4/3:trell:mbd=2:dia=4:cmp=3:precmp=3:ildctcmp=3:subcmp=3:mbcmp=3:cbp:mv0:dc=10 -of mpeg -mpegopts format=dvd -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 -ofps 30000/1001 -o ./${INFILE}.reformatted  ${FILEPATH}\n</code></pre>\n\n<p>-edl/-edlout [Edit Decision Lists] are used to snip out just the video sections I want.</p>\n\n<p>${VBITRATE} is normally 5000 for DVD-mpeg-video.  But if you flub it a bit you can squeeze more video onto a dvd.  Assuming you can tolerate the artifacts.</p>\n\n<p>scale=720:480,harddup -- Little issue with the scale being wrong for my dvdplayer, and harddup to resolve a sound-video desync issue on my <em>"el cheapo"</em> player.</p>\n\n<p>(To playback on a widescreen player that wouldn\'t handle 4x3 video, I\'ve used atrocities like <em>"aspect=16/9"</em>, <em>"-vf scale=560:480,expand=720:480,harddup"</em>.  But in general you don\'t want to waste bits encoding black-bars.)</p>\n\n<p>This is not the most efficient set of options to <a href="http://www.mplayerhq.hu" rel="nofollow noreferrer">mencoder</a> by far!  It can be time consuming to run.  But I had other goals in mind...</p>\n'}, {'answer_id': 2785251, 'author': 'hamishmcn', 'author_id': 3590, 'author_profile': 'https://Stackoverflow.com/users/3590', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://www.rhozet.com/carbon_coder.html" rel="nofollow noreferrer">Rhozet Carbon Coder</a> can handle a <a href="http://www.rhozet.com/rhozet_formatGuide.pdf" rel="nofollow noreferrer">wide range of formats</a> plus you can use plugins to alter the video (eg add a watermark)</p>\n'}, {'answer_id': 3011043, 'author': 'jdbow75', 'author_id': 363002, 'author_profile': 'https://Stackoverflow.com/users/363002', 'pm_score': 3, 'selected': True, 'text': '<p>I strongly recommend ffmpeg. On Windows, I have found <a href="https://ffmpeg.zeranoe.com/builds/" rel="nofollow noreferrer">this site</a> to host good binaries.</p>\n'}]
['https://Stackoverflow.com/questions/6932', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/571/']