duanleiliu7373
duanleiliu7373
2017-03-17 14:03

通过PHP合并两个视频

已采纳

So, I'm trying to merge two files using PHP and I've taken a look at the FFMpeg library, yet I cannot manage to merge them. Here's what I've got so far:

$ffmpeg = FFMpeg\FFMpeg::create();
$vid1 = $ffmpeg->open('videos/vid1.mp4');
$vid2 = $ffmpeg->open('videos/vid2.mp4');

How do I stitch together $vid1 and $vid2 and save them?

Thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongmu4591 dongmu4591 4年前

    You can concatenate files directly by using shell_exec().

    See FFmpeg Concatenate

    Usage:

    shell_exec( "G:/ffmpeg/ffmpeg.exe -f concat -safe 0 -i G:/ffmpeg/concatenate.txt -c copy G:/ffmpeg/phpconcatenated.mp4" )
    

    concatenate.txt includes names of files you want to merge.

    # Example concatenate.txt
    file 'G:/ffmpeg/input.mp4'
    file 'G:/ffmpeg/input_2.mp4'
    
    点赞 1 评论 复制链接分享