[FFmpeg-user] mp4 generate moov atom at beginning of recording

Robert Krüger krueger at lesspain.de
Tue Aug 20 11:31:12 CEST 2013


On Mon, Aug 19, 2013 at 6:53 PM, simon mares <simon.mares at gmail.com> wrote:
> On 08/19/2013 04:39 PM, Tom Evans wrote:
>>
>> On Sun, Aug 18, 2013 at 3:04 AM, simon mares <simon.mares at gmail.com>
>> wrote:
>>>
>>> Hello, is it possible to generate a pre-defined moov atom for fixed
>>> lenght
>>> of fe. 8 hours with use of
>>> http://ffmpeg.org/ffmpeg-all.html#MOV_002fMP4_002fISMV arguments? Video
>>> would never be seeked beyond the real duration, as I would not allow.
>>>
>>> Reason for doing this is that I'm experimenting with something and I
>>> would
>>> like to playback the file that I'm still recording, so it's kind of a
>>> live-streaming, but it's only used locally. As I'm only transcoding from
>>> .ts
>>> to .mp4 file no CPU is used, this is also my goal.
>>>
>>> Codec is h264, 720p, 25pfs. Video is generated with blackmagic
>>> pro-recorder.
>>>
>> Just use "-movflags faststart".
>>
>> Cheers
>>
>> Tom
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> Hey
> Thank you for answer.
> I tried this, indeed ffmpeg did move moov atom in front of movie data (mdat)
> but when I open this video after 18 seconds of recoding and video *is still
> being recorded* then duration is 18 seconds in player, but video is still
> recording. What I would need that I would predefine this headers for some
> hours ahead.
>
> Please note that I'm encoding from named pipe, so mp4 file is generated
> on-the-fly.
>
> One more explanation
>
> *Current state*:
> 1) Recording started (recording_01.mp4) from named pipe from video encoder
> 2) Video is being recorded for 18 seconds now and it continues to record
> 3) I open recording_01.mp4 in video player, duration is 18 seconds and I'm
> watching from start, 5 seconds
> 4) ffmpeg is still encoding to recording_01.mp4 ... duration 18, 19, 20, 21
> s, ...
> 5) when I come to 19 seconds video stops being played (point 3)
>
> after 5 seconds of playing
>
> 0s   5s   10s   15s   20s
> |-------------------------------| 23 sec rec_01.mp4
> |----->----------------| 5 sec video player, duration 18 sec
>
> *What I would like is following*:
> 1) Recording started (recording_01.mp4) from named pipe from video encoder
> 2) Video is being recorded for 18 seconds now and it continues to record
> 3) I open recording_01.mp4 in video player, duration is *3600* seconds and
> I'm watching from start
> 4) ffmpeg is still encoding to recording_01.mp4 ... duration 18, 19, 20, 21
> s, ...
> 5) when I come to 19 seconds video *doesnt stop* being played
>
> 0s   5s   10s   15s   20s
> |-------------------------------| 23 sec rec_01.mp4
> |----->---------------------------------- .... -----| 5 sec video player,
> duration 1 hour
>
> Check points 3 and 5, where I put "*".
>
> I hope it's more understandable now.
>

In theory this is a perfect use case for fragmented mp4 but its
usefulness in your case depends on what you are going to use the
generated mp4 files for. I would guess only a fraction of programs
supporting mp4 as a container properly deal with fragmented mp4 files.
You could simply test. Check the part of the documentation that you
already found on the correct command line parameters for fragmented
mp4 (essentially it generates a header every X seconds or bytes and a
player that supports it can jump through those headers like through a
linked list and should be able to do random access in the fragments
that have a complete header).


More information about the ffmpeg-user mailing list