Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaInfo.CreationTime property does not contain date #474

Open
Dylrak opened this issue Jan 15, 2024 · 0 comments
Open

MediaInfo.CreationTime property does not contain date #474

Dylrak opened this issue Jan 15, 2024 · 0 comments

Comments

@Dylrak
Copy link

Dylrak commented Jan 15, 2024

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant