diff --git a/FFMSsharp.sln b/FFMSSharp.sln similarity index 82% rename from FFMSsharp.sln rename to FFMSSharp.sln index 17c93a2..e781efd 100644 --- a/FFMSsharp.sln +++ b/FFMSSharp.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.30110.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFMSsharp", "FFMSsharp\FFMSsharp.csproj", "{303CA7DC-1B7E-45BE-9A90-A37D72CE4791}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFMSSharp", "FFMSsharp\FFMSSharp.csproj", "{303CA7DC-1B7E-45BE-9A90-A37D72CE4791}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFMSsharp.Tests", "FFMSsharp.Tests\FFMSsharp.Tests.csproj", "{04F8F954-CEF5-4E80-B134-68C99584B338}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFMSSharp.Tests", "FFMSsharp.Tests\FFMSSharp.Tests.csproj", "{04F8F954-CEF5-4E80-B134-68C99584B338}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/FFMSsharp.Tests/FFMSsharp.Tests.csproj b/FFMSsharp.Tests/FFMSsharp.Tests.csproj index e86dfe3..0060033 100644 --- a/FFMSsharp.Tests/FFMSsharp.Tests.csproj +++ b/FFMSsharp.Tests/FFMSsharp.Tests.csproj @@ -57,9 +57,9 @@ - + {303ca7dc-1b7e-45be-9a90-a37d72ce4791} - FFMSsharp + FFMSSharp diff --git a/FFMSsharp.Tests/UnitTest1.cs b/FFMSsharp.Tests/UnitTest1.cs index 80ee14c..d468d0b 100644 --- a/FFMSsharp.Tests/UnitTest1.cs +++ b/FFMSsharp.Tests/UnitTest1.cs @@ -1,6 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using FFMSsharp; +using FFMSSharp; using System.Drawing; using System.Collections.Generic; using System.IO; @@ -41,7 +41,7 @@ public void IndexerMatroska() Indexer indexer = new Indexer("h264_720p_hp_5.1_3mbps_vorbis_styled_and_unstyled_subs_suzumiya.mkv"); Assert.AreEqual(5, indexer.NumberOfTracks); - Assert.AreEqual(FFMSsharp.TrackType.Video, indexer.GetTrackType(0)); + Assert.AreEqual(FFMSSharp.TrackType.Video, indexer.GetTrackType(0)); Assert.AreEqual("matroska", indexer.FormatName); Assert.AreEqual("h264", indexer.GetCodecName(0)); } diff --git a/FFMSsharp/AudioSource.cs b/FFMSsharp/AudioSource.cs index e279ec2..67a6f77 100644 --- a/FFMSsharp/AudioSource.cs +++ b/FFMSsharp/AudioSource.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace FFMSsharp +namespace FFMSSharp { #region Interop @@ -325,7 +325,7 @@ public double FirstTime public double LastTime { get { return AP.LastTime; } } - FFMSsharp.Track track; + FFMSSharp.Track track; /// /// Retrieves track info /// @@ -342,7 +342,7 @@ public Track Track { IntPtr trackPtr = IntPtr.Zero; trackPtr = NativeMethods.FFMS_GetTrackFromAudio(FFMS_AudioSource); - track = new FFMSsharp.Track(trackPtr); + track = new FFMSSharp.Track(trackPtr); } return track; } @@ -416,7 +416,7 @@ public byte[] GetAudio(long start, long count) if (err.ErrorType == FFMS_Errors.FFMS_ERROR_SEEKING && err.SubType == FFMS_Errors.FFMS_ERROR_CODEC) throw new NotSupportedException(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)); + 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)); } return buffer; diff --git a/FFMSsharp/CustomDictionary.xml b/FFMSsharp/CustomDictionary.xml new file mode 100644 index 0000000..e7f4535 --- /dev/null +++ b/FFMSsharp/CustomDictionary.xml @@ -0,0 +1,17 @@ + + + + FFMS2 + GitHub + timecode + timecodes + demuxer + FFMSSharp's + + + + + FFMS + + + \ No newline at end of file diff --git a/FFMSsharp/FFMS.cs b/FFMSsharp/FFMS.cs index 11d886b..ae0d387 100644 --- a/FFMSsharp/FFMS.cs +++ b/FFMSsharp/FFMS.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; [assembly: CLSCompliant(false)] -namespace FFMSsharp +namespace FFMSSharp { #region Interop diff --git a/FFMSsharp/FFMSsharp.csproj b/FFMSsharp/FFMSsharp.csproj index 3d9274d..a91eb8e 100644 --- a/FFMSsharp/FFMSsharp.csproj +++ b/FFMSsharp/FFMSsharp.csproj @@ -7,8 +7,8 @@ {303CA7DC-1B7E-45BE-9A90-A37D72CE4791} Library Properties - FFMSsharp - FFMSsharp + FFMSSharp + FFMSSharp v4.0 512 Client @@ -55,6 +55,9 @@ + + + @@ -1303,7 +1303,7 @@ In FFMS2, the equivalent is FFMS_RESIZERS_BICUBLIN. - + Gauss @@ -1311,7 +1311,7 @@ In FFMS2, the equivalent is FFMS_RESIZERS_GAUSS. - + Sinc @@ -1319,7 +1319,7 @@ In FFMS2, the equivalent is FFMS_RESIZERS_SINC. - + Lanczos @@ -1327,7 +1327,7 @@ In FFMS2, the equivalent is FFMS_RESIZERS_LANCZOS. - + Spline @@ -1335,17 +1335,17 @@ In FFMS2, the equivalent is FFMS_RESIZERS_SPLINE. - + Video source In FFMS2, the equivalent is FFMS_VideoSource. - See Index.VideoSource on how to create a VideoSource object. - Note that there is no equivalent for FFMS2's FFMS_GetVideoProperties as it is called during construction of the VideoSource object. + See Index.VideoSource on how to create a VideoSource object. + Note that there is no equivalent for FFMS2's FFMS_GetVideoProperties as it is called during construction of the VideoSource object. - + Video source destructor @@ -1353,7 +1353,7 @@ In FFMS2, the equivalent is FFMS_DestroyVideoSource. - + Sets the output format for video frames @@ -1362,7 +1362,7 @@ The desired output colorspace(s) The destination that gives the least lossy conversion from the source colorspace will automatically be selected, ON A FRAME BASIS. - To get the integer constant representing a given colorspace, see GetPixFmt. + To get the integer constant representing a given colorspace, see GetPixFmt. The desired image width, in pixels If you do not want to resize just pass the input dimensions. @@ -1373,12 +1373,12 @@ The desired image resizing algorithm. You must choose one even if you're not actually rescaling the image, because the video may change resolution mid-stream and then you will be using a resizer whether you want it or not (you will only know that the resolution changed after you actually decoded a frame with a new resolution), and it may also get used for rescaling subsampled chroma planes. - + Trying to set the desired image resolution to an invalid size like 0, 0. Trying to supply a null list of . Trying to set an invalid output format. - + Resets the video output format @@ -1386,83 +1386,83 @@ In FFMS2, the equivalent is FFMS_ResetOutputFormatV. Resets the output format so that no conversion takes place. Note that the results of this function may vary wildly, particularly if the video changes resolution mid-stream. - If you call it, you'd better call GetFrame afterwards and examine the properties to see what you actually ended up with. + If you call it, you'd better call GetFrame afterwards and examine the properties to see what you actually ended up with. - + Override the source format for video frames In FFMS2, the equivalent is FFMS_SetInputFormatV. - Override the source colorspace passed to SWScale for conversions and resizing for all further calls to GetFrame, until the next time you call SetInputFormat or ResetInputFormat. + Override the source colorspace passed to SWScale for conversions and resizing for all further calls to GetFrame, until the next time you call SetInputFormat or ResetInputFormat. This is intended primarily for compatibility with programs which use the wrong YUV colorspace when converting to or from RGB, but can also be useful for files which have incorrect colorspace flags. Values passed are not checked for sanity; if you wish you may tell FFMS2 to pretend that a RGB files is actually YUV using this function, but doing so is unlikely to have useful results. - This function only has an effect if the output format is also set with SetOutputFormat. + This function only has an effect if the output format is also set with SetOutputFormat. The desired input colorspace The desired input colorrange - + Trying to set an invalid output format. - + Override the source format for video frames In FFMS2, the equivalent is FFMS_SetInputFormatV. - Override the source colorspace passed to SWScale for conversions and resizing for all further calls to GetFrame, until the next time you call SetInputFormat or ResetInputFormat. + Override the source colorspace passed to SWScale for conversions and resizing for all further calls to GetFrame, until the next time you call SetInputFormat or ResetInputFormat. This is intended primarily for compatibility with programs which use the wrong YUV colorspace when converting to or from RGB, but can also be useful for files which have incorrect colorspace flags. Values passed are not checked for sanity; if you wish you may tell FFMS2 to pretend that a RGB files is actually YUV using this function, but doing so is unlikely to have useful results. - This function only has an effect if the output format is also set with SetOutputFormat. + This function only has an effect if the output format is also set with SetOutputFormat. The desired input pixel format The desired input colorspace The desired input colorrange - + Trying to set an insane input format. - + Resets the video input format to the values specified in the source file In FFMS2, the equivalent is FFMS_ResetInputFormatV. - - + + - + Retrieves a video frame In FFMS2, the equivalent is FFMS_GetFrame. - The returned frame is owned by the given VideoSource object, and remains valid until the video source is destroyed, a different frame is requested from the video source, or the video source's input or output format is changed. + The returned frame is owned by the given VideoSource object, and remains valid until the video source is destroyed, a different frame is requested from the video source, or the video source's input or output format is changed. The frame number to get - Frame numbering starts from zero, and hence the first frame is number 0 (not 1) and the last frame is number NumFrames - 1. + Frame numbering starts from zero, and hence the first frame is number 0 (not 1) and the last frame is number NumFrames - 1. - The generated Frame object. - + The generated Frame object. + Trying to access a Frame that doesn't exist. - + Retrieves a video frame at a timestamp In FFMS2, the equivalent is FFMS_GetFrameByTime. - The returned frame is owned by the given VideoSource object, and remains valid until the video source is destroyed, a different frame is requested from the video source, or the video source's input or output format is changed. - Does the exact same thing as GetFrame except instead of giving it a frame number you give it a timestamp in seconds, and it will retrieve the frame that starts closest to that timestamp. + The returned frame is owned by the given VideoSource object, and remains valid until the video source is destroyed, a different frame is requested from the video source, or the video source's input or output format is changed. + Does the exact same thing as GetFrame except instead of giving it a frame number you give it a timestamp in seconds, and it will retrieve the frame that starts closest to that timestamp. This function exists for the people who are too lazy to build and traverse a mapping between frame numbers and timestamps themselves. Timestamp - The generated Frame object. - + The generated Frame object. + Trying to access a Frame that doesn't exist. - + The nominal framerate of the track @@ -1471,11 +1471,11 @@ For Matroska files, this number is based on the average frame duration of all frames, while for everything else it's based on the duration of the first frame. While it might seem tempting to use these values to extrapolate wallclock timestamps for each frame, you really shouldn't do that since it makes your code unable to handle variable framerate properly. The ugly reality is that these values are pretty much only useful for informational purposes; they are only somewhat reliable for antiquated containers like AVI. - Normally they should never be used for practical purposes; generate individual frame timestamps from FrameInfo.PTS instead. + Normally they should never be used for practical purposes; generate individual frame timestamps from FrameInfo.PTS instead. - + - + The nominal framerate of the track @@ -1484,31 +1484,31 @@ For Matroska files, this number is based on the average frame duration of all frames, while for everything else it's based on the duration of the first frame. While it might seem tempting to use these values to extrapolate wallclock timestamps for each frame, you really shouldn't do that since it makes your code unable to handle variable framerate properly. The ugly reality is that these values are pretty much only useful for informational purposes; they are only somewhat reliable for antiquated containers like AVI. - Normally they should never be used for practical purposes; generate individual frame timestamps from FrameInfo.PTS instead. + Normally they should never be used for practical purposes; generate individual frame timestamps from FrameInfo.PTS instead. - + - + The special RFF timebase In FFMS2, the equivalent is FFMS_VideoProperties->RFFNumerator. - - + + - + The special RFF timebase In FFMS2, the equivalent is FFMS_VideoProperties->RFFDenominator. - - + + - + The number of frames in the video track @@ -1516,7 +1516,7 @@ In FFMS2, the equivalent is FFMS_VideoProperties->NumFrames. - + Sample aspect ratio of the video frames @@ -1525,9 +1525,9 @@ Note that this is a metadata setting that you are free to ignore, but if you want the proper display aspect ratio with anamorphic material, you should honor it. On the other hand, there are situations (like when encoding) where you should probably ignore it because the user expects it to be ignored. - + - + Sample aspect ratio of the video frames @@ -1536,18 +1536,18 @@ Note that this is a metadata setting that you are free to ignore, but if you want the proper display aspect ratio with anamorphic material, you should honor it. On the other hand, there are situations (like when encoding) where you should probably ignore it because the user expects it to be ignored. - + - + The number of pixels you should crop the frame before displaying it In FFMS2, the equivalent is FFMS_VideoProperties->CropTop, CropBottom, CropLeft and CropRight. - + - + Is the top field first? @@ -1555,7 +1555,7 @@ In FFMS2, the equivalent is FFMS_VideoProperties->TopFieldFirst. - + The first timestamp of the stream, in seconds @@ -1563,9 +1563,9 @@ In FFMS2, the equivalent is FFMS_VideoProperties->FirstTime. Useful if you want to know if the stream has a delay, or for quickly determining its length in seconds. - + - + The first timestamp of the stream, in seconds @@ -1573,34 +1573,34 @@ In FFMS2, the equivalent is FFMS_VideoProperties->LastTime. Useful if you want to know if the stream has a delay, or for quickly determining its length in seconds. - + - + Retrieves track info In FFMS2, the equivalent is FFMS_GetTrackFromVideo. - It's generally safer to use this instead of Index.GetTrack, since unlike that function it cannot cause access violations if you specified an nonexistent track number, return a Track object that doesn't actually contain any indexing information, or return an object that ceases to be valid when the index is destroyed. - Note that the Track object is only valid until its parent AudioSource object is destroyed. + It's generally safer to use this instead of Index.GetTrack, since unlike that function it cannot cause access violations if you specified an nonexistent track number, return a Track object that doesn't actually contain any indexing information, or return an object that ceases to be valid when the index is destroyed. + Note that the Track object is only valid until its parent AudioSource object is destroyed. - + Log level for libavformat - + No output - + Something went really wrong and we will crash now - + Something went wrong and recovery is not possible @@ -1609,7 +1609,7 @@ on headers or an illegal combination of parameters is used. - + Something went wrong and cannot losslessly be recovered @@ -1617,7 +1617,7 @@ However, not all future data is affected. - + Something somehow does not look correct @@ -1625,52 +1625,52 @@ This may or may not lead to problems. An example would be the use of '-vstrict -2'. - + Show regular information - + Show lots of information - + Stuff which is only useful for libav* developers - + Simple representation of a selection rectangle - + Amount of Top to crop - + Amount of Left to crop - + Amount of Right to crop - + Amount of Bottom to crop - + Container for generic FFMS2 functions - + Initialize the FFMS2 library @@ -1680,27 +1680,27 @@ If you can't (or don't want to) place ffms2.dll in the same directory as your .exe, you may specify a path where you store it. - + Is the source compiled in the library? The source in question The result - + Is the source currently enabled? The source in question The result - + Gets a colorspace identifier from a colorspace name In FFMS2, the equivalent is FFMS_GetPixFmt. - Translates a given pixel format name to an integer constant representing it, suitable for passing to VideoSource.SetOutputFormat. + Translates a given pixel format name to an integer constant representing it, suitable for passing to VideoSource.SetOutputFormat. This function exists so that you don't have to include a FFmpeg header file in every single program you ever write. For a list of colorspaces and their names, see libavutil/pixfmt.h. To get the name of a colorspace, strip the leading PIX_FMT_ and convert the remainder to lowercase. @@ -1710,12 +1710,12 @@ - + Is FFMS2 initialized? - + Source modules that the library was compiled with @@ -1723,7 +1723,7 @@ In FFMS2, the equivalent is FFMS_GetPresentSources. - + Source modules that are actually available for use @@ -1731,24 +1731,24 @@ In FFMS2, the equivalent is FFMS_GetEnabledSources. - + The FFMS_VERSION constant In FFMS2, the equivalent is FFMS_GetVersion. - You may want to use VersionString if you just want to print the version. + You may want to use VersionString if you just want to print the version. - + - + A human-readable version of the FFMS_VERSION constant A pretty version string - + - + FFmpeg message level diff --git a/FFMSsharp/Frame.cs b/FFMSsharp/Frame.cs index 975091b..c07ca04 100644 --- a/FFMSsharp/Frame.cs +++ b/FFMSsharp/Frame.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; using System.Drawing; -namespace FFMSsharp +namespace FFMSSharp { #region Interop diff --git a/FFMSsharp/FrameInfo.cs b/FFMSsharp/FrameInfo.cs index f9e6b51..72afe33 100644 --- a/FFMSsharp/FrameInfo.cs +++ b/FFMSsharp/FrameInfo.cs @@ -1,4 +1,4 @@ -namespace FFMSsharp +namespace FFMSSharp { #region Interop diff --git a/FFMSsharp/GlobalSuppressions.cs b/FFMSsharp/GlobalSuppressions.cs index dad7adb..115f72e 100644 Binary files a/FFMSsharp/GlobalSuppressions.cs and b/FFMSsharp/GlobalSuppressions.cs differ diff --git a/FFMSsharp/Index.cs b/FFMSsharp/Index.cs index 65cb744..eb50138 100644 --- a/FFMSsharp/Index.cs +++ b/FFMSsharp/Index.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -namespace FFMSsharp +namespace FFMSSharp { #region Interop @@ -200,7 +200,7 @@ public class Index : IDisposable /// /// In FFMS2, the equivalent is FFMS_GetSourceType. /// - /// + /// public Source Source { get @@ -215,7 +215,7 @@ public Source Source /// /// In FFMS2, the equivalent is FFMS_GetErrorHandling. /// - /// + /// public IndexErrorHandling IndexErrorHandling { get @@ -266,7 +266,7 @@ public Index(string indexFile) if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_NOT_AVAILABLE) throw new NotSupportedException(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)); + 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)); } } @@ -339,7 +339,7 @@ public int GetFirstTrackOfType(TrackType type) if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_NOT_AVAILABLE) throw new System.Collections.Generic.KeyNotFoundException(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)); + 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)); } return track; @@ -369,7 +369,7 @@ public int GetFirstIndexedTrackOfType(TrackType type) if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_NOT_AVAILABLE) throw new System.Collections.Generic.KeyNotFoundException(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)); + 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)); } return track; @@ -382,7 +382,7 @@ public int GetFirstIndexedTrackOfType(TrackType type) /// In FFMS2, the equivalent is FFMS_WriteIndex. /// /// Can be an absolute or relative path; it will be truncated and overwritten if it already exists - /// Failure to initialize zlib + /// Failure to write the index public void WriteIndex(string indexFile) { FFMS_ErrorInfo err = new FFMS_ErrorInfo(); @@ -392,9 +392,9 @@ public void WriteIndex(string indexFile) if (NativeMethods.FFMS_WriteIndex(indexFile, FFMS_Index, ref err) != 0) { if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_READ) - throw new ApplicationException(err.Buffer); + throw new System.IO.IOException(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)); + 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)); } } @@ -404,7 +404,7 @@ public void WriteIndex(string indexFile) /// /// In FFMS2, the equivalent is FFMS_IndexBelongsToFile. /// Makes a heuristic (but very reliable) guess about whether the index is of the or not. - /// Useful to determine if the index object you just created by loading an index file from disk is actually relevant to your interests, since the only two ways to pair up index files with source files are a) trust the user blindly, or b) comparing the filenames; neither is very reliable. + /// Useful to determine if the index object you just created by loading an index file from disk is actually relevant to your interests, since the only two ways to pair up index files with source files are a) trust the user blindly, or b) comparing the filenames; neither is very reliable. /// /// File to check against /// True or false depending on the result @@ -419,7 +419,7 @@ public bool BelongsToFile(string sourceFile) if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_MISMATCH) return false; - 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)); + 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)); } return true; @@ -430,11 +430,11 @@ public bool BelongsToFile(string sourceFile) #region Object creation /// - /// Create a VideoSource object + /// Create a VideoSource object /// /// /// In FFMS2, the equivalent is FFMS_CreateVideoSource. - /// Note that the index object is copied into the VideoSource object upon its creation, so once you've created the video source you can generally destroy the index object immediately, since all info you can retrieve from it is also retrievable from the VideoSource object. + /// Note that the index object is copied into the VideoSource object upon its creation, so once you've created the video source you can generally destroy the index object immediately, since all info you can retrieve from it is also retrievable from the VideoSource object. /// /// The media file. Can be an absolute or relative path /// Track number of the specific video track @@ -444,7 +444,7 @@ public bool BelongsToFile(string sourceFile) /// Controls how seeking (random access) is handled and hence affects frame accuracy /// Has no effect on Matroska files, where the equivalent of Normal is always used. /// LinearNoRw may come in handy if you want to open images. - /// The generated VideoSource object + /// The generated VideoSource object /// /// /// @@ -469,23 +469,23 @@ public VideoSource VideoSource(string sourceFile, int track, int threads = 1, Se if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_MISMATCH) throw new InvalidOperationException(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)); + 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)); } - return new FFMSsharp.VideoSource(videoSource); + return new FFMSSharp.VideoSource(videoSource); } /// - /// Create an AudioSource object + /// Create an AudioSource object /// /// /// In FFMS2, the equivalent is FFMS_CreateAudioSource. - /// Note that the index object is copied into the AudioSource object upon its creation, so once you've created the video source you can generally destroy the index object immediately, since all info you can retrieve from it is also retrievable from the AudioSource object. + /// Note that the index object is copied into the AudioSource object upon its creation, so once you've created the video source you can generally destroy the index object immediately, since all info you can retrieve from it is also retrievable from the AudioSource object. /// /// The media file. Can be an absolute or relative path /// Track number of the specific audio track /// Controls how audio with a non-zero first PTS is handled; in other words what FFMS does about audio delay. - /// The generated AudioSource object + /// The generated AudioSource object /// /// /// @@ -510,24 +510,24 @@ public AudioSource AudioSource(string sourceFile, int track, AudioDelayMode dela if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_MISMATCH) throw new InvalidOperationException(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)); + 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)); } - return new FFMSsharp.AudioSource(audioSource); + return new FFMSSharp.AudioSource(audioSource); } /// - /// Create a Track object + /// Create a Track object /// /// /// In FFMS2, the equivalent is FFMS_GetTrackFromIndex. /// Use this function if you don't want to (or cannot) open the track with VideoSource or AudioSource first. - /// If you already have a VideoSource object or AudioSource object it's safer to use the Track property of VideoSource and AudioSource instead. - /// The returned Track object is only valid until its parent Index object is destroyed. - /// Requesting indexing information for a track that has not been indexed will not cause an error, it will just return an empty FFMS_Track (check for >0 frames using GetNumFrames to see if the returned object actually contains indexing information). + /// If you already have a VideoSource object or AudioSource object it's safer to use the Track property of VideoSource and AudioSource instead. + /// The returned Track object is only valid until its parent Index object is destroyed. + /// Requesting indexing information for a track that has not been indexed will not cause an error, it will just return an empty FFMS_Track (check for >0 frames using GetNumFrames to see if the returned object actually contains indexing information). /// /// Track number - /// The generated Track object + /// The generated Track object /// /// /// Trying to access a Track that doesn't exist. @@ -540,7 +540,7 @@ public Track GetTrack(int track) trackPtr = NativeMethods.FFMS_GetTrackFromIndex(FFMS_Index, track); - return new FFMSsharp.Track(trackPtr); + return new FFMSSharp.Track(trackPtr); } #endregion diff --git a/FFMSsharp/Indexer.cs b/FFMSsharp/Indexer.cs index 29766e4..811aa04 100644 --- a/FFMSsharp/Indexer.cs +++ b/FFMSsharp/Indexer.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -namespace FFMSsharp +namespace FFMSSharp { #region Interop @@ -145,7 +145,7 @@ public bool IsIndexing /// /// In FFMS2, the equivalent is FFMS_GetSourceTypeI. /// - /// + /// public Source Source { get { return (Source)NativeMethods.FFMS_GetSourceTypeI(FFMS_Indexer); } } /// @@ -153,9 +153,9 @@ public Source Source /// /// /// In FFMS2, the equivalent is FFMS_GetNumTrackI. - /// Does the same thing as Index.NumberOfTracks but does not require having the file indexed first. + /// Does the same thing as Index.NumberOfTracks but does not require having the file indexed first. /// - /// + /// public int NumberOfTracks { get { return NativeMethods.FFMS_GetNumTracksI(FFMS_Indexer); } } /// @@ -195,7 +195,7 @@ public Indexer(string sourceFile, Source demuxer = Source.Default) 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)); + 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)); } } @@ -245,12 +245,12 @@ protected virtual void Dispose(bool disposing) /// /// /// In FFMS2, the equivalent is FFMS_GetTrackTypeI. - /// Does the same thing as Track.Type but does not require having the file indexed first. - /// If you have indexed the file, use Track.Type instead since the FFMS_Indexer object is destroyed when the index is created. + /// Does the same thing as Track.Type but does not require having the file indexed first. + /// If you have indexed the file, use Track.Type instead since the FFMS_Indexer object is destroyed when the index is created. /// /// Track number /// Track type - /// + /// /// Trying to access a Track that doesn't exist. public TrackType GetTrackType(int track) { @@ -308,10 +308,10 @@ private Index Index(int AudioIndexMask, int AudioDumpMask, IndexErrorHandling In if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEXING && err.SubType == FFMS_Errors.FFMS_ERROR_PARSER) throw new System.IO.InvalidDataException(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)); + 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)); } - return new FFMSsharp.Index(index); + return new FFMSSharp.Index(index); } /// @@ -323,7 +323,7 @@ private Index Index(int AudioIndexMask, int AudioDumpMask, IndexErrorHandling In /// /// A list of specific Audio tracks to index /// Control behavior when a decoding error is encountered - /// The generated Index object + /// The generated Index object /// Called to give you an update on indexing progress /// Called when the indexing has finished /// Attempting to index a codec not supported by the indexer diff --git a/FFMSsharp/Track.cs b/FFMSsharp/Track.cs index b7dd8d1..746bd4a 100644 --- a/FFMSsharp/Track.cs +++ b/FFMSsharp/Track.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace FFMSsharp +namespace FFMSSharp { #region Interop @@ -190,7 +190,7 @@ public void WriteTimecodes(string timecodeFile) if (err.ErrorType == FFMS_Errors.FFMS_ERROR_TRACK && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_WRITE) throw new System.IO.IOException(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)); + 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)); } } diff --git a/FFMSsharp/VideoSource.cs b/FFMSsharp/VideoSource.cs index dbda046..d571164 100644 --- a/FFMSsharp/VideoSource.cs +++ b/FFMSsharp/VideoSource.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -namespace FFMSsharp +namespace FFMSSharp { #region Interop @@ -282,7 +282,7 @@ public double FirstTime public double LastTime { get { return VP.LastTime; } } - FFMSsharp.Track track; + FFMSSharp.Track track; /// /// Retrieves track info /// @@ -299,7 +299,7 @@ public Track Track { IntPtr trackPtr = IntPtr.Zero; trackPtr = NativeMethods.FFMS_GetTrackFromVideo(FFMS_VideoSource); - track = new FFMSsharp.Track(trackPtr); + track = new FFMSSharp.Track(trackPtr); } return track; } @@ -378,7 +378,7 @@ public void SetOutputFormat(ICollection targetFormats, int width, int heigh if (err.ErrorType == FFMS_Errors.FFMS_ERROR_DECODING && err.SubType == FFMS_Errors.FFMS_ERROR_CODEC) throw new ArgumentException(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)); + 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)); } } @@ -442,7 +442,7 @@ public void SetInputFormat(int pixelFormat, ColorSpace colorSpace = ColorSpace.U if (err.ErrorType == FFMS_Errors.FFMS_ERROR_DECODING && err.SubType == FFMS_Errors.FFMS_ERROR_CODEC) throw new ArgumentException(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)); + 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)); } } @@ -489,7 +489,7 @@ public Frame GetFrame(int frame) if (framePtr == IntPtr.Zero) { - 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)); + 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)); } return new Frame(framePtr); @@ -525,7 +525,7 @@ public Frame GetFrame(double time) if (framePtr == IntPtr.Zero) { - 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)); + 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)); } return new Frame(framePtr); diff --git a/README.md b/README.md index 8d0065e..3d8b635 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ FFMS# C# wrapper for [FFMS2](//github.com/ffms/ffms2) ### How to use -1. Download the [latest FFMSsharp.dll](//github.com/nixxquality/FFMSsharp/releases) +1. Download the [latest FFMSSharp.dll](//github.com/nixxquality/FFMSSharp/releases) 2. Reference it in your C# application 3. Download [ffms2.dll](//github.com/ffms/ffms2/releases) 4. Put it next to your .exe file @@ -18,21 +18,21 @@ C# wrapper for [FFMS2](//github.com/ffms/ffms2) ### Example ```C# // Initialize the library. You have to call this before anything else. -FFMSsharp.FFMS2.Initialize(); +FFMSSharp.FFMS2.Initialize(); // Index the source file. string sourcefile = "somefilename"; -var indexer = new FFMSsharp.Indexer(sourcefile); +var indexer = new FFMSSharp.Indexer(sourcefile); var index = indexer.Index(); // Retrieve the track number of the first video track -int trackno = index.GetFirstTrackOfType(FFMSsharp.TrackType.Video); +int trackno = index.GetFirstTrackOfType(FFMSSharp.TrackType.Video); // We now have enough information to create the video source object var videosource = index.VideoSource(sourcefile, trackno); // Check how many frames the video has -int num_frames = videosource.NumFrames; +int num_frames = videosource.NumberOfFrames; // Get the first frame for examination so we know what we're getting. // This is required because resolution and colorspace is a per frame property and NOT global for the video. @@ -46,7 +46,7 @@ var propframe = videosource.GetFrame(0); /* If you want to change the output colorspace or resize the output frame size, now is the time to do it. * IMPORTANT: This step is also required to prevent resolution and colorspace changes midstream. - * You can you can always tell a frame's original properties by examining the Encoded* properties in FFMSsharp.Frame. + * You can you can always tell a frame's original properties by examining the Encoded* properties in FFMSSharp.Frame. * See libavutil/pixfmt.h for the list of pixel formats/colorspaces. * To get the name of a given pixel format, strip the leading PIX_FMT_ and convert to lowercase. * For example, PIX_FMT_YUV420P becomes "yuv420p". @@ -54,9 +54,9 @@ var propframe = videosource.GetFrame(0); // A list of the acceptable output formats List pixfmts = new List(); -pixfmts.Add(FFMSsharp.FFMS2.GetPixFmt("bgra")); +pixfmts.Add(FFMSSharp.FFMS2.GetPixelFormat("bgra")); -videosource.SetOutputFormat(pixfmts, propframe.EncodedResolution.Width, propframe.EncodedResolution.Height, FFMSsharp.Resizers.Bicubic); +videosource.SetOutputFormat(pixfmts, propframe.EncodedResolution.Width, propframe.EncodedResolution.Height, FFMSSharp.Resizer.Bicubic); // Now we're ready to actually retrieve the video frames. int framenumber = 0;