Pregunta

I've recently installed the PHP-FFMpeg lib on a server and used the following tutorial: https://github.com/PHP-FFMpeg/PHP-FFMpeg

I managed to convert a .mov video (uploaded through a mobile device) to webm and ogg but when encoding to mp4 I always get an "Encoding Failed" message from the error object (in a try catch).

This is the code I'm using after instantiating FFMPEG

    $video->filters()->resize(new FFMpeg\Coordinate\Dimension(756, 461), $mode = RESIZEMODE_SCALE_WIDTH)->synchronize();

$video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))->save('sites/default/files/videos/thumbnails/'.$filename.'.jpg');

$video->save(new FFMpeg\Format\Video\Ogg(), 'sites/default/files/videos/'.$filename.'.ogg')
      ->save(new FFMpeg\Format\Video\X264(), 'sites/default/files/videos/'.$filename.'.mp4')
      ->save(new FFMpeg\Format\Video\WebM(), 'sites/default/files/videos/'.$filename.'.webm');

Thanks for your help!

¿Fue útil?

Solución

In case anyone comes upon this and needs to convert MOV to MP4 using FFMpeg, the correct method is:

  $ffmpeg = FFMpeg\FFMpeg::create();

  $video = $ffmpeg->open('path/to/movie.mov');
  $format = new FFMpeg\Format\Video\X264();
  $format->setAudioCodec("libmp3lame");

 $video
     ->save($format, 'path/to/movie.mp4');

Answer found here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top