As I know a mp4 media file size, how could i calculate the file duration through file size? (C#)
Thanks.
As I know a mp4 media file size, how could i calculate the file duration through file size? (C#)
Thanks.
You may look at ID3 Metadata Tags in the file. You should use TagLib Sharp for read ID3 tags from mp3/mp4 files.
I use the NReco.VideoInfo library to achieve this very easily. It's a simple as giving the library a file path and it spits out the metadata:
var ffProbe = new FFProbe();
var videoInfo = ffProbe.GetMediaInfo(blob.Uri.AbsoluteUri);
return videoInfo.Duration.TotalMilliseconds;
Reading this: https://web.archive.org/web/20121130070329/http://neuron2.net/LVG/ratesandsizes.html I think perhaps you can approximately solve the number of seconds from the equation presented in the section Calculating the File Size of a Bitrate-Based Format using the metadata from the file.
Edit: URL changed as a suggestion by @BrentRittenhouse.