Skip to content

Commit 40145ab

Browse files
authored
[FIX] Fix issue #1453: Respect -stdout if multiple CC tracks are found in a Matroska input file (#1460)
* Respect `-stdout` if multiple CC tracks are found When passed the `-stdout` flag, CCExtractor should write the subtitles to standard output, instead of an output file. However, as noted in Issue #1453, CCExtractor doesn't respect the `-stdout` flag when multiple CC tracks are present in a Matroska input file (usually .mkv). This commit ensures that output is written to standard output if `- stdout` is present even if the input file is a Matroska container with multiple CC tracks. Signed-off-by: Abhishek Kumar <abhi.kr.2100@gmail.com> * Mention fixing of issue #1453 in changelog Signed-off-by: Abhishek Kumar <abhi.kr.2100@gmail.com> * Correctly spell Matroska Signed-off-by: Abhishek Kumar <abhi.kr.2100@gmail.com> Signed-off-by: Abhishek Kumar <abhi.kr.2100@gmail.com>
1 parent 492f0d5 commit 40145ab

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

docs/CHANGES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
0.95 (to be released)
22
-----------------
3+
- Fix: respect `-stdout` even if multiple CC tracks are present in a Matroska input file (#1453)
34
- Fix: crash in Rust decoder on ATSC1.0 TS Files (#1407)
45
- Removed the --with-gui flag for linux/configure and mac/configure (use the Flutter GUI instead)
56
- Fix: segmentation fault in using hardsubx

src/lib_ccx/matroska.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,15 +1099,24 @@ char *ass_ssa_sentence_erase_read_order(char *text)
10991099

11001100
void save_sub_track(struct matroska_ctx *mkv_ctx, struct matroska_sub_track *track)
11011101
{
1102-
char *filename = generate_filename_from_track(mkv_ctx, track);
1103-
mprint("\nOutput file: %s", filename);
1102+
char *filename;
11041103
int desc;
1104+
1105+
if (mkv_ctx->ctx->cc_to_stdout == CCX_TRUE)
1106+
{
1107+
desc = 1; // file descriptor of stdout
1108+
}
1109+
else
1110+
{
1111+
filename = generate_filename_from_track(mkv_ctx, track);
1112+
mprint("\nOutput file: %s", filename);
11051113
#ifdef WIN32
1106-
desc = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, S_IREAD | S_IWRITE);
1114+
desc = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, S_IREAD | S_IWRITE);
11071115
#else
1108-
desc = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, S_IWUSR | S_IRUSR);
1116+
desc = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, S_IWUSR | S_IRUSR);
11091117
#endif
1110-
free(filename);
1118+
free(filename);
1119+
}
11111120

11121121
if (track->header != NULL)
11131122
write_wrapped(desc, track->header, strlen(track->header));

0 commit comments

Comments
 (0)