[Libav-user] newb mp4 question

Dan Haddix dan6992 at hotmail.com
Thu Oct 6 01:35:54 CEST 2011


You can't falsify the MOOV atom because it contains file offsets to the individual data blocks, and you wont know what those offsets are until the data is written. If you need to stream realtime then MP4 is not a good format.

I didn't realize you were only streaming audio though. In that case you don't really need a container at all. You can stream raw AAC frames as long as they have an ADTS header attached. You only need a container if you need to interleave audio and video data, or if you need timestamps for seeking. If you're just streaming in real time then sending raw frames should work fine.

Dan

> Date: Wed, 5 Oct 2011 23:05:16 +0000
> From: atlithorn at gmail.com
> To: libav-user at ffmpeg.org
> Subject: Re: [Libav-user] newb mp4 question
> 
> Thanks Dan, when we stream live we often falsify the content-length to
> something like 2gb, users are never going to hit that limit with
> normal usage so it's "good enough". The underlying http client will
> often cut off at that point which is fine, people will forgive
> restarting a stream after 2gb of listening.
> 
> Could I use QTFastStart and provide similarily false information to
> the container so it could at least start streaming?
> 
> While I have you on the line ;) what transport stream should I
> otherwise be looking at. I don't have a lot of options to choose
> from....
> 
> Atli.
> 
> On 5 October 2011 22:38, Dan Haddix <dan6992 at hotmail.com> wrote:
> > MP4 files contain something called a MOOV atom, which contains vital
> > information about the file that is needed for playback. The MOOV atom is not
> > written until you call av_write_trailer. And even then it's written to the
> > very end of the file which makes it so you can't stream the file. There is
> > another chunk of code in FFmpeg called QTFastStart which moves the MOOV atom
> > to the start of the file, which in turn makes it possible to stream the
> > file, but you still need a finished file before you can call it. So it's
> > really only meant for streaming complete files from a server to a player.
> >
> > If you need to remux and stream in realtime then you'd be better off using
> > another format. Transport streams are the best for streaming. They have no
> > header or footer and can be picked up at any point in the stream without
> > issue. This is why broadcasters use TS for digital TV signals.
> >
> > Dan
> >
> >> Date: Wed, 5 Oct 2011 22:18:24 +0000
> >> From: atlithorn at gmail.com
> >> To: libav-user at ffmpeg.org
> >> Subject: [Libav-user] newb mp4 question
> >>
> >> Hi, I'm trying to remux an flv muxed aac stream using the mp4 muxer.
> >> (movenc.c). It works fine so long as I call av_write_trailer.
> >>
> >> Problem is I also need to remux live (long running) streams, how would
> >> I go about that. Currently a skeleton of my code looks like this
> >>
> >> init_input
> >> init_output
> >>
> >> do{
> >> av_init_packet(&ipacket)
> >> av_read_frame(iFormatCtx, &ipacket);
> >> if(packet.stream_index == audioStrem){
> >> av_init_packet(&opacket);
> >>
> >> copy stuff around, code borrowed from ffmpeg.c
> >>
> >> av_write_frame(oFormatCtx, &opacket);
> >> av_free_packet(&opacket);
> >> }
> >> av_free_packet(&ipacket);
> >>
> >> }while(stuff is incoming);
> >>
> >> av_write_trailer(oFormatCtx);
> >>
> >>
> >> I was hoping I could buffer av_write_frame calls and write out to a
> >> client but the client can't understand the file without the trailer it
> >> seems. I'm new to this stuff so I was hoping someone could point me in
> >> the right direction.
> >>
> >> Before you ask, I am streaming to the Android MediaPlayer so my format
> >> options are a little limited.
> >>
> >> Thanks,
> >> Atli.
> >> _______________________________________________
> >> Libav-user mailing list
> >> Libav-user at ffmpeg.org
> >> http://ffmpeg.org/mailman/listinfo/libav-user
> >
> > _______________________________________________
> > Libav-user mailing list
> > Libav-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/libav-user
> >
> >
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20111005/1c81dbf0/attachment.html>


More information about the Libav-user mailing list