2017-05-03 01:12
浏览 491

连接多个视频php ffmpeg

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;

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

图片转代码服务由CSDN问答提供 功能建议

我有多个已编码的文件(它们具有相同的格式和大小 )我想在一个视频(已经存在并且必须被覆盖)上连接。


\ n

FFmpeg有一个concat demuxer,当你想避免重新编码时你可以使用它,你的格式不支持文件级连接。 < 问题是我应该使用 .txt 文件和一个使用此命令行的文件列表

ffmpeg -f concat -safe 0 -i mylist.txt -c copy output

其中 mylist.txt 应为:

 <  code> file'/ path / to / file1'
file'/ path / to / file2'
file'/ path / to / file3'

怎么能 我用PHP吗?

\ n


我尝试使用 concat协议重新编码视频 代码:

  $ cli = FFMPEG。'  -y -i \'concat:'; 
foreach($ data as $ key =&gt; $ media){
 $ tmpFilename = $ media ['id']; 
 $ tmpPath = $ storePath。'/  tmp /'.$ tmpFilename。'。mp4'; 
 if($ key!=($ dataLenght  -  1)){
 $ cli。= $ tmpPath。'|'; 
} else {
  $ cli。= $ tmpPath。'\''; 
 $ cli。=' -  c copy'。$ export; 
exec($ cli); 


/ 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 < / code>


[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fc8aa800000]发现 复制的MOOV Atom。 跳过它

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题