From a91c387268792f22f0b68ca4ee8ce9d8f0c971bf Mon Sep 17 00:00:00 2001 From: Max-Julian Pogner Date: Sat, 4 Jan 2025 14:59:38 +0100 Subject: [PATCH] general: linux audio extract now considers actual header len The documentation on page /general/audio-file-format/ section 2. Audio file format reports, that the header is of variable length. Thus, for precise audio data extraction, the header's length must be parsed in order to discard the correct number of bytes. Previously, the code-snippet discarded always 4096 bytes, which would fail when the header length should be ever different. Also, i always like to have easy-to-copy&paste snippets in documentation. --- content/docs/wiki/general/audio-file-format.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/content/docs/wiki/general/audio-file-format.md b/content/docs/wiki/general/audio-file-format.md index 5ea3cda6..2db73e3d 100644 --- a/content/docs/wiki/general/audio-file-format.md +++ b/content/docs/wiki/general/audio-file-format.md @@ -76,9 +76,21 @@ But the in experiments used encoder did not have an obvious feature to do this. **We have developed a tool called [teddy](https://github.com/toniebox-reverse-engineering/teddy) to encode and decode these files.** -# Audio file extraction with Linux OS -- Remove Header of the file with ´dd bs=4096 skip=1 if=500304E0 of=trim.ogg´ -- then just use ffmpeg to convert it into mp3 ´ffmpeg -i trim.ogg done.mp3´ +# Audio file extraction with Linux OS and bash shell + +1. read the *header_len* (in hex): `dd status=none if=50012345 bs=1 count=4 | xxd -plain` +2. convert to decimal and add 4 in order to get the length (in decimal) of the whole header +3. read the audio_data into file: `dd if=50012345 bs=1 skip="${header_len}" of=50012345.audio_data.ogg` +4. (optional) convert audio_data from ogg to mp3: `ffmpeg -i 50012345.audio_data.ogg 50012345.audio_data.mp3` + +The same procedure as one block of spagetthi code for easier copy&paste: + +```bash +inputfile=50012345 +header_len="$((4+0x"$(dd status=none if="${inputfile}" bs=1 count=4 | xxd -plain)"))" +dd if="${inputfile}" bs=1 skip="${header_len}" of=${inputfile}.audio_data.ogg +ffmpeg -i "${inputfile}.audio_data.ogg" "${inputfile}.audio_data.mp3" +``` # Audio file extraction with Windows - Remove Header of the file with: powershell -Command "$in = [System.IO.File]::OpenRead('00000000'); $out = [System.IO.File]::Create('trim.ogg'); $in.Seek(4096, 'Begin') | Out-Null; $in.CopyTo($out); $in.Close(); $out.Close()"