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