mirror of
https://github.com/imrayya/SRTto3Dsubtitles.git
synced 2026-09-21 10:17:27 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ef16453c2 | |||
| d32816489c |
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -23,11 +23,45 @@ namespace ConvertSRTto3DASS
|
||||
File.WriteAllText(Path.GetFileNameWithoutExtension(args[0]) + ".ass", finished);
|
||||
}
|
||||
|
||||
//Is there a better way to do it?
|
||||
private static Dictionary<Regex, string> regexReplacementDict =
|
||||
new Dictionary<Regex, string> {
|
||||
{new Regex("<b>"), "{\\b1}"},
|
||||
{new Regex("(</b>)"),"{\\b0}"},
|
||||
{new Regex("(<i>)"),"{\\i1}"},
|
||||
{new Regex("(</i>)"),"{\\i0}"},
|
||||
{new Regex("(<u>)"),"{\\u1}" },
|
||||
{new Regex("(</u>)"),"{\\u0}"},
|
||||
{new Regex("(</font>)"),"{\\c&HFFFFFF&}"} //TODO custom colors. When you add custom colors, it needs to change this too
|
||||
|
||||
//TODO: Add formatting for the string. Have to look into the SSA v4.00+ specification on how to handle it
|
||||
};
|
||||
private static Regex color = new Regex("<font color=\"#.{6}\">");
|
||||
|
||||
//TODO Add positional data to the formatting.
|
||||
private static string ChangeFormatting(string line)
|
||||
{
|
||||
return "";
|
||||
foreach (var tuple in regexReplacementDict)
|
||||
{
|
||||
line = tuple.Key.Replace(line, tuple.Value);
|
||||
}
|
||||
|
||||
while (color.IsMatch(line))
|
||||
{
|
||||
var match = color.Match(line);
|
||||
string str_match = match.Value;
|
||||
var color_str = str_match.Substring(14, 6); //RGB value in HEX
|
||||
|
||||
//ASS uses RGB value, but in reverse order so got to reverse it
|
||||
var char_array = color_str.ToCharArray();
|
||||
Array.Reverse(char_array);
|
||||
color_str = new string(char_array);
|
||||
|
||||
line = color.Replace(line, "{\\c&" + color_str + "&}");
|
||||
|
||||
|
||||
}
|
||||
|
||||
return removeFormatting(line);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +229,7 @@ namespace ConvertSRTto3DASS
|
||||
if (line == "" | line == "\r")
|
||||
{
|
||||
j = 0;
|
||||
converted.Add(new Tuple<string, string, string, string>(timestamp_start, timestamp_end, removeFormatting(subtitiles), ""));
|
||||
converted.Add(new Tuple<string, string, string, string>(timestamp_start, timestamp_end, ChangeFormatting(subtitiles), ""));
|
||||
subtitiles = "";
|
||||
continue;
|
||||
}
|
||||
@@ -206,6 +240,7 @@ namespace ConvertSRTto3DASS
|
||||
if (k != i)
|
||||
{
|
||||
Console.Error.WriteLine("Something went wrong");
|
||||
Console.Error.WriteLine("Something wrong on line:" + linecounter);
|
||||
System.Environment.Exit(-1);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# SRT subtitles to 3D subtitles
|
||||
## The problem
|
||||
I wanted watch a movie with subtitle, like I always do, but the subtitles for the movie I have was a traditonal .srt while the movie I was watching was a 3D movie which was **H**alf **S**ide **B**y **S**ide (HSBS). The subtitles in question were centered which was very disorienting to read while watching the movie. The solution? Write my own program to convert it for me
|
||||
I wanted watch a movie with subtitle, like I always do, but the subtitles for the movie I have was traditional .srt while the movie I was watching was a 3D movie which was **H**alf **S**ide **B**y **S**ide (HSBS). The subtitles in question were centered which was very disorienting to read while watching the movie. The solution? Write my own program to convert it for me.
|
||||
|
||||
## Convert
|
||||
Currently just a command line program to convert a .srt subtitle file to a .ass subtitle file while making it compatable with the HSBS format. Either drag the SRT file on the .exe to convert the .srt file or run the command `SRTto3D.exe [insert your file name here]` and the program will convert it. Word of warning, I have yet to put in formating and the program will strip off any formatting of the srt. It will also likely fail with .srt file that contain a positional information.
|
||||
Currently just a command line program to convert a .srt subtitle file to an .ass subtitle file while making it compatible with the HSBS format. Either drag the SRT file on the .exe to convert the .srt file or run the command `SRTto3D.exe [insert your file name here]` and the program will convert it. Word of warning, the program will strip off any positional data off the srt. It will also likely fail with .srt file that contain a positional information.
|
||||
|
||||
## Features
|
||||
_Basically nothing right now_
|
||||
@@ -14,7 +14,7 @@ _Basically nothing right now_
|
||||
- [ ] For Anaglyph 3D media (red and green media)
|
||||
- [ ] For traditionally media (pancake mode).
|
||||
- _I suggest to just use ffmpeg for this use case_
|
||||
- [ ] Convert formatting of .srt subtitles to transfer to the converted version
|
||||
- [x] Convert formatting of .srt subtitles to transfer to the converted version
|
||||
- [ ] Convert positional data of .srt subtitles
|
||||
- [ ] Add changes which allows custom:
|
||||
- [ ] Font
|
||||
@@ -27,7 +27,7 @@ _Basically nothing right now_
|
||||
|
||||
|
||||
## Known Issues
|
||||
For some reason that I have yet to understand, Plex Transcorder doesn't not like the converted subtitles (it has a a werid issue) but it works perfectly in VLC
|
||||
For some reason that I have yet to understand, Plex Transcoder doesn't not like the converted subtitles (it has a weird issue) but it works perfectly in VLC
|
||||
|
||||
## Warning
|
||||
The code is a complete and utter mess with very little comments in it. This was meant to be a private project and I haven't had the chance to clean it up yet
|
||||
The code is a complete and utter mess with very little comments in it. This was meant to be a private project and I haven't had the chance to clean it up yet.
|
||||
|
||||
Reference in New Issue
Block a user