[FFmpeg-devel] [PATCH] libavcodec/htmlsubtitles: skip newline characters at the beginning of the subtitle

Evgeny Shulgin izaronplatz at gmail.com
Fri Jun 16 21:30:44 EEST 2017


Info about this patch:

Working with one video, I noticed that ffmpeg incorrectly extracts out
subtitles. Some subtitles have disappeared.
I have a video file as Matroska (.mkv) container, subtitles are there in
the SubRip (.srt) format.

Output of `ffmpeg`: https://pastebin.com/raw/vyiMNFbe
Output of my Matroska parser:  https://pastebin.com/raw/8XsXkm0C
Output of `mkvextract`: https://pastebin.com/raw/7K7nkwsd

When I open the .mkv file in VLC Player, these magical subtitles are
displayed correctly.
But of all the extracted subtitle files, only the second file works
correctly (from my parser) in VLC, in other 2 files these subtitle lines
have dissapeared.

Therefore, I suggest deleting the newline characters at the beginning of
the line, and working on. FATE tests works without error.

2017-06-16 21:23 GMT+03:00 Evgeny Shulgin <izaronplatz at gmail.com>:

> We can have a certain number of newline characters at the very beginning
> of the subtitles. We must skip them to get the correct result.
> ---
>  libavcodec/htmlsubtitles.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c
> index 16295da..b144aaa 100644
> --- a/libavcodec/htmlsubtitles.c
> +++ b/libavcodec/htmlsubtitles.c
> @@ -62,6 +62,9 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst,
> const char *in)
>      strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
>      strcpy(stack[0].param[PARAM_FACE],  "{\\fn}");
>
> +    while (*in && (*in == '\r' || *in == '\n'))
> +        in++;
> +
>      for (; !end && *in; in++) {
>          switch (*in) {
>          case '\r':
> --
> 2.7.4
>
>


More information about the ffmpeg-devel mailing list