mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Mp4 fix + unit test
This commit is contained in:
parent
d5af0383b4
commit
cdbc5f083d
@ -106,9 +106,11 @@ namespace Nikse.SubtitleEdit.Logic.Mp4
|
||||
public MP4Parser(string fileName)
|
||||
{
|
||||
FileName = fileName;
|
||||
var fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
ParseMp4(fs);
|
||||
fs.Close();
|
||||
using (var fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
ParseMp4(fs);
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public MP4Parser(FileStream fs)
|
||||
@ -129,8 +131,8 @@ namespace Nikse.SubtitleEdit.Logic.Mp4
|
||||
if (Size < 8)
|
||||
return;
|
||||
|
||||
if (Name == "moov" && Moov != null)
|
||||
Moov = new Moov(fs, Position);
|
||||
if (Name == "moov" && Moov == null)
|
||||
Moov = new Moov(fs, Position); // only scan first "moov" element
|
||||
|
||||
count++;
|
||||
if (count > 100)
|
||||
|
BIN
src/Test/Files/sample_MP4_SRT.mp4
Normal file
BIN
src/Test/Files/sample_MP4_SRT.mp4
Normal file
Binary file not shown.
23
src/Test/Logic/Mp4/Mp4Test.cs
Normal file
23
src/Test/Logic/Mp4/Mp4Test.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.IO;
|
||||
|
||||
namespace Test.Logic.Mp4
|
||||
{
|
||||
[TestClass]
|
||||
[DeploymentItem("Files")]
|
||||
public class Mp4Test
|
||||
{
|
||||
[TestMethod]
|
||||
public void Mp4Test1()
|
||||
{
|
||||
string fileName = Path.Combine(Directory.GetCurrentDirectory(), "sample_MP4_SRT.mp4");
|
||||
var parser = new Nikse.SubtitleEdit.Logic.Mp4.MP4Parser(fileName);
|
||||
|
||||
var tracks = parser.GetSubtitleTracks();
|
||||
|
||||
Assert.IsTrue(tracks.Count == 1);
|
||||
Assert.IsTrue(tracks[0].Mdia.Minf.Stbl.EndTimeCodes.Count == 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -49,6 +49,7 @@
|
||||
<Compile Include="Logic\Dictionaries\NamesListTest.cs" />
|
||||
<Compile Include="Core\HtmlUtilTest.cs" />
|
||||
<Compile Include="Logic\Dictionaries\OcrFixReplaceListTest.cs" />
|
||||
<Compile Include="Logic\Mp4\Mp4Test.cs" />
|
||||
<Compile Include="Logic\TransportStream\TransportStreamTest.cs" />
|
||||
<Compile Include="Logic\TarFileTest.cs" />
|
||||
<Compile Include="Logic\VideoFormats\MatroskaTest.cs" />
|
||||
@ -90,6 +91,11 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Files\sample_MP4_SRT.mp4">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
Loading…
Reference in New Issue
Block a user