OSDN Git Service

#42987 Fixed failing to seek the tail of mp4 video (by using DTXCreator + DTXMania...
authoryyagi <yyagi.dtxmania@gmail.com>
Mon, 4 Oct 2021 16:06:59 +0000 (01:06 +0900)
committeryyagi <yyagi.dtxmania@gmail.com>
Mon, 4 Oct 2021 16:06:59 +0000 (01:06 +0900)
FDK/コード/04.グラフィック/CAviDS.cs

index 3609ddc..14f02dc 100644 (file)
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
 using System.Runtime.InteropServices;
 using DirectShowLib;
 using SharpDX;
+using System.Diagnostics;
 
 namespace FDK
 {
@@ -142,8 +143,11 @@ namespace FDK
 
                public void Seek(int timeInMs)
                {
-                       int hr = seeker.SetPositions(new DsLong(timeInMs * 10000), AMSeekingSeekingFlags.AbsolutePositioning, null, AMSeekingSeekingFlags.NoPositioning);
-                       DsError.ThrowExceptionForHR(hr);
+                       int hr = seeker.SetPositions( DsLong.FromInt64((long)(timeInMs * 10000)), AMSeekingSeekingFlags.AbsolutePositioning, null, AMSeekingSeekingFlags.NoPositioning);
+                       if ( (uint)hr != 0x80070057 )   // E_INVALIDARG. It tend to occur in seeking to the tail-part in mp4 file. Even if we ignore the error, the seek seems success,
+                       {
+                               DsError.ThrowExceptionForHR(hr);
+                       }
                        hr = control.GetState(timeOutMs, out state); // state is Running
                        DsError.ThrowExceptionForHR(hr);
                }