简体   繁体   English

如何让ffmpeg的视频和音频持续时间相同?

[英]How make video and audio duration the same with ffmpeg?

I am merging a few user-generated videos together with ffmpeg-concat and sometimes run into an audio sync issue.我将一些用户生成的视频与ffmpeg-concat合并在一起,有时会遇到音频同步问题。 I figured that it fails when audio and video duration mismatch.我认为当音频和视频持续时间不匹配时它会失败。 Eg:例如:

ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 IMG_7679.mov
16.666016
ffprobe -v error -select_streams a:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 IMG_7679.mov
16.670998

Question is — how do make audio and video duration equal prior to concat, without loosing the content?问题是——如何在不丢失内容的情况下使音频和视频的持续时间在连接之前相等?

Or maybe classic ffmpeg's concat solves this issue somehow and I should use it?或者也许经典的 ffmpeg 的 concat 以某种方式解决了这个问题,我应该使用它?

you can use the trim and or atrim filter to cut a part of the audio or video.您可以使用trim和/或atrim过滤器来剪切音频或视频的一部分。

[v]trim=0:3.23,setpts=START-PTS[vout]
[a]atrim=0:3.23,asetpts=START-PTS[aout]

setpts and asetpts fixes the timestamps setpts 和 asetpts 修复了时间戳

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM