Jabb
Jabb

Reputation: 3502

How to limit output filesize of ffmpeg input stream to 10 megabytes

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?

Upvotes: 10

Views: 21360

Answers (1)

Ngoral
Ngoral

Reputation: 4824

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.

Upvotes: 20

Related Questions