Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically convert a video to FLV [closed]

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.

like image 905
Raibaz Avatar asked Feb 02 '09 10:02

Raibaz


5 Answers

There's a great open source tool call FFmpeg that I use to transcode my videos. I use PHP making shell calls to make it come to life, but I can't imagine that it would be too hard to get it to play nice with Java. (Maybe this could be a good starting point for you.)

I feed my installation 30+ gig batches on a weekly basis and it always comes out as quality material. The only tricky part for me has been getting it compiled to handle a wide variety of video formats. On the bright side, this has provided me with heavy lifting I need.

like image 107
thaBadDawg Avatar answered Nov 14 '22 04:11

thaBadDawg


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

like image 41
Art Clarke Avatar answered Nov 14 '22 04:11

Art Clarke


You basically have two choices if you want to host, transcode and stream flv files (and don't want to buy a video transcoding application): you can call out to FFMpeg/MEncoder or you can use an external Web service. You could also sidestep the problem completely by allowing them to embed YouTube videos on your site.

If you go the 'local FFMpeg route' I would suggest simply using ProcessBuilder and constructing a command-line to execute FFMpeg. That way you get full control over what gets executed, you avoid JNI, which is an absolute nightmare to work with, and you keep OS-specific code out of your app. You can find FFMPeg with all the bells and whistles for pretty much any platform. There's a good chance it's already on your server.

The nice thing about the 'Local FFMPeg' route is that you don't have to pay for any extra hosting, and everything is running locally, although your hosting admin might start complaining if you're using a crazy amount of disk and CPU. There are some other StackOverflow questions that talk about some of the gotchas using FFMpeg to create flvs that you can actually play in the flash player.

The Web service route is nice because there is less setup involved. I have not used Hey!Watch but it looks promising. PandaStream is easy to set up and it works well, plus you get all your videos on S3 with no additional effort.

like image 11
Yu Sun corn Avatar answered Nov 14 '22 04:11

Yu Sun corn


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
(source: pandastream.com)

  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
like image 4
Baishampayan Ghose Avatar answered Nov 14 '22 05:11

Baishampayan Ghose


There is an open source library used by MPlayer, called mencoder, wich supports FLV, as well as a lot of other codecs.

There is a Java GUI you could see how was made

This could help too.

I don't seem to be able to find any example not called from the console, so it may not be usefull for you. :S

Edit Also take a look at this question.

like image 3
Esteban Küber Avatar answered Nov 14 '22 06:11

Esteban Küber