Programmatically convert a video to FLV [closed]

2019-01-31 13:44发布

i am currently working on a web application that needs to accept video uploaded by users in any format (.avi, .mov, etc.) and convert them to flv for playing in a flash-based player.

Since the site is OpenCms-based, the best solution would be a ready-made plugin for OpenCms that allowed to upload and play videos doing the transcode operation in background, but just a set of Java classes to do the transcode would be great and then i could make the uploading form and playback part on my own.

11条回答
【Aperson】
2楼-- · 2019-01-31 13:45

You can encode video in Java using Xuggler, which is a Java API that natively uses FFmpeg's C code behind the scenes.

查看更多
姐就是有狂的资本
3楼-- · 2019-01-31 13:50

This can be slightly tangential, but I have found Panda Stream to be a very useful solution to all kinds of video encoding problems.

All you have to do is to upload the video file to an Amazon EC2 instance running Panda and it will encode the video to your desired formats and quality and will issue a callback to your application server with the details when it's done. You can then use the bundled Flash Video player or your own player to play the videos on your site.

It's a very scalable (thanks to Amazon EC2 & S3), cost-effective and customisable solution compared to rolling your own.

Highly recommended.

Update:

The architecture of Panda is as follows:

Architecture of Panda Stream http://pandastream.com/images/panda_arch.gif

  1. Page displays Panda's upload form in an iframe or popup
  2. Video upload with AJAX progress bar
  3. API callback when encoding is complete
  4. Video streamed to user
查看更多
ら.Afraid
4楼-- · 2019-01-31 13:50

Encoding files in one format to another takes a lot of development time to get right, which is why there is so little in terms of decoders/encoders that are able to accomplish those feats. The ones that are well known and used the most are ffmpeg and mencoder.

What you may want to look into is to see if the platform you are running on (Windows/Mac OS X/Other unix) has an underlying set of API calls you can use that is able to decode the files, and re-encode them. Windows has DirectShow and Mac OS X has Quicktime. Not sure if you can access those API's using Java though.

FFMpeg does have a Java wrapper available: FFMPEG Java, and there is also FOBS which has a JNI available for their C++ wrapper around ffmpeg. The last one that I found jFFmpeg, however there are some posts that I found with Google suggesting that the project may not be alive any longer.

Your best bet would be either mencoder from mplayer and or ffmpeg. Ffmpeg can be installed as a separate binary and then called from other code using the default "shell" commands. If you are however not able to execute commands you may need to look at using an online conversion website like Mark Robinson suggested.

查看更多
一纸荒年 Trace。
5楼-- · 2019-01-31 13:54

FFMpeg is the best when it comes to video transcoding.

You can use java wrappers for ffmpeg - http://fmj-sf.net/ffmpeg-java/getting_started.php http://sourceforge.net/projects/jffmpeg/

查看更多
时光不老,我们不散
6楼-- · 2019-01-31 13:57

You could try using an online service like HeyWatch to convert your video. Never used it but they claim

"transparent upload, send videos transparently from your website"

Not a java solution, but you wouldn't have to worry about what OS your web application is on.

If OS wasn't an issue I agree with the answer theBadDawg gave. I don't know of and have had not any luck finding a pure java solution.

查看更多
forever°为你锁心
7楼-- · 2019-01-31 13:57

You might also be interested in hearing that we've now released Panda as a hosted service as well, which makes the setup and scaling easier :)

http://pandastream.com

查看更多
登录 后发表回答