gpt4 book ai didi

audio - 结合cdg和mp3时如何使ffmpeg尊重 "start_time"变量?

转载 作者:行者123 更新时间:2023-12-02 23:02:25 27 4
gpt4 key购买 nike

我正在尝试合并两个 .cdg 和 .mp3 文件,因为我想用它们制作一个 .mkv 文件。

当我这样做时,我会得到一个 .mkv 文件,但不幸的是音频没有与视频同步。

所以,我想知道这是为什么?显然我必须在我的命令或其他东西上缺少一个参数。

我要做的是:

ffmpeg -y -i song.cdg -i song.mp3 -pix_fmt yuv420p -vcodec libx264 -acodec copy song.mkv

它工作正常,但在这种特殊情况下,结果不同步约 1.2 秒。这因歌曲而异,从 0 秒到几秒不等。

但是,如果我对 .cdg 文件执行 ffprobe,我会注意到这个数字已经存在,作为“start_time”变量:
ffprobe -v error -show_format -show_streams song.cdg
...
start_time=1.186667
...

所以,如果我直接使用这个数字作为 -itsoffset 参数:
ffmpeg -y -itsoffset 1.186667 -i song.cdg -i song.mp3 -pix_fmt yuv420p -vcodec libx264 -acodec copy song.mkv

然后视频和音频完美同步。

所以,我想知道 - 我需要在命令中添加什么参数才能让 ffmpeg 尊重这个变量?

最佳答案

我尝试添加 -copyts 参数,它解决了我的问题。

ffmpeg -copyts -y -i song.cdg -i song.mp3 -pix_fmt yuv420p -vcodec libx264 -acodec copy song.mkv

https://ffmpeg.org/ffmpeg.html

-copyts
Do not process input timestamps, but keep their values without trying to sanitize them. In particular, do not remove the initialstart time offset value.

Note that, depending on the vsync option or on specific muxerprocessing (e.g. in case the format option avoid_negative_ts isenabled) the output timestamps may mismatch with the input timestampseven when this option is selected.

关于audio - 结合cdg和mp3时如何使ffmpeg尊重 "start_time"变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60078498/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com