4

I am trying to upload a movie onto a site and then automatically convert it into .mp4 format from the .mov iPhone format. Is there a php conversion library or tool that would help me do this?

Thanks.

willpots
  • 235
  • 3
  • 11

5 Answers5

5

Well I know this is an alternative solution:

PHP:

$cmd = './HandBrakeCLI -i /path/to/source.MOV -o movie.mp4 --preset="iPhone & iPod Touch"';
echo exec($cmd);

Note: You will need to install Handbrake on your server

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
3

You could try the ffmpeg extension: http://ffmpeg-php.sourceforge.net/

Edit:

It turns out that the ffmpeg extension probably won't help you, but you could still use ffmpeg to do the conversion. You are probably better off having a cron job or something similar do the conversions in the background. Just let the user upload the mov file, and then add it to a queue and convert it to mp4 in another process.

jncraton
  • 9,022
  • 3
  • 34
  • 49
  • I don't believe ffmpeg does file conversion. – tplaner Jun 24 '11 at 20:14
  • It looks like you're right. I assumed that the extension wrapped all of ffmpeg's functions. It looks like it is mainly useful for generating thumbnails. – jncraton Jun 24 '11 at 20:18
  • This does look useful and I will certainly implement it, but unfortunately I still need to find another solution. – willpots Jun 27 '11 at 17:45
3

The Apple mov files are in fact MP4 containers - so .mov == .m4v == .mp4 == .m4a. It will be ok to just rename the file. Or do you want a specific codec?

Sebastian Annies
  • 2,438
  • 1
  • 20
  • 38
2

Not really unfortunately.

I've been doing this exact thing for the past 4 years, if you want to take a crack at writing it yourself, your best bet is to fork an exec to ffmpeg in your upload script eg.

exec('ffmpeg ... &');

note the ampersand at the end, this allows your php script to complete while allowing the encode to happen in the background, also CHECK YOUR INPUT VARS as there is the chance of shell injection using this method.

or the alternative:

use a system like beanstalkd as a message queue between your php upload script and a worker process (I use a custom multithreaded perl script) on the backend that takes in new encodes and processes them (I'm using ffmpeg, mencoder, or quicktime using qt_tools, depending on input video format), using memcached as temp storage for encoding status.

sorry I can't be more specific right now, I may update this tomorrow with a bit more, but I've been up all night, and need SLEEP. hopefully this gets you moving in the right direction till then.

Jason
  • 2,035
  • 11
  • 13
0

Try command :

 ffmpeg -i movie.mov -vcodec copy -acodec copy out.mp4
Pooja Jadav
  • 279
  • 1
  • 3
  • 17