FFmpeg的CONCAT视频和音频不同步 [英] FFmpeg concat video and audio out of sync

查看:3633
本文介绍了FFmpeg的CONCAT视频和音频不同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在加入时间戳或偏移的不匹配使用的ffmpeg CONCAT 似乎导致多个文件音频。我试过几个视频,注意到了H.264 / MP4同样的问题。

Joining multiple files using ffmpeg concat seems to result in a mismatch of the timestamps or offsets for the audio. I've tried with several videos and noticed the same problem for h.264 / MP4.

使用 CONCAT 和编码的视频似乎做工精细。音频保持同步的ffmpeg的不完整的转换计算,似乎把一切权利。

Using concat and encoding the video seems to work fine. The audio stays in sync as ffmpeg does the full conversion calculations and seems to get everything right.

然而,简单地串联了视频,而不会在缓慢增加同步问题进行任何改造或编码的结果。显然,编码的视频,而不是简单地加入他们将会导致信息丢失/质量,所以我宁愿找到解决这一问题的方法。

However, simply concatenating the videos without any transformation or encoding results in a slowly increasing sync issue. Obviously, encoding the videos rather than simply joining them will result in a loss of information/quality so I would rather find a way around this problem.

我已经尝试了几种标志理清出现是基于时间戳这个问题。这些似乎都不虽然解决问题。

I've tried several flags to sort out this problem that appears to be based on the timestamps. None of these seem to correct the problem though.

ffmpeg -f concat -fflags +genpts -async 1 -i segments.txt test.mov
ffmpeg -auto_convert 1 -f concat -fflags +genpts -async 1 -i segments.txt -c copy test2.mov
ffmpeg -f concat -i segments.txt -c copy -fflags +genpts test3.mp4
ffmpeg -f concat -fflags +genpts -async 1 -i segments.txt -copyts test4.mov
ffmpeg -f concat -i segments.txt -copyts test5.mov
ffmpeg -f concat -i segments.txt -copyts -c copy test6.mov
ffmpeg -f concat -fflags +genpts -i segments.txt -copyts -c copy test7.mov

注:我能找到的所有其他问题,这样似乎简单地重新编码视频修复的问题。没有一个良好的解决方案。

我意识到CONCAT不是问题。原设定的剪辑有不匹配的时间戳。不知怎的,CONCAT +固定编码的问题,但我不想再带code中的视频和适度宽松的质量各一次。

I realized the concat wasn't the problem. The original set of clips had mis-matched timestamps. Somehow concat + encoding fixed the issue, but I don't want to re-encode the videos and loose quality each time.

ffmpeg -y -ss 00:00:02.750 -i input.MOV -c copy -t 00:00:05.880 output.MOV

这导致了如下的数据

Which resulted in the following data

ffprobe -v quiet -show_entries stream=start_time,duration output.MOV

start_time=-0.247500
duration=6.131125
start_time=-0.257333
duration=6.155333

从那时起,我试图用 -to M和 -t 在不同的地方一起 -af APAD -c:v复制和我仍然未能获得持续的时间是一样的。

Since then I've tried to use -tom and -t in different places along with -af apad -c:v copy and I've still failed to get the duration to be the same.

我录一个样本视频,添加的命令砍它,然后它的concat。 http://davidpennington.me/share/audio_sync_test_video.zip

I recorded a sample video, added the commands to chop it up, then concat it. http://davidpennington.me/share/audio_sync_test_video.zip

推荐答案

这两个步骤应该工作

第1步在每段垫出来的音频

ffmpeg -i segment1.mov -af apad -c:v copy <audio encoding params> -shortest -avoid_negative_ts make_zero -fflags +genpts padded1.mov

或者

生成与同步流段

ffmpeg -y -ss 00:00:02.750 -i input.MOV -c copy -t 00:00:05.880 -avoid_negative_ts make_zero -fflags +genpts segment.MOV

第2步的毗连

ffmpeg -f concat -i segments.txt -c copy test.mov

其中, segments.txt 由填充文件的名称。

这篇关于FFmpeg的CONCAT视频和音频不同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆