I have multiple files that are already been encoded (they have the same format and size) I would like to concatenate on a single video (that already exist and has to be overwritten).
Following the official FAQ Documentation I should use demuxer
FFmpeg has a concat demuxer which you can use when you want to avoid a re-encode and your format doesn’t support file level concatenation.
The problem is that I should use a .txt
file with a list of files using this command line
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output
where mylist.txt
should be:
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
How can I do with PHP?
Also tried with concat protocol
I tried using also the concat protocol
that re-encode videos with these lines of code:
$cli = FFMPEG.' -y -i \'concat:';
foreach ($data as $key => $media) {
$tmpFilename = $media['id'];
$tmpPath = $storePath.'/tmp/'.$tmpFilename.'.mp4';
if ($key != ($dataLenght - 1)) {
$cli .= $tmpPath.'|';
} else {
$cli .= $tmpPath.'\'';
}
}
$cli .= ' -c copy '.$export;
exec($cli);
that generate this command line:
/usr/local/bin/ffmpeg -i 'concat:/USER/storage/app/public/video/sessions/590916f0d122b/tmp/1493768472144.mp4|/USER/storage/app/public/video/sessions/590916f0d122b/tmp/1493767926114.mp4|/USER/storage/app/public/video/sessions/590916f0d122b/tmp/1493771107551.mp4|/USER/storage/app/public/video/sessions/590916f0d122b/tmp/1493771114598.mp4' -c:v libx264 /USER/storage/app/public/video/sessions/590916f0d122b/tmp_video_session.mp4
but I got this error:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fc8aa800000] Found duplicated MOOV Atom. Skipped it