Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert a movie into .MP4 from .MOV using a PHP upload script?

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.

like image 938
willpots Avatar asked Dec 13 '22 11:12

willpots


2 Answers

Well I know this is an alternative solution:

  • http://handbrake.fr/ CLI (Command Line Interface)
  • https://trac.handbrake.fr/wiki/CLIGuide, just use PHP to kick it off
  • Install Handbrake Ubuntu

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

like image 50
Phill Pafford Avatar answered Jan 13 '23 13:01

Phill Pafford


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.

like image 23
jncraton Avatar answered Jan 13 '23 14:01

jncraton