My iPhone app uses FFMPeg for decoding/playing an audio file.
I’m successfully getting the current time in microseconds from the appropriate FFMPeg function, but I’m not being able to convert it to minutes and seconds (MM:SS).
This is my code to display an NSString containing the time; getFFMPEGtime is the time in microseconds:
self.currentAudioTime = [NSString stringWithFormat: @"%02d:%02d",
(int) getFFMPEGtime / (int)1000000,
(int) getFFMPEGtime % 1000000];
It seems that the time in minutes is okay, but the seconds are messed up. What’s the proper way to convert microseconds to minutes and seconds?
I’d argue that your time in seconds is probably right and your time in minutes is most likely wrong.
(int) getFFMPEGtime / (int)1000000is giving you total secondsTo get
MM:SS, you need to do the following: