Jump to content

using binary code to strip a mp3 file


Recommended Posts

Hi there,

I am trying to strip a mp3 file to only contain a specific part of the whole song.

This is my script:

#include <String.au3>

;open file, get binary code in hex
Dim $file_buffer_old
Dim $file = FileOpenDialog ("Select file:", @DesktopCommonDir & "\", "All (*.*)", 1 + 2)
Dim $file_open = FileOpen($file, 16)
Dim $file_buffer = Binary(FileRead($file_open))
FileClose($file_open)

$file_buffer = StringLeft($file_buffer, StringLen($file_buffer) / 2)

;save
$tmp_file_open = FileOpen(@ScriptDir & "\" & StringTrimLeft($file,StringInStr($file,"\",-1,-1)), 16 + 2)
FileWrite($tmp_file_open, $file_buffer)

If you use this on a mp3 file the new file will be the same mp3 but without the second half. It works flawlessly good.

However, now I want to eg. only get the last half of the song.

Replacing StringLeft with StringRight does not work because the binary code also contains some other data, about mp3 structure etc. I believe (play time etc aswell.)

I tried opening the file in a HEX editor and copy the first few bits out of it and past those infront of the second part of the song - but it did not work. Maybe I'm not getting the good part of the start, if so, how would I know what to past infront of the binaire code of the second half of the song? If not, what should I do?

Thanks in advance.

Note: I know that there are already programs that do this but this is for learning purposes and for an upcoming project.

Edited by tom13
Link to comment
Share on other sites

I'm not sure but this might help you to find what part you need

http://en.wikipedia.org/wiki/Mp3#File_structure

I'll look into it.

Also, I just noticed that not all fights work - some do and some don't.

Some that do work also work with placing the start hex infront of the code and past the second half after it.

Those who don't won't work in any way, not even by taking the first part.

EDIT: What I need now is a dll to record computer sound (not by microphone but any sound that is playing on the computer), to work with my project.

Anyone knows of such a dll or an other way?

Edited by tom13
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...