9

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
  • 3,414
  • 8
  • 35
  • 58

1 Answers1

19

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.

Ngoral
  • 4,215
  • 2
  • 20
  • 37
  • 2
    thanx. 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 – Jabb Apr 12 '16 at 17:43
  • Please, see the edit I made: there's a small script that can help you. – Ngoral Apr 12 '16 at 22:53
  • 2
    Thanks. 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. – Jabb Apr 13 '16 at 06:57
  • Can I also use `G` as the unit for Gigabyte? – Qin Heyang Jun 30 '22 at 00:36
  • @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 – Ngoral Jul 06 '22 at 14:54