Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ffmpeg

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?

like image 677
Jabb Avatar asked Apr 12 '16 16:04

Jabb


People also ask

How do I set video duration in FFmpeg?

Use the -t option to specify a time limit: `-t duration' Restrict the transcoded/captured video sequence to the duration specified in seconds. hh:mm:ss[. xxx] syntax is also supported.

What is FFmpeg video format?

ffmpeg is a command-line tool that converts audio or video formats. It can also capture and encode in real-time from various hardware and software sources such as a TV capture card. ffplay is a simple media player utilizing SDL and the FFmpeg libraries.


1 Answers

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.

like image 194
Ngoral Avatar answered Sep 24 '22 19:09

Ngoral