繁体   English   中英

PHP FFMPEG - 将 .mov 转换为 .mp4 (H264)

[英]PHP FFMPEG - Convert .mov to .mp4 (H264)

我最近在服务器上安装了 PHP-FFMpeg 库并使用了以下教程: https : //github.com/PHP-FFMpeg/PHP-FFMpeg

我设法将 .mov 视频(通过移动设备上传)转换为 webm 和 ogg,但是当编码为 mp4 时,我总是从错误对象(在 try catch 中)收到“编码失败”消息。

这是我在实例化 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');

谢谢你的帮助!

如果有人遇到这种情况并需要使用 FFMpeg 将 MOV 转换为 MP4,正确的方法是:

  $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');

答案在这里找到

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM