Skip to content

Commit

Permalink
finalize by adding find_frame_return_info
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Jan 31, 2024
1 parent 9d66abe commit ee4a094
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 90 deletions.
18 changes: 10 additions & 8 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ METHODS
MP3: mp3, mp2
MP4: mp4, m4a, m4b, m4p, m4v, m4r, k3g, skm, 3gp, 3g2, mov
AAC (ADTS): aac
Ogg: ogg, oga
FLAC: flc, flac, fla
Ogg: ogg, oga, ogf
FLAC: flc, flac, fla, ogf
ASF: wma, wmv, asf
Musepack: mpc, mpp, mp+
Monkey's Audio: ape, apl
Expand Down Expand Up @@ -95,15 +95,16 @@ METHODS
WAV, AIFF, Musepack, Monkey's Audio, WavPack
Not yet supported by find_frame.

find_frame_return_info( $mp4_path, $timestamp_in_ms )
The header of an MP4 file contains various metadata that refers to the
find_frame_return_info( $path, $timestamp_in_ms )
The header of an MP4 or OggFlac file contains various metadata that refers to the
structure of the audio data, making seeking more difficult to perform.
This method will return the usual $info hash with 2 additional keys:

seek_offset - The seek offset in bytes
seek_header - A rewritten MP4 header that can be prepended to the audio data
found at seek_offset to construct a valid bitstream. Specifically,
the following boxes are rewritten: stts, stsc, stsz, stco
seek_header - A rewritten MP4/OggFlac header that can be prepended to the audio data
found at seek_offset to construct a valid bitstream. Specifically, for MP4
the following boxes are rewritten: stts, stsc, stsz, stco. For FLAC, the
number of samples and md5 in STREAMINFO are zero'd

For example, to seek 30 seconds into a file and write out a new MP4 file
seeked to this point:
Expand Down Expand Up @@ -332,13 +333,14 @@ OGG VORBIS
TAGS
Raw Vorbis comments are returned. All comment keys are capitalized.

FLAC
FLAC or OggFLAC
INFO
The following metadata about a file is returned:

channels
samplerate (in kHz)
bitrate (in bps)
bitrage_ogg (in bps, calculate from ogg frames)
file_size
audio_offset (byte offset to first audio frame)
audio_size
Expand Down
2 changes: 1 addition & 1 deletion Scan.xs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static taghandler taghandlers[] = {
{ "aac", get_aacinfo, 0, 0, 0 },
{ "mp3", get_mp3tags, get_mp3fileinfo, mp3_find_frame, 0 },
{ "ogg", get_ogg_metadata, 0, ogg_find_frame, 0 },
{ "ogf", get_ogf_metadata, 0, ogf_find_frame, 0 },
{ "ogf", get_ogf_metadata, 0, ogf_find_frame, ogf_find_frame_return_info },
{ "opus", get_opus_metadata, 0, opus_find_frame, 0 },
{ "mpc", get_ape_metadata, get_mpcfileinfo, 0, 0 },
{ "ape", get_ape_metadata, get_macfileinfo, 0, 0 },
Expand Down
7 changes: 5 additions & 2 deletions include/ogf.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
*/

int get_ogf_metadata(PerlIO *infile, char *file, HV *info, HV *tags);
int _ogf_parse(PerlIO *infile, char *file, HV *info, HV *tags, uint8_t seeking);
static int ogf_find_frame(PerlIO *infile, char *file, int offset);
int ogf_find_frame_return_info(PerlIO *infile, char *file, int offset, HV *info);
int ogf_find_frame(PerlIO *infile, char *file, int offset);

static int _ogf_parse(PerlIO *infile, char *file, HV *info, HV *tags, uint8_t seeking);
static int _ogf_find_frame(PerlIO *infile, char *file, int offset, HV *info, HV *tags);
11 changes: 6 additions & 5 deletions lib/Audio/Scan.pm
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,17 @@ Not yet supported by find_frame.
=back
=head2 find_frame_return_info( $mp4_path, $timestamp_in_ms )
=head2 find_frame_return_info( $path, $timestamp_in_ms )
The header of an MP4 file contains various metadata that refers to the structure of
The header of an MP4/OggFlac file contains various metadata that refers to the structure of
the audio data, making seeking more difficult to perform. This method will return
the usual $info hash with 2 additional keys:
seek_offset - The seek offset in bytes
seek_header - A rewritten MP4 header that can be prepended to the audio data
found at seek_offset to construct a valid bitstream. Specifically,
the following boxes are rewritten: stts, stsc, stsz, stco
seek_header - A rewritten MP4/OggFlac header that can be prepended to the audio data
found at seek_offset to construct a valid bitstream. Specifically, for MP4
the following boxes are rewritten: stts, stsc, stsz, stco. For FLAC, the
number of samples and md5 in STREAMINFO are zero'd
For example, to seek 30 seconds into a file and write out a new MP4 file seeked to
this point:
Expand Down
Loading

0 comments on commit ee4a094

Please sign in to comment.