0

I want to write soap webservice like Coconut

Coconut::Job.create(
  "api_key" => "k-api-key",
  "vars" => {"cdn" => "s3://accesskey:secretkey@mybucket", "vid" => 1234},
  "source" => "mysite.com/media/video.mp4",
  "outputs" => {
    "mp4" => "$cdn/videos/$vid/video.mp4",
    "webm" => "$cdn/videos/$vid/video.webm",
    "hls" => "$cdn/hls/$vid/video.m3u8",
    "dash" => "$cdn/dash/$vid/video.mpd",
    "jpg:300x" => "$cdn/previews/$vid/thumbs_%1d.jpg, number=3",
    "gif:150x" => "$cdn/previews/$vid/animated.gif"
  }
)

Now I want to write some thing like this but I am in two mind to select java or some thing like PHP because my original codes are in PHP it seem that the most used library is ffmpeg. for php I found this library https://github.com/PHP-FFMpeg/PHP-FFMpeg for java I found this libraries : JAVE,JMF,SMF.

I would be appreciate if any body tell me which language and which library and why this library (speed or features or ...)

Farnabaz
  • 4,030
  • 1
  • 22
  • 42
Ebrahim Poursadeqi
  • 1,776
  • 2
  • 17
  • 27

1 Answers1

1

Based on your query, the server language is almost irrelevant in the ones you mentioned. The bit that does the crunching is ffMpeg and that's the most important. As you already have the control/interface in PHP, stay with it.

Suggestion to help: Don't use the ffMPEG library. Build your own commands and use exec to run. Reasons: - It's simpler (and is all the library does anyway) - ffMPEG has a gazillion options / configuration steps that sometimes building them into the library is impossible - However you do need to ensure your command is 'safe'

If you're looking at other languages, you could do far worse than NodeJS; there is a reasonable library for ffMPEG (although see note about passing parameters can be impossible for super-complex stuff) and the advantage is that NodeJS can pass control back to other requests when ffMPEG is running (PHP, JAVA et al will keep the request open and on hold when ffMPEG is running).

One downside of NodeJS is that if you CTRL-C the application then you can't control ffMPEG by SigTerm gracefully. But that's getting more advanced and the simple solution is not to ctrl-C the application :)

Also note that ffMPEG should only run one at a time (per CPU core) as a general rule. Hold ffMPEG tasks in a queue and only process one at a time. This means you can use PHP to handle HTTP requests and put into a queue, and another language entirely to trigger the ffMPEG (but again, may as well stay with PHP, but NodeJS would be better running this but as a service).

Check out REDIS queues and/or RabbitMQ for queuing options cross-compatible with both NodeJS and PHP.

Robbie
  • 17,605
  • 4
  • 35
  • 72
  • hi robbie currently im using java because i can use multi thread and pools very easy to manage this task.i didn't use nodejs before just a touch but i will test your solution :) thanks – Ebrahim Poursadeqi Dec 20 '16 at 05:42
  • 1
    No need to change from Java either, especially if you're running threads as you can have one service task with multiple threads (up to number of cpus) listening to a queue to process jobs. Sound like you're mostly there. Just use runTime:exec() once you've built the right command and should be smooth sailing. RabbitMQ and Redis both have Java clients as well... – Robbie Dec 20 '16 at 06:52