How to limit output filesize of ffmpeg input stream to 10 megabytes
You need just -fs
key.
It sets output filesize limit in bytes.
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
I think this is more elegant than trying to do everything using ffmpeg only.
Jabb
Updated on June 21, 2022Comments
-
Jabb about 2 years
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.
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?
-
Jabb about 8 yearsthanx. the -fs option will stop ffmpeg. I'd like to overwrite the segment continuosly. I think I found a good solution that is quite close to what I need. -f ssegment -segment_time 60 -segment_wrap 2 tmp/out%03d.ts
-
Ngoral about 8 yearsPlease, see the edit I made: there's a small script that can help you.
-
Jabb about 8 yearsThanks. I disagree though. It is more elegant to use a native ffmpeg function instead of implementing sth. external. But since your solution is more exact I will accept it as an answer.
-
Qin Heyang about 2 yearsCan I also use
G
as the unit for Gigabyte? -
Ngoral almost 2 years@QinHeyang I can't tell right away from looking at a documentation. I guess you can simply try. I thinm it'll fail if
G
is not a right option