How to detect the specified part in a MP3 file? - mp3

I have more than 600 MP3 files, I just want to listen a part of each MP3 file. I know some MP3 cutter tools can do this job manually. Repeating the similar job more than 600+ times via MP3 cutter tool, that must be a very very boring and hard thing. So I need to write a program to finish this job automatically.
The specified part in each MP3 file have the almost same start/end part (5~8 seconds), if I can write a program to detect the start point and the end point, my question is nearly to be resolved.
PS:
1) All the MP3 files are English learning podcast.
2) C or JAVA solution is prefered
Thanks
I find the specified part time was already listed in MP3 metadata, so my problem is resolved:
1) Read MP3 metadata, get the start time and end time, thanks to https://stackoverflow.com/a/21746702/3367812
2) cut MP3 file, thanks to https://stackoverflow.com/a/10056024/3367812

This has been asked in several places.
You can follow this answer, which shows how to cut a wave file, to come up with your own program.
cutting a wave file

Related

Is it possible to continue bzip2 decompressing?

Long story short: I have big (700+ GB) .tar.bz2 archive and I wanted to decompress it. It is stored on very slow HDD, so it took my computer about 110 hours nonstop working to get 92% of data. But then I accidentally close the terminal with unarchiving process.
If decompressing process was stopped can it continue from the breakpoint or skip already unzipped files or skip some offset?
Yes, it is possible in principle since a bzip2 file consists of independent blocks, each of which starts with a specific marker that you can search for. Also a tar file consists of independent blocks for each file, for which you should be able to find headers on some 512-byte boundaries.
You would need to write your own code to poke around and try to find out where you left off, assuming you know what the last file extracted was. Then you could continue to decompress from there.

concatenate files in libffmpeg c++

i'm a bit at loss here. My goal is to merge two video files (which might be of different file formats) and i'm already using libffmpeg for other simple tasks. I thought libffmpeg exposed some kind of function to merge files, but i can't find it.
I found these pages on the documentation that might be relevant: http://ffmpeg.org/doxygen/trunk/structConcatStream.html and http://ffmpeg.org/doxygen/trunk/group__lavf__encoding.html
I'm not sure if this is really relevant though? Can anybody point me in the right direction? Do i need to use FFmpeg muxing and manually joins streams? Is there any example that can explain to me what i should do? thanks!
For those looking for an example, i ended up using
How to use libavformat to concat 2 video files with same codec (re-muxing)?
there's a nice snippet and it works very well
Use ffmpeg to open file 1, start reading frames, converting to target format, and writing to the output file. When there are no more frames, close file 1 (leave output open). Open file 2, start reading frames, converting to target format, and writing to the output file. When there are no more frames, close file 2 and close output.
Merged and formats reconciled.

How do you code into an mp3 file?

I'm interested in creating a drm type program. I want to put code into an mp3 file that checks online to see if it is licensed out. The online aspect is not something I'm concerned with at the moment, but I've looked online for some resource on doing this, but I've found nothing really that useful. There are people talking about viruses, but I want this to be intentional and not malicious. Simply when you play the the mp3 it quickly checks online to see if the license is actually allowed to play. If it is it plays if it isn't it gives an error and says either you need to log on or buy the song.
I'm pretty sure this is impossible. mp3 files can't contain executable code. They could contain byte data that could represent code, but the mp3 player would need to interpret it as such and execute it instead of trying to play it as music, which no player does. You would have to program your own player to do this, but since there's no way to constrain an mp3 file to only one player (again, because they can't contain code), you'd have to create your own competing standard. Further, there would be nothing preventing someone from converting this mp3 to a normal non-constrained mp3 and sharing it.
From a less technical standpoint, as a user (who despises DRM) it would irk me to no end if an mp3 was checking up on whether I was "allowed" to have it, and even more so if I was required to be online in order to listen to it, to the point that I would just delete it and never buy/download/steal anything in that format again.
(Does this count as an answer? It was too long for a comment.)
Its surely possible but very difficult. Im not very experienced in coding but using discord i was able to turn an mp3 file into a txt file, But the problem is that it becomes strange characters

Library for extracting zip on the fly

I have a rather large ZIP file, which gets downloaded (cannot change the file). The quest now is to unzip the file while it is downloading instead of having to wait till the central directory end is received.
Does such a library exist?
I wrote "pinch" a while back. It's in Objective-C but the method to decode files from a zip might be a way to get it in C++? Yeah, some coding will be necessary.
http://forrst.com/posts/Now_in_ObjC_Pinch_Retrieve_a_file_from_inside-I54
https://github.com/epatel/pinch-objc
I'm not sure such a library exists. Unless you are on a very fast line [or have a very slow processor], it's unlikely to save you a huge amount of time. Decompressing several gigabytes only takes a few seconds if all the data is in ram [it may then take a while to write the uncompressed data to the disk, and loading it from the disk may add to the total time].
However, assuming the sending end supports "range" downloading, you could possibly write something that downloads the directory first [by reading the fixed header first, then reading the directory and then downloading the rest of the file from start to finish]. Presumably that's how "pinch" linked in epatel's answer works.

How to write mp3 frames from PCM data (C/C++)?

How to write mp3 frames (not full mp3 files with ID3 etc) from PCM data?
I have something like PCM data (for ex 100mb) I want to create an array of mp3 frames from that data. How to perform such operation? (for ex with lame or any other opensource encoder)
What do I need:
Open Source Libs for encoding.
Tutorials and blog articles on How to do it, about etc.
You should be able to use LAME. It has a -t command line switch that turns off the INFO header in the output (otherwise present in frame 0). If that still leaves too much bookkeeping data, you should be able to write a separate tool to strip that away.
You are already on the right track: use LAME external executable, or any other shell-invoked encoder.
To build MP frames, were your layer of interest is 3, is not easy to do from scratch. There are compression steps, Fast-fourier transforms followed by quantization, which are of complex and tediously long explanation. The amount of work required for a developer to build it from scratch is very big.
There are programmatic C and C++ MP encoding libs, but you will be either asked for fees, be left with very limited support, or have very limited interfacing options.
Go LAME, study their wiki.