[Libav-user] Record, seek and play

Robert Krüger krueger at lesspain.de
Sat Mar 2 18:04:20 CET 2013

On Sat, Mar 2, 2013 at 5:48 PM, Steve Hart <steve.hart at rtsw.co.uk> wrote:
> On 1 March 2013 17:49, RenE J.V. Bertin <rjvbertin at gmail.com> wrote:
>> >
>> >
>> What if you buffer in memory by using a custom AvIO context or however
>> that's called? At least you be able to catch seeks that go where they
>> shouldn't ... and it might be less platform specific?
>> R
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
> The problem is that the recording could be hours long!
> The problem seems to be down to the fact that some formats don't write the
> header info
> until the file is closed. This is certainly true of mxf'd DV. I debugged
> into the mxf muxer
> and found that duration was 0 - no surprise really.....
> I do have more success is I seek using AV_SEEK_BYTE rather than
> which I am looking at now.
> I know some solutions record off 'chunks' of video and store the latest
> x mins in memory. Then have an algorithm that loads the relevant chunk ahead
> of time.
> But a bit laborious and I'd end up with a bunch of small files.
> Steve

You could take a look at fragmented mp4. I'm not sure how well ffmpeg
seeking works with it but at least in theory you should be able to
produce a file where you have control over how much is available for
seeking while you record by setting fragment_duration (or size)
accordingly (fragmented means a header is written every X bytes or
seconds). Seek performance would be worse than that of an mp4 file
with one header (aka moov box/atom) because when you seek it works
like a linked list jumping from fragment to fragment but it very well
be may be fast enough for your use case. Would be worth a try. Again,
I have not personally tested this with ffmpeg seeking API. It may or
may not be implemented for that demuxer. If it is not, however, you
would have the option to offer a bounty to someone to add that
functionality to the mov/mp4 demuxer.


More information about the Libav-user mailing list