<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
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.<br><br>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.<br><br>Dan<br><br><div>> Date: Wed, 5 Oct 2011 22:18:24 +0000<br>> From: atlithorn@gmail.com<br>> To: libav-user@ffmpeg.org<br>> Subject: [Libav-user] newb mp4 question<br>> <br>> Hi, I'm trying to remux an flv muxed aac stream using the mp4 muxer.<br>> (movenc.c). It works fine so long as I call av_write_trailer.<br>> <br>> Problem is I also need to remux live (long running) streams, how would<br>> I go about that. Currently a skeleton of my code looks like this<br>> <br>> init_input<br>> init_output<br>> <br>> do{<br>>   av_init_packet(&ipacket)<br>>   av_read_frame(iFormatCtx, &ipacket);<br>>   if(packet.stream_index == audioStrem){<br>>     av_init_packet(&opacket);<br>> <br>>     copy stuff around, code borrowed from ffmpeg.c<br>> <br>>     av_write_frame(oFormatCtx, &opacket);<br>>     av_free_packet(&opacket);<br>>   }<br>>   av_free_packet(&ipacket);<br>> <br>> }while(stuff is incoming);<br>> <br>> av_write_trailer(oFormatCtx);<br>> <br>> <br>> I was hoping I could buffer av_write_frame calls and write out to a<br>> client but the client can't understand the file without the trailer it<br>> seems. I'm new to this stuff so I was hoping someone could point me in<br>> the right direction.<br>> <br>> Before you ask, I am streaming to the Android MediaPlayer so my format<br>> options are a little limited.<br>> <br>> Thanks,<br>> Atli.<br>> _______________________________________________<br>> Libav-user mailing list<br>> Libav-user@ffmpeg.org<br>> http://ffmpeg.org/mailman/listinfo/libav-user<br></div>                                      </div></body>
</html>