a guest Dec 5th, 2016 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. If you have a long good recording, and you're on unix, you should be able to patch the two together like so:
  3. head -c 3221 long_good.m4a > fixed.m4a
  4. tail -c +3222 brokenrecording.m4a >> fixed.m4a
  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.
  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`.
  10. ---
  12. tinytest_broken and brokenrecording both contain valid audio data, so it's probably just a matter of getting them a correct audio header.
  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.
  16. The header encodes a duration, so we need to work out where. I think I found three separate places:
  18. * location 0x38, shortly after 'moov', the bytes 0x00000817 (2071 miliseconds, where miliseconds are given by 0x03e8 (1000) just before).
  20. * location 0x127, same bytes - miliseconds this time are the same as before
  22. editing these both to 0x10000817, mplayer now says the duration of the file is 74:33:57.5, but it still cuts out.
  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.
  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.
  28. The file format spec is here:
  30. and mp4-specific extensions are here:
RAW Paste Data