2

I need to be able to programmatically transcode mpeg-2 files to .mp4, .mp3, .wmv, .rm (optional), and .flv (optional), and hopefully generate a thumbnail as well. I found the Java Media Framework, but it frankly looks pretty crappy. This will be running a Linux server, so I could shell out to ffmpeg using Commons Exec - does ffmpeg do everything I need to do? FFmpeg seems pretty daunting, which is why I'm having trouble finding this information, but it definitely seems to be a jack-of-all-trades. Any suggestions?

dancavallaro
  • 13,109
  • 8
  • 37
  • 33

4 Answers4

5

Ffmpeg is the best and easiest. To output/convert video:

ffmpeg -i {input}.ext -r {target_frame_rate} -ar {target_audio_rate} -b {target_bitrate} -s {width}x{height} {target}.ext

And your screenshot:

ffmpeg -i {input}.ext -r 1 -ss 00:00:04:005 -t 00:00:01 -an -s {width}x{height} {target_name}%d.jpg

15 fps is standard for flv and audio sample rate should be 44100 for flv. Options to use: -r specifies a frame rate of 1 fps (one frame used as the screenshot), -ss seeks to the position you want hh:mm:ss:fff, -t is the duration (one second to match your one fps), -an tells ffmpeg to ignore audio, and -s is the size of the screenshot. The %d is necessary as it will be the digit incremented on how many screenshots you use. With the above, %d will always be the number 1 (one frame, one screenshot). Good luck.

Stu Thompson
  • 38,370
  • 19
  • 110
  • 156
  • Thanks very much, that was a helpful taste of what ffmpeg can do. I'll definitely be looking at ffmpeg more closely.. – dancavallaro Jan 01 '09 at 01:07
  • Out of interest, is using -an when screen-capping of any use? It makes sense that you'd ignore the audio but I'm wondering if there's a performance gain of some description? – Adrian Lynch Jul 24 '09 at 13:01
2

You can also use Xuggler directly from Java, which provides much better codec and encoding support than JMF.

Art Clarke
  • 2,495
  • 18
  • 15
  • Xuggler is on hiatus as no one is actively developing it anymore. Sorry. That said, you can always find the source code and start hacking yourself. Good luck! http://www.xuggle.com/xuggler/status – tostao May 24 '18 at 14:27
2

An interesting web service from encoding.com will transcode files for you.

Brandon
  • 6,832
  • 11
  • 38
  • 50
  • That looks like a good service, but we really don't have that many videos to transcode, it's really in batches of 10 or so, and I'm looking to automate a workflow, so it would be easier to keep everything in-house. – dancavallaro Jan 01 '09 at 01:04
  • I've been looking for a service like this EVERYWHERE, thanks Brandon – Fire Crow Jul 23 '09 at 21:42
0

The popular transcoding applications for Linux are ffmpeg, transcode and mencoder. Both transcode and mencoder use ffmpeg and all three can handle the tasks that you require, including FLV transcoding and video thumbnailing. ffmpeg is probably the most popular of the three, so you might find better online support. Also worth mentioning is that ffmpeg supports multithreaded transcoding.

I would recommend using ffmpeg.

codelogic
  • 71,764
  • 9
  • 59
  • 54