Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. If you have a long good recording, and you're on unix, you should be able to patch the two together like so:
  2.  
  3. head -c 3221 long_good.m4a > fixed.m4a
  4. tail -c +3222 brokenrecording.m4a >> fixed.m4a
  5.  
  6. Maybe use a hex editor first to confirm that the bytes 'mdat' are in the correct location (byte 0xc95 should be the m in both files) - if not, you should get everything up to mdat from the good file, and everything from mdat onwards from the bad one.
  7.  
  8. mplayer and ffmpeg both seem to work with the patched files, they give warning messages but they play them. With ffmpeg, you should be able to recode to a non-errored file with something like `ffmpeg -i with-errors.m4a no-errors.mp3`.
  9.  
  10. ---
  11.  
  12. tinytest_broken and brokenrecording both contain valid audio data, so it's probably just a matter of getting them a correct audio header.
  13.  
  14. The header looks like it finishes around byte 0xc96 (3222), where all files have the bytes 'mdat'. So I took the first 3221 bytes of tinytest_notbroken and appended bytes 3222 onwards of brokenrecording. mplayer then plays two seconds of audio from brokenrecording.
  15.  
  16. The header encodes a duration, so we need to work out where. I think I found three separate places:
  17.  
  18. * location 0x38, shortly after 'moov', the bytes 0x00000817 (2071 miliseconds, where miliseconds are given by 0x03e8 (1000) just before).
  19.  
  20. * location 0x127, same bytes - miliseconds this time are the same as before
  21.  
  22. editing these both to 0x10000817, mplayer now says the duration of the file is 74:33:57.5, but it still cuts out.
  23.  
  24. * Another duration is at location 0x187, bytes 0x000164b3 (approximately 2.07 seconds in 1/44100 of a second, 44100 is given by 0x0000ac44 just before). But editing this to 0x100164b3 doesn't seem to change anything.
  25.  
  26. I can't find any other instances of those byte patterns. I'm not sure what to try next, but maybe someone else will be able to figure it out.
  27.  
  28. The file format spec is here: http://l.web.umkc.edu/lizhu/teaching/2016sp.video-communication/ref/mp4.pdf
  29.  
  30. and mp4-specific extensions are here: https://www.cmlab.csie.ntu.edu.tw/~cathyp/eBooks/14496_MPEG4/ISO_IEC_14496-14_2003-11-15.pdf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement