1
0
mirror of http://mpg123.de/trunk/.git synced 2025-07-03 11:22:31 +03:00
Files
mpg123/doc/examples/dump_seekindex.c
thor c4b7f976ea examples: update for mpg123_init() and sensible copyright
git-svn-id: svn://scm.orgis.org/mpg123/trunk@4831 35dc7657-300d-0410-a2e5-dc2837fedb53
2021-04-12 06:01:39 +00:00

45 lines
1.1 KiB
C

/*
dump_seekindex: Scan a mpeg file and dump its seek index.
This is example code only sensible to be considered in the public domain.
Initially written by Patrick Dehne.
*/
#include <mpg123.h>
#include <stdio.h>
#include <inttypes.h>
int main(int argc, char **argv)
{
mpg123_handle *m;
off_t* offsets;
off_t step;
size_t fill, i;
if(argc != 2)
{
fprintf(stderr, "\nI will dump the frame index of an MPEG audio file.\n");
fprintf(stderr, "\nUsage: %s <mpeg audio file>\n\n", argv[0]);
return -1;
}
#if MPG123_API_VERSION < 46
// Newer versions of the library don't need that anymore, but it is safe
// to have the no-op call present for compatibility with old versions.
mpg123_init();
#endif
m = mpg123_new(NULL, NULL);
mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0);
mpg123_param(m, MPG123_INDEX_SIZE, -1, 0);
mpg123_open(m, argv[1]);
mpg123_scan(m);
mpg123_index(m, &offsets, &step, &fill);
for(i=0; i<fill;i++) {
printf("Frame number %"PRIiMAX": file offset %"PRIiMAX"\n", (intmax_t)(i * step), (intmax_t)offsets[i]);
}
mpg123_close(m);
mpg123_delete(m);
return 0;
}