Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
This question does not appear to be about
a specific programming problem, a software algorithm, or software tools primarily used by programmers
. If you believe the question would be on-topic on
another Stack Exchange site
, you can leave a comment to explain where the question may be able to be answered.
Closed
last year
.
The community reviewed whether to reopen this question
last year
and left it closed:
Original close reason(s) were not resolved
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
moov
atom on serverside using
FFMPEG
but didn't get any success. Anyone has an idea on how can I achieve this?
–
–
–
–
–
–
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.
–
–
–
–
–
–
the mp4 format needs the moov atom information to play the video, and to generate the moov atom the video must be finished, you can't play a mp4 file while it is recording because you still don't have all the information to create the moov atom part.
What you want to do is some kind of real-time-streaming (play while is recroding) so you need to use another format. HLS streaming and mpeg-dash stores the video in tiny chunks (2 seconds to 10 seconds) and send to the users, this way the users plays many finished files one after the other.
as @Sebastian Annies suggested, to create many tiny mp4 files and concatenate is the same approach: to have tiny finished files and play as a list, here you could get more information
What exactly is Fragmented mp4(fMP4)? How is it different from normal mp4?
–
–
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
if(!output.exists()) // if there is no output file we'll create one
output.createNewFile();
}catch (IOException e){
Log.e("TAG", e.toString());
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