我的ffmpeg输出总是在末尾增加30秒钟的静音时间 [英] My ffmpeg output always add extra 30s of silence at the end

查看:261
本文介绍了我的ffmpeg输出总是在末尾增加30秒钟的静音时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我用来将1个音频和1个图像合并为1个视频的代码/参数.由于某种原因,无论源是什么,它都会在输出视频的末尾增加30秒的静音.

This is a code / argument I use to merge 1 audio and 1 image into 1 video. For some reason it adds 30s silence to the end of output video no matter the source.

我在装有最新ffmpeg的Win10 x64上运行此程序. 我已经检查了代码,但无法确定导致静音的地方.

I run this on Win10 x64, with latest ffmpeg installed. I have checked the code but cannot identify where it makes the silence.

ffmpeg -y -loop 1 -framerate 2 -i "some.png" -i "with.mp3" 
-c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest "result.mkv"

输出不应包含额外的30秒钟的静音.它应该在音频用完时结束.

The output should not conatin the additional 30s of silence. It should end when audio runs out.

我应该补充一点,我从某个网站复制了大多数参数,并且OP似乎很好地使用了它,所以我不确定这是否只是我的问题.

I should add that I copied most of the arguments from some website, and that OP seems to use it just fine, so I'm not sure if this is just my problem.

推荐答案

使用

ffmpeg -y -loop 1 -framerate 2 -i "some.png" -i "with.mp3" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest -fflags +shortest -max_interleave_delta 100M "result.mkv"

容器(AVI,MP4,MKV)通常以交错的方式存储多个流,即几秒钟的视频,然后几秒钟的音频,依此类推.因此,ffmpeg在写入时会缓冲所有流中的数据.

Containers (AVI, MP4, MKV) usually store multiple streams in an interleaved fashion i.e. a few seconds of video, then a few seconds of audio, and so on. So ffmpeg buffers data from all streams, when writing.

-shortest在较高级别上起作用,并在第一个流完成时触发.但是,来自其他流的缓冲数据仍将写入文件. -fflags shortest在较低级别上起作用,并在与足够高的max_interleave_delta一起使用时,阻止写入缓冲的数据.

-shortest acts at a relatively high-level and is triggered when the first of the streams has finished. However, buffered data from other streams will still be written to file. -fflags shortest acts at a lower level and stops the buffered data from being written when used with a sufficiently high max_interleave_delta.

这篇关于我的ffmpeg输出总是在末尾增加30秒钟的静音时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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