I am creating a video editing application. I have created an ObservableCollection which contains information regarding every frame, 30 per second. I have computed the DateTime per frame as VideoCreationDate + FrameNumber / 29.97. When I display the current time and date with a TextBlock overlaying each frame, the time is perfectly accurate. However, once I convert the date time to Unix time and use it as parameters in the FFMPEG DrawText filter, the time is slightly off. The first few frames are accurate and progressively get worse off the more I scrub through the frames. I am checking the Unix timestamp on each frame and it is correct but for some reason, when I render the FFMPEG command, it converts the timestamp to date time inaccurately.
Below is the method to convert DateTime to Unix:
public long ToUnixTimestamp(DateTime value)
{
var dateTimeOffset = new DateTimeOffset(value);
var unixDateTime = dateTimeOffset.ToUnixTimeSeconds();
Debug.WriteLine(unixDateTime);
return unixDateTime;
}
Below is part of the FFMPEG string containing the DrawText filter:
drawtext=text=\'%{pts\:localtime\:" + ToUnixTimestamp(CurrentFrame.FrameTime) + @"\:'%#I\:%M%p'}\'
I am not sure if I am doing something wrong or if this is a flaw with FFMPEG. Any ideas?