如何将ffmpeg输入流的输出文件大小限制为10兆字节 [英] How to limit output filesize of ffmpeg input stream to 10 megabytes
问题描述
我正在使用ffmpeg从tvheadend订阅一个输入流,我正在将该流连续写入磁盘。我想限制此输出流,以便随时存储最多10兆字节的数据。
I am subscribing to an input stream from tvheadend using ffmpeg and I am writing that stream to disk continuously . I'd like to limit this output stream so that there are 10 megabytes of data stored at maximum at any time.
我已经从moreutils和linux buffer命令中查找海绵来构建某种管道。虽然,我找不到一个工作的解决方案。谁能指出我正确的方向?
I already looked into sponge from moreutils and the linux buffer command to build some kind of a pipe . Though, I could not find a working solution yet. Who can point me into the right direction?
推荐答案
你只需要 -fs
键。
它以字节为单位设置输出文件大小限制。
You need just -fs
key.
It sets output filesize limit in bytes.
您可以键入 ffmpeg -i input -fs 10M -c copy output
,其中输入
是您希望文件拥有的输入地址,输出
- filename。 M
指定您想要的大小(以兆字节为单位)(也允许 k
(千字节))。
You can type ffmpeg -i input -fs 10M -c copy output
, where input
is your input address, output
- filename you want your file to have. M
specifies that you want size in megabytes (also k
for kilobytes is allowed).
为了覆盖,您可以使用这样的小脚本
For overwriting you can use a small sript like this
#!/bin/bash
t=1
while :
do
ffmpeg -i input -fs 10M -c copy output$t
t=`expr $t + 1`
done
我认为这比试图用ffmpeg来做一切事情。
I think this is more elegant than trying to do everything using ffmpeg only.
这篇关于如何将ffmpeg输入流的输出文件大小限制为10兆字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!