/// <summary> /// Create an indexer of a media file /// </summary> /// <remarks> /// <para>In FFMS2, the equivalent is <c>FFMS_CreateIndexer</c> or <c>FFMS_CreateIndexerWithDemuxer</c>.</para> /// <para>The chosen demuxer gets used for both indexing and decoding later on. Only force one if you know what you're doing.</para> /// <para>Picking a demuxer that doesn't work on your file will not cause automatic fallback on lavf or automatic probing; it'll just cause indexer creation to fail.</para> /// </remarks> /// <param name="sourceFile">The media file</param> /// <param name="demuxer">What demuxer to use</param> /// <exception cref="System.IO.FileLoadException">Failure to load the media file</exception> public Indexer(string sourceFile, Source demuxer = Source.Default) { if (sourceFile == null) { throw new ArgumentNullException(@"sourceFile"); } var err = new FFMS_ErrorInfo { BufferSize = 1024, Buffer = new String((char)0, 1024) }; byte[] sourceFileBytes = Encoding.UTF8.GetBytes(sourceFile); _handle = NativeMethods.FFMS_CreateIndexerWithDemuxer(sourceFileBytes, (int)demuxer, ref err); if (!_handle.IsInvalid) { return; } if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_READ) { throw new System.IO.FileLoadException(err.Buffer); } throw new NotImplementedException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Unknown FFMS2 error encountered: ({0}, {1}, '{2}'). Please report this issue on FFMSSharp's GitHub.", err.ErrorType, err.SubType, err.Buffer)); }
public static extern SafeIndexHandle FFMS_DoIndexing(SafeIndexerHandle Indexer, int IndexMask, int DumpMask, TAudioNameCallback ANC, [MarshalAs(UnmanagedType.LPStr)] string ANCPrivate, int ErrorHandling, TIndexCallback IC, IntPtr ICPrivate, ref FFMS_ErrorInfo ErrorInfo);
public static extern IntPtr FFMS_GetFormatNameI(SafeIndexerHandle Indexer);
public static extern IntPtr FFMS_GetCodecNameI(SafeIndexerHandle Indexer, int Track);
public static extern int FFMS_GetTrackTypeI(SafeIndexerHandle Indexer, int Track);
public static extern int FFMS_GetNumTracksI(SafeIndexerHandle Indexer);
public static extern int FFMS_GetSourceTypeI(SafeIndexerHandle Indexer);
/// <summary> /// Create an indexer of a media file /// </summary> /// <remarks> /// <para>In FFMS2, the equivalent is <c>FFMS_CreateIndexer</c> or <c>FFMS_CreateIndexerWithDemuxer</c>.</para> /// <para>The chosen demuxer gets used for both indexing and decoding later on. Only force one if you know what you're doing.</para> /// <para>Picking a demuxer that doesn't work on your file will not cause automatic fallback on lavf or automatic probing; it'll just cause indexer creation to fail.</para> /// </remarks> /// <param name="sourceFile">The media file</param> /// <param name="demuxer">What demuxer to use</param> /// <exception cref="System.IO.FileLoadException">Failure to load the media file</exception> public Indexer(string sourceFile, Source demuxer = Source.Default) { if (sourceFile == null) throw new ArgumentNullException(@"sourceFile"); var err = new FFMS_ErrorInfo { BufferSize = 1024, Buffer = new String((char) 0, 1024) }; byte[] sourceFileBytes = Encoding.UTF8.GetBytes(sourceFile); _handle = NativeMethods.FFMS_CreateIndexerWithDemuxer(sourceFileBytes, (int)demuxer, ref err); if (!_handle.IsInvalid) return; if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_READ) throw new System.IO.FileLoadException(err.Buffer); throw new NotImplementedException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Unknown FFMS2 error encountered: ({0}, {1}, '{2}'). Please report this issue on FFMSSharp's GitHub.", err.ErrorType, err.SubType, err.Buffer)); }