mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 15:02:35 +01:00
working on format mvt
This commit is contained in:
parent
e283f8edc3
commit
9c67ed5137
@ -6,7 +6,7 @@ using System.Text;
|
|||||||
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Timeline - THE MOVIE TITLE EDITOR - http://www.pld.ttu.ee/~priidu/timeline/
|
/// Timeline - THE MOVIE TITRE EDITOR - http://www.pld.ttu.ee/~priidu/timeline/ by priidu@pld.ttu.ee
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TimeLineMvt : SubtitleFormat
|
public class TimeLineMvt : SubtitleFormat
|
||||||
{
|
{
|
||||||
@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
|
|
||||||
public override string Name
|
public override string Name
|
||||||
{
|
{
|
||||||
get { return "Timeline mtv"; }
|
get { return "Timeline mvt"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsTimeBased
|
public override bool IsTimeBased
|
||||||
@ -91,19 +91,20 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
Encoding encoding2 = GetEncodingFromLanguage(language2);
|
Encoding encoding2 = GetEncodingFromLanguage(language2);
|
||||||
|
|
||||||
_errorCount = 0;
|
_errorCount = 0;
|
||||||
while (index < bytes.Length - 10)
|
while (index < bytes.Length - 20)
|
||||||
{
|
{
|
||||||
if (bytes[index] == 5 && bytes[index + 1] == 0 && bytes[index + 2] == 0) // find subtitle
|
if (bytes[index] == 5 && bytes[index + 1] == 0 && bytes[index + 2] == 0) // find subtitle
|
||||||
{
|
{
|
||||||
// codes...
|
// time codes
|
||||||
int frames = bytes[index + 8] * 256; // + bytes[index + 9] * 256;
|
int timeCodeIndexStart = index + 4;
|
||||||
index += 20;
|
int timeCodeIndexEnd = index + 15;
|
||||||
|
index += 22;
|
||||||
while (index < bytes.Length && bytes[index] != 0x6)
|
while (index < bytes.Length && bytes[index] != 0x6)
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
index += 2;
|
index += 2;
|
||||||
if (index < bytes.Length && bytes[index] == 0x6)
|
while (index < bytes.Length && bytes[index] == 0x6)
|
||||||
{
|
{
|
||||||
index+=2;
|
index+=2;
|
||||||
}
|
}
|
||||||
@ -130,9 +131,12 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
if (index + 1 < bytes.Length)
|
if (index + 1 < bytes.Length)
|
||||||
{
|
{
|
||||||
string text2 = encoding2.GetString(bytes, start, index - start);
|
string text2 = encoding2.GetString(bytes, start, index - start);
|
||||||
var p = new Paragraph { Text = text1 + Environment.NewLine + text2 };
|
var p = new Paragraph
|
||||||
p.StartTime.TotalMilliseconds = FramesToMilliseconds(frames);
|
{
|
||||||
p.EndTime.TotalMilliseconds = frames;
|
Text = text1 + Environment.NewLine + text2,
|
||||||
|
StartTime = { TotalMilliseconds = GetTimeCode(bytes, timeCodeIndexStart) },
|
||||||
|
EndTime = { TotalMilliseconds = GetTimeCode(bytes, timeCodeIndexEnd) }
|
||||||
|
};
|
||||||
subtitle.Paragraphs.Add(p);
|
subtitle.Paragraphs.Add(p);
|
||||||
index--;
|
index--;
|
||||||
}
|
}
|
||||||
@ -144,6 +148,21 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
subtitle.Renumber();
|
subtitle.Renumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double GetTimeCode(byte[] bytes, int timeCodeIndex)
|
||||||
|
{
|
||||||
|
if (bytes == null || bytes.Length < timeCodeIndex + 8)
|
||||||
|
return 0;
|
||||||
|
Console.WriteLine(bytes[timeCodeIndex + 0].ToString("X2") + " " +
|
||||||
|
bytes[timeCodeIndex + 1].ToString("X2") + " " +
|
||||||
|
bytes[timeCodeIndex + 2].ToString("X2") + " " +
|
||||||
|
bytes[timeCodeIndex + 3].ToString("X2") + " " +
|
||||||
|
bytes[timeCodeIndex + 4].ToString("X2") + " " +
|
||||||
|
bytes[timeCodeIndex + 5].ToString("X2") + " " +
|
||||||
|
bytes[timeCodeIndex + 6].ToString("X2"));
|
||||||
|
return ((bytes[timeCodeIndex + 5] << 24) + (bytes[timeCodeIndex + 4] << 16) + (bytes[timeCodeIndex + 3] << 8) + (bytes[timeCodeIndex + 2])) / 1800.0;
|
||||||
|
// return (bytes[timeCodeIndex + 5] << 16) + (bytes[timeCodeIndex + 4] << 8) + (bytes[timeCodeIndex + 3]);
|
||||||
|
}
|
||||||
|
|
||||||
private Encoding GetEncodingFromLanguage(string language)
|
private Encoding GetEncodingFromLanguage(string language)
|
||||||
{
|
{
|
||||||
if (language == "Russian")
|
if (language == "Russian")
|
||||||
|
Loading…
Reference in New Issue
Block a user