Skip to content

Commit

Permalink
Track.WriteTimecodes supports UTF-8 paths
Browse files Browse the repository at this point in the history
Fixes #6.

See #8.
  • Loading branch information
nixxquality committed May 16, 2014
1 parent a84df10 commit f25b7d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions FFMSsharp.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,16 @@ public void VideoTrackAndAPIFunctions()
Console.WriteLine("Please confirm that {0}\\timecodes.txt looks correct.", Environment.CurrentDirectory);
}

[TestMethod]
public void TrackWriteTimecodesUTF8()
{
Index index = new Index("h264_720p_hp_5.1_3mbps_vorbis_styled_and_unstyled_subs_suzumiya.ffindex");
VideoSource source = index.VideoSource("h264_720p_hp_5.1_3mbps_vorbis_styled_and_unstyled_subs_suzumiya.mkv", 0);

source.Track.WriteTimecodes("おはよう.txt");
Assert.IsTrue(File.Exists("おはよう.txt"));
}

[TestMethod]
[ExpectedException(typeof(IOException))]
public void TrackWriteTimecodesIOException()
Expand Down
6 changes: 4 additions & 2 deletions FFMSsharp/Track.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static partial class NativeMethods
public static extern IntPtr FFMS_GetFrameInfo(IntPtr T, int Frame);

[DllImport("ffms2.dll", SetLastError = false)]
public static extern int FFMS_WriteTimecodes(IntPtr T, string TimecodeFile, ref FFMS_ErrorInfo ErrorInfo);
public static extern int FFMS_WriteTimecodes(IntPtr T, byte[] TimecodeFile, ref FFMS_ErrorInfo ErrorInfo);
}

#endregion
Expand Down Expand Up @@ -181,7 +181,9 @@ public void WriteTimecodes(string timecodeFile)
err.BufferSize = 1024;
err.Buffer = new String((char)0, 1024);

if (NativeMethods.FFMS_WriteTimecodes(FFMS_Track, timecodeFile, ref err) != 0)
byte[] TimecodeFile = new byte[timecodeFile.Length];
TimecodeFile = System.Text.Encoding.UTF8.GetBytes(timecodeFile);
if (NativeMethods.FFMS_WriteTimecodes(FFMS_Track, TimecodeFile, ref err) != 0)
{
if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_READ) // FFMS2 2.19 throws this type of error
throw new System.IO.IOException(err.Buffer);
Expand Down

0 comments on commit f25b7d8

Please sign in to comment.