I am trying to stream video from android camera through local unix socket and write file from stream to sdcard. Everything works fine, except file is not playable with any player. It's because Android not filling some gaps in the file because socket is not seekable. As I understand I need to make some modifications after video stream is over. I read several articles here, here and here, but none of them helped me. I am playing with hex editor to learn how to do it manually, so afterwards it will be trivial to do the same in the Android code.
Here is sample file that saved from stream: https://dl.dropbox.com/u/17510473/sample_not_playable.3gp
Can anyone fix to make it playable and tell how he done it?
EDIT: I erase header of the 3gp file and write new one as follows:
00 00 00 18 66 74 79 70 33 67 70 34 00 00 03 00 33 67 70 34 33 67 70 36 00 00 00 00
Then I find starting location of mdat and moov atoms with following command:
grep -aobE "ftyp|mdat|moov" sample_not_playable.3gp
And it gives me following output:
4:ftyp
28:mdat
1414676:moov
Then make 1414676 - 28 = 1,414,648 = 0x1595F8
Then I write 0x1595F8 as 25-28 bytes, just prior mdat atom. So my header now looks like this:
00 00 00 18 66 74 79 70 33 67 70 34 00 00 03 00 33 67 70 34 33 67 70 36 00 15 95 F8
And when I try to play it with mplayer I get some damaged video and audio output. Here's some part from mplayer output:
[amrwb @ 0x7f72ad652380]Frame too small (33 bytes). Truncated file?
[amrwb @ 0x7f72ad652380]Encountered a bad or corrupted frame
[amrwb @ 0x7f72ad652380]Encountered a bad or corrupted frame
[amrwb @ 0x7f72ad652380]Frame too small (33 bytes). Truncated file?
[amrwb @ 0x7f72ad652380]Encountered a bad or corrupted frame
[amrwb @ 0x7f72ad652380]Encountered a bad or corrupted frame
[amrwb @ 0x7f72ad652380]Encountered a bad or corrupted frame
A: 11.0 V: 1.4 A-V: 9.650 ct: 0.023 0/ 0 10% 1% 1.6% 0 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f72adeafc40]stream 1, offset 0x15e62b: partial file
[h263 @ 0x7f72ad652380]Bad picture start code
[h263 @ 0x7f72ad652380]header damaged
Error while decoding frame!
[h263 @ 0x7f72ad652380]Bad picture start code
[h263 @ 0x7f72ad652380]header damaged
Error while decoding frame!
[h263 @ 0x7f72ad652380]Bad picture start code
[h263 @ 0x7f72ad652380]header damaged
Error while decoding frame!
A: 11.1 V: 1.5 A-V: 9.558 ct: 0.027 0/ 0 9% 1% 1.4% 0 0
[h263 @ 0x7f72ad652380]Bad picture start code
[h263 @ 0x7f72ad652380]header damaged
Error while decoding frame!
What I am doing wrong?