0

I am trying to make a simple av player, and in some cases I am getting values correctly as below:

checking /media/timecapsule/Music/02 Baawre.mp3
[mp3 @ 0x7f0698005660] Skipping 0 bytes of junk at 2102699.
dur is 4396400640
duration is 311

However, in other places, I am getting negative durations:

checking /media/timecapsule/Music/01 Just Chill.mp3
[mp3 @ 0x7f0694005f20] Skipping 0 bytes of junk at 1318922.
dur is -9223372036854775808
duration is -653583619391

I am not sure what's causing the duration to end up negative only in some audio files. Any ideas to where I might be wrong are welcome!

Source code here https://github.com/heroic/musika/blob/master/player/library.c

Amit
  • 3,952
  • 7
  • 46
  • 80

1 Answers1

0

I would suggest two things: 1. Make sure that failed files are not corrupt, i.e. you can use ffmpeg command line tool to dump details. 2. Break this in 2 if conditions to avoid order of operation and ensure open succeeded. if(!(avformat_open_input(&container, name, NULL, NULL) < 0 && avformat_find_stream_info(container, NULL) < 0)) {

Also you can use av_dump_format to ensure that it headers are correct. See ex - https://www.ffmpeg.org/doxygen/2.8/avio_reading_8c-example.html#a24

Ketan

Ketan
  • 1,017
  • 8
  • 17