MediaInfo.CreationTime property does not contain date
Dylrak opened this issue · comments
Issue
When a media file specifies both a date and a creation_time, the MediaInfo.CreationTime property ignores the date tag, instead being set to DateTime.Now plus the creation time.
Let's say that ffprobe E:\input.wav
yields the following result:
date : 2016-03-31
creation_time : 10:15:35
Using Xabe.FFMPEG as follows:
IMediaInfo mediaInfo = await FFmpeg.GetMediaInfo("E:\input.wav");
will set mediaInfo.CreationTime
to {01/15/2024 10:15:35}
.
Suggested Fix
In FFprobeWrapper.SetProperties()
, change creation_time to a TimeSpan and attempt to parse the date as well, adding them to each other. If only creation_time is specified, the old behaviour is kept:
if (!string.IsNullOrWhiteSpace(infos.format.tags?.creation_time) && TimeSpan.TryParse(infos.format.tags.creation_time, out var creationTime))
{
mediaInfo.CreationTime = !string.IsNullOrWhiteSpace(infos.format.tags?.date) && DateTime.TryParse(infos.format.tags.date, out var date)
? date.Add(creationTime)
: DateTime.Now.Add(creationTime);
}