diff options
Diffstat (limited to 'sub/sd_lavc_conv.c')
-rw-r--r-- | sub/sd_lavc_conv.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sub/sd_lavc_conv.c b/sub/sd_lavc_conv.c index 744aa83440..9c7a6f2c5f 100644 --- a/sub/sd_lavc_conv.c +++ b/sub/sd_lavc_conv.c @@ -27,6 +27,7 @@ #include "talloc.h" #include "core/mp_msg.h" #include "core/av_common.h" +#include "core/bstr.h" #include "sd.h" struct sd_lavc_priv { @@ -55,6 +56,19 @@ static bool supports_format(const char *format) #endif } +// Disable style definitions generated by the libavcodec converter. +// We always want the user defined style instead. +static void disable_styles(bstr header) +{ + while (header.len) { + int n = bstr_find(header, bstr0("\nStyle: ")); + if (n < 0) + break; + header.start[n + 1] = '#'; // turn into a comment + header = bstr_cut(header, 2); + } +} + static int init(struct sd *sd) { struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv); @@ -76,6 +90,11 @@ static int init(struct sd *sd) sd->output_codec = "ass"; sd->output_extradata = avctx->subtitle_header; sd->output_extradata_len = avctx->subtitle_header_size; + if (sd->output_extradata) { + sd->output_extradata = talloc_memdup(sd, sd->output_extradata, + sd->output_extradata_len); + disable_styles((bstr){sd->output_extradata, sd->output_extradata_len}); + } return 0; error: |