How to convert an mp3 file into binary and its reverse
20 views (last 30 days)
Show older comments
How to convert an mp3 file into binary and its reverse
2 Comments
ola lawson
on 16 Apr 2017
Would it be possible to explain the reverse method, finding it difficult to convert it back into mp3 file
Walter Roberson
on 16 Apr 2017
fid = fopen('OutputFile.mp3', 'w');
fwrite(fid, TheVectorOfUint8);
fclose(fid);
Answers (1)
Walter Roberson
on 15 Mar 2016
mp3_content = uint8( fileread('YourFile.mp3') );
The exact contents of the file are now a series of 8 bit unsigned integers, which you can process as usual, such as with dec2bin().
In the reverse side, once you have a vector of 8 bit unsigned integers,
fid = fopen('OutputFile.mp3', 'w');
fwrite(fid, TheVectorOfUint8);
fclose(fid);
and now OutputFile.mp3 will be the same contents as the original .mp3 file.
2 Comments
Walter Roberson
on 26 Jan 2017
fid = fopen('YourFile.mp3', 'r');
mp3_content = fread(fid, [1 inf], '*uint8');
fclose(fid);
fid = fopen('OutputFile.mp3', 'w');
fwrite(fid, TheVectorOfUint8);
fclose(fid);
The two files should be the same.
See Also
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!