[FFmpeg-devel] [PATCH 2/4] lavfi/subtitles: support charset option.

Clément Bœsch ubitux at gmail.com
Mon Dec 31 11:19:42 CET 2012


---
 doc/filters.texi     | 3 +++
 libavfilter/vf_ass.c | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 76e8fb5..8d44fd5 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3953,6 +3953,9 @@ Set the filename of the subtitle file to read. It must be specified.
 Specify the size of the original video, the video for which the ASS file
 was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
 necessary to correctly scale the fonts if the aspect ratio has been changed.
+
+ at item charset
+Set subtitles input charset. @code{subtitles} filter only.
 @end table
 
 If the first key is not specified, it is assumed that the first value
diff --git a/libavfilter/vf_ass.c b/libavfilter/vf_ass.c
index 2686cab..d704ebb 100644
--- a/libavfilter/vf_ass.c
+++ b/libavfilter/vf_ass.c
@@ -50,6 +50,7 @@ typedef struct {
     ASS_Renderer *renderer;
     ASS_Track    *track;
     char *filename;
+    char *charset;
     uint8_t rgba_map[4];
     int     pix_step[4];       ///< steps per pixel for each plane of the main output
     int original_w, original_h;
@@ -253,6 +254,7 @@ AVFilter avfilter_vf_ass = {
 
 static const AVOption subtitles_options[] = {
     COMMON_OPTIONS
+    {"charset", "set input charset", OFFSET(charset), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
     {NULL},
 };
 
@@ -261,6 +263,7 @@ AVFILTER_DEFINE_CLASS(subtitles);
 static av_cold int init_subtitles(AVFilterContext *ctx, const char *args)
 {
     int ret, sid;
+    AVDictionary *codec_opts = NULL;
     AVFormatContext *fmt = NULL;
     AVCodecContext *dec_ctx = NULL;
     AVCodec *dec = NULL;
@@ -306,7 +309,9 @@ static av_cold int init_subtitles(AVFilterContext *ctx, const char *args)
                avcodec_get_name(dec_ctx->codec_id));
         return AVERROR(EINVAL);
     }
-    ret = avcodec_open2(dec_ctx, dec, NULL);
+    if (ass->charset)
+        av_dict_set(&codec_opts, "sub_charset", ass->charset, 0);
+    ret = avcodec_open2(dec_ctx, dec, &codec_opts);
     if (ret < 0)
         goto end;
 
-- 
1.8.0.3



More information about the ffmpeg-devel mailing list