[FFmpeg-devel] [PATCH] libavf/avienc: store language metadata for XSUB streams

Michael Niedermayer michaelni at gmx.at
Sat Nov 9 19:38:13 CET 2013


On Sat, Nov 09, 2013 at 04:57:39PM +0100, Erik Olofsson wrote:
> Formatted in such a way that DivX certified players can decode it.
> Verified on Sony Playstation 3 and Philips DVP3380.
> 
> Fixes ticket 2385
> 
> Signed-off-by: Erik Olofsson <eaj.olofsson at gmail.com>
> ---
>  libavformat/avienc.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/libavformat/avienc.c b/libavformat/avienc.c
> index 27db3f1..0e43920 100644
> --- a/libavformat/avienc.c
> +++ b/libavformat/avienc.c
> @@ -26,6 +26,8 @@
>  #include "avi.h"
>  #include "avio_internal.h"
>  #include "riff.h"
> +#include "libavformat/avlanguage.h"
> +#include "libavutil/avstring.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/dict.h"
>  #include "libavutil/avassert.h"
> @@ -152,6 +154,8 @@ static int avi_write_header(AVFormatContext *s)
>      AVCodecContext *stream, *video_enc;
>      int64_t list1, list2, strh, strf;
>      AVDictionaryEntry *t = NULL;
> +    char* str;
> +    const char* langstr;
>  
>      if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
>          av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",

these 2 can be put in the block of code that uses them
otherwise av_freep() shuld be used to ensure no pointers to freed
memory remain.
moving them down makes the code also nicely self contained


> @@ -309,6 +313,16 @@ static int avi_write_header(AVFormatContext *s)
>              ff_riff_write_info_tag(s->pb, "strn", t->value);
>              t = NULL;
>          }
> +        if(stream->codec_id == AV_CODEC_ID_XSUB
> +           && (t = av_dict_get(s->streams[i]->metadata, "language", NULL, 0))) {
> +            langstr = av_convert_lang_to(t->value, AV_LANG_ISO639_1);
> +            t = NULL;
> +            if (langstr) {
> +                str = av_asprintf("Subtitle - %s-xx;02", langstr);
> +                ff_riff_write_info_tag(s->pb, "strn", str);
> +                av_free(str);
> +            }
> +        }
>        }
>  
>          if (pb->seekable) {
> -- 
> 1.8.3.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131109/e720b5c1/attachment.asc>


More information about the ffmpeg-devel mailing list