Reputation: 1164
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
Upvotes: 1
Views: 1708
Reputation: 415
$ffmpeg = \FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('videos/vid1.mp4');
$combination = $audio->concat([
'videos/vid1.mp4',
'videos/vid2.mp4'
]);
$combination->saveFromSameCodecs('videos/output.mp4');
Upvotes: 0
Reputation: 201
You can concatenate files directly by using shell_exec().
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'
Upvotes: 1