How can I get millisecond resolution on file duration with the command >ffmpeg -v quiet -stats -i file.mp3 -f null –
In my application, for an mp3 file that is downloaded, I need to get a duration that is accurate to the millisecond. My application does not allow for the entire file to be decompressed and stored. If I get the file duration using ffprobe, I get the the resolution I need, but the duration does not match what I get when the file is converted to a .wav file. If I decompress without saving to get the duration, it only displays the seconds to hundredths of seconds. Why the discrepancy in resolution? Is there a way to get ffmpeg to show the time to the millisecond when decompressing but not writing?
Here’s the output from >ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 myfile.mp3
30.171429
Here’s the output from ffmpeg -v quiet -stats -i myfile.mp3 -f null –
size=N/A time=00:00:30.11 bitrate=N/A speed= 576x
As you can see, they don’t match and the resolution is different.
When I do an ffprobe on the resulting wav file, the size matches what I get from the ffmpeg command (to 2 decimal places) and it also matches the size in the wav file header.
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 myfile.wav
30.110635
Read more here: Source link
