Add an UTF-8 BOM to extracted SSA/ASS and SRT subtitle files. Print warnings for missing durations for text subtitle tracks.

This commit is contained in:
Moritz Bunkus 2003-09-15 22:03:06 +00:00
parent 8003ef5ed5
commit e5cb5a2731
3 changed files with 29 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2003-09-16 Moritz Bunkus <moritz@bunkus.org>
* mkvextract: Add an UTF-8 BOM to extracted SSA/ASS and SRT
subtitle files. Print warnings for missing durations for text
subtitle tracks.
2003-09-14 Moritz Bunkus <moritz@bunkus.org> 2003-09-14 Moritz Bunkus <moritz@bunkus.org>
* Added a complete GUI for mkvmerge, mkvmergeGUI (mmg) based on * Added a complete GUI for mkvmerge, mkvmergeGUI (mmg) based on

View File

@ -72,6 +72,7 @@ typedef struct {
int srt_num; int srt_num;
int conv_handle; int conv_handle;
vector<ssa_line_c> ssa_lines; vector<ssa_line_c> ssa_lines;
bool warning_printed;
wave_header wh; wave_header wh;
int64_t bytes_written; int64_t bytes_written;

View File

@ -111,6 +111,7 @@ static void create_output_files() {
bool something_to_do, is_ok; bool something_to_do, is_ok;
unsigned char *c; unsigned char *c;
ogg_packet op; ogg_packet op;
const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf};
something_to_do = false; something_to_do = false;
@ -390,15 +391,20 @@ static void create_output_files() {
tracks[i].out->write(wh, sizeof(wave_header)); tracks[i].out->write(wh, sizeof(wave_header));
} else if (tracks[i].type == TYPESRT) } else if (tracks[i].type == TYPESRT) {
tracks[i].srt_num = 1; tracks[i].srt_num = 1;
tracks[i].out->write(utf8_bom, 3);
else if (tracks[i].type == TYPESSA) { } else if (tracks[i].type == TYPESSA) {
char *s; char *s;
unsigned char *pd;
s = (char *)safemalloc(tracks[i].private_size + 1); s = (char *)safemalloc(tracks[i].private_size + 1);
memcpy(s, tracks[i].private_data, tracks[i].private_size); memcpy(s, tracks[i].private_data, tracks[i].private_size);
s[tracks[i].private_size] = 0; s[tracks[i].private_size] = 0;
pd = (unsigned char *)tracks[i].private_data;
if ((pd[0] != 0x00) && (pd[0] != 0xef) && (pd[0] != 0xff))
tracks[i].out->write(utf8_bom, 3);
tracks[i].out->puts_unl(s); tracks[i].out->puts_unl(s);
tracks[i].out->puts_unl("\n[Events]\nFormat: Marked, Start, End, " tracks[i].out->puts_unl("\n[Events]\nFormat: Marked, Start, End, "
"Style, Name, MarginL, MarginR, MarginV, " "Style, Name, MarginL, MarginR, MarginV, "
@ -479,6 +485,13 @@ static void handle_data(KaxBlock *block, int64_t block_duration,
break; break;
case TYPESRT: case TYPESRT:
if ((end == start) && !tracks[i].warning_printed) {
mxwarn("Subtitle track %lld is missing some duration elements. "
"Please check the resulting SRT file for entries that "
"have the same start and end time.\n");
tracks[i].warning_printed = true;
}
// Do the charset conversion. // Do the charset conversion.
s = (char *)safemalloc(data.Size() + 1); s = (char *)safemalloc(data.Size() + 1);
memcpy(s, data.Buffer(), data.Size()); memcpy(s, data.Buffer(), data.Size());
@ -513,6 +526,13 @@ static void handle_data(KaxBlock *block, int64_t block_duration,
break; break;
case TYPESSA: case TYPESSA:
if ((end == start) && !tracks[i].warning_printed) {
mxwarn("Subtitle track %lld is missing some duration elements. "
"Please check the resulting SSA/ASS file for entries that "
"have the same start and end time.\n");
tracks[i].warning_printed = true;
}
s = (char *)safemalloc(data.Size() + 1); s = (char *)safemalloc(data.Size() + 1);
memcpy(s, data.Buffer(), data.Size()); memcpy(s, data.Buffer(), data.Size());
s[data.Size()] = 0; s[data.Size()] = 0;