解决ffmpeg报错Non-monotonous DTS in output stream 0:0;

7,548 阅读1分钟

最近使用ffmpeg合成mp4视频有了如下报错信息:

Non-monotonous DTS in output stream 0:0; previous: 21587350, current: 12740928; changing to 21587351. This may result in incorrect timestamps in the output file.

解决方法是如下:

for f in ./*.mp4; do ffmpeg -i $f -q 0 "${f%.*}.mts"; done

然后新建文本文档,可以用python新建

f=open('file.txt','w')
for i in range(30):
	f.write('file crypto1-1-'+str(i+2)+'.mts'+"\n")
f.close()

得到如下文件:

在这里插入图片描述
之后使用命令:

ffmpeg -f concat -i file.txt -c copy output.mp4

即可