Our client sends a request to download a movie file from a server. As the server receives the request, it will start a ffmpeg process to transcode the movie. The output of ffmpeg is temporarily saved to harddisk. We dont want to make client to wait to download the file after transcoding finish, so we send output data as its generated.
The problem is that ffmpeg seem to rewrite the output file header after finish transcoding, so the downloaded file (on client side) doesnt have correct file header, and player can not play it.
My question is that there is any way to make ffmpeg not to rewrite the header? What should be the solution for this?
EDIT: the command is to transcode to H264/AAC in mp4 container
Yes
ffmpeggoes back to the beginning of the file and updates structures to indicate effective sizes that are only available when the file is being completed.To be able to stream “live” you should consider passing payload video/audio using another method such as using RTSP protocol. Incomplete MP4 files are not well playable until fully complete.