dump_seekindex.c 958 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. dump_seekindex: Scan a mpeg file and dump its seek index.
  3. copyright 2010 by the mpg123 project - free software under the terms of the LGPL 2.1
  4. see COPYING and AUTHORS files in distribution or http://mpg123.org
  5. initially written by Patrick Dehne
  6. */
  7. #include <mpg123.h>
  8. #include <stdio.h>
  9. int main(int argc, char **argv)
  10. {
  11. mpg123_handle *m;
  12. off_t* offsets;
  13. off_t step;
  14. size_t fill, i;
  15. if(argc != 2)
  16. {
  17. fprintf(stderr, "\nI will dump the frame index of an MPEG audio file.\n");
  18. fprintf(stderr, "\nUsage: %s <mpeg audio file>\n\n", argv[0]);
  19. return -1;
  20. }
  21. mpg123_init();
  22. m = mpg123_new(NULL, NULL);
  23. mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0);
  24. mpg123_param(m, MPG123_INDEX_SIZE, -1, 0);
  25. mpg123_open(m, argv[1]);
  26. mpg123_scan(m);
  27. mpg123_index(m, &offsets, &step, &fill);
  28. for(i=0; i<fill;i++) {
  29. printf("Frame number %d: file offset %d\n", i * step, offsets[i]);
  30. }
  31. mpg123_close(m);
  32. mpg123_delete(m);
  33. mpg123_exit();
  34. return 0;
  35. }