ghettorecorder package
Submodules
ghettorecorder.audio_conf module
ghettorecorder.cmd module
ghettorecorder.ghetto_agents module
ghettorecorder.ghetto_api module
ghettorecorder.ghetto_blacklist module
ghettorecorder.ghetto_container module
ghettorecorder.ghetto_db_worker module
ghettorecorder.ghetto_header_aac module
ghettorecorder.ghetto_header_mp3 module
Output is human-readable. Non-destructive. Use as input for further mp3 stream processing.
Feed streaming web server with file system sound files. Needs bitrate per second, else browser hangs.
http://www.mp3-tech.org/programmer/frame_header.html
Bytes
1
2
3
4
5
6
AAAAAAAA
AAABBCCD
EEEEFFGH
IIJJKLMM
OOOOOOOO
OOOOOOOO
Bit Groups
Group
Number
Count
Description
A
0-11
11
Syncword, all bits 1
B
12-13
2
[00 = MPEG Version 2.5] [01 = reserved] [10 = MPEG Version 2] [11 = MPEG Version 1]
C
14-15
2
Layer [00 = reserviert] [01 = Layer III] [10 = Layer II] [11 = Layer I]
D
16
1
[[[
Warning]]], set to 1 if there is no CRC and 0 if there is CRCE
17-20
4
Bitrate index table, Version and layer read the table
F
21-22
2
Sampling rate frequency index
G
23
1
Padding bit [0 - frame is not padded] [1 - frame is padded with one extra slot]
H
24
1
Private bit. This one is only informative.
I
25-26
2
Channel Mode [00 - Stereo] [01 - Joint stereo] [10 - Dual] [11 - Single (Mono)]
J
27-28
2
Mode extension (Only used in Joint stereo)
K
29
1
Copyright ID bit
L
30
1
Original [0 - Copy of original media] [1 - Original media]
M
31-32
2
Emphasis [00 - none] [01 - 50/15 ms] [10 - reserved] [11 - CCIT J.17]
O
33-48
16
CRC if existing, D 16 set
frame length layer 1: FrameLengthInBytes = (12 * BitRate / SampleRate + Padding) * 4 frame length layer 2: FrameLengthInBytes = 144 * BitRate / SampleRate + Padding
The next line is C code:
//*************************************************************************************
// This reference data is from MPEGAudioInfo app
// Samples per Frame / 8
static const u32 m_dwCoefficients[2][3] =
{
{ // MPEG 1
12, // Layer1 (must be multiplied with 4, because of slot size)
144, // Layer2
144 // Layer3
},
{ // MPEG 2, 2.5
12, // Layer1 (must be multiplied with 4, because of slot size)
144, // Layer2
72 // Layer3
}
};
- class ghettorecorder.ghetto_header_mp3.Mp3Header(file)
Bases:
objectFind bitrate in header. ‘br_dict’ list with most votes wins.
__init__(self, file)
- Param:
file: # can be path string
- bitrate_get()
Looking for the first bits of mp3 header. Search sync_word. Second byte of word has only 3bit information. Mask and bit-shift.
- Returns:
bitrate int, or None
- bitrate_get_from_dict()
Calculate the bitrate from dict. We have defective Header and intersections of unknown. Key bitrate with most votes wins.
- Returns:
bitrate of file like obj, else None
- bitrate_one_frame_get(mp3_object)
Extract bitrate via bit shift and mask into ‘br_dict’. Bit Groups listed in module’s docString. and(ing) 11… bits, move resulting bits right and calculate
- mp3_object_to_bytes()
Convert path to file like object, if path, else it is bytes object
- ghettorecorder.ghetto_header_mp3.main(path_str=None)
Example to get the bitrate.
- Param:
path_str: file path or object