I am working on live device to server streaming in android. I am able to send data in bytes on server but when i play that file during recording on server VLC say that MOOV atom not found. After a lot of workaround i found that MOOV atom of a mp4 file generates in the end. But i have to play that file on server while recording means live. I go through the source code of SPYDROID and SIPDROID but non of them is working. I tried to add move atom on serverside using FFMPEG but didn't get any success. Any one have any idea how can i achieve this. Thanx in advance.
问题:
回答1:
You got a problem. The 'moov' box is a kind of table of contents. If not all content is there you can't have a complete table of contents. Ouch!
If you want to stick with MP4 and if you are writing the file by yourself you could write the file as so called fragmented MP4 file. A fragmented MP4 file contains multiple self-contained small pieces of the video - each with its own table of contents. It would enable you to play the file before the complete recording has finished.
If you don't need to stick with MP4 an option would be to write the raw h264 stream to the server. Then you don't have that kind of table of content. VLC can play raw h264 streams.
回答2:
Run qt_faststart to move the moov atom to the beginning of the stream.
qt-faststart in.mp4 out.mp4
回答3:
Use MP4Box to move MOOV atom at begening of file and interleaving to stream in chunk.
MP4Box test.mp4 test.mp4
回答4:
It is possible to move the moov atom to the begining of the video file using FFMpeg.
ffmpeg -i input_video_file.mp4 -vcodec copy -acodec copy -movflags faststart output_video_file.mp4
回答5:
Add to your gradle this lib: compile 'net.ypresto.qtfaststartjava:qtfaststart:0.1.0' and then
File input = new File(path + "/input.mp4"); // Your input file
File output = new File(path + "/output.mp4"); // Your output file
try{
if(!output.exists()) // if there is no output file we'll create one
output.createNewFile();
}
}catch (IOException e){
Log.e("TAG", e.toString());
}
try{
QtFastStart.fastStart(input, output); // Adds moov to your input
// Now your output file is ready to stream!
}catch (QtFastStart.MalformedFileException m){
Log.e("QT", m.toString());
}catch (QtFastStart.UnsupportedFileException q){
Log.e("QT", q.toString());
}catch (IOException i){
Log.e("QT", i.toString());
}
Here that's all