ffmpeg 遇到未知时间戳错误

ffmpeg 遇到未知时间戳错误

我使用 ffmpeg concat 合并多个 ts 文件,我使用以下命令

ffmpeg -y -f concat -i filelist.txt -c copy output.mkv

所有 ts 文件的路径都放在 filelist.txt 中,大多数时候运行良好,但在处理某些 ts 文件时,ffmpeg 会出现以下错误

[matroska @ 044bf9c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[matroska @ 044bf9c0] Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument

我猜错误是由于这些 ts 文件缺少时间戳而导致的?但由于错误消息显示“已弃用并将停止工作将来“所以我的问题是现在如果有办法或一些 ffmpeg 命令标志来抑制此错误并仅合并那些 ts 文件无需重新编码, 谢谢!

答案1

添加-fflags +genpts到 ffmpeg 命令即

ffmpeg -fflags +genpts -i foo.avi -c:v copy -c:a copy foo.mp4

相关内容