[FFmpeg-devel] [PATCH 3/7] avformat/assenc: support remuxing old V4 ASS form (SSA)

Clément Bœsch u at pkh.me
Tue Oct 14 20:22:56 CEST 2014

On Tue, Oct 14, 2014 at 08:12:38PM +0200, James Darnley wrote:
> On 2014-10-11 19:59, Clément Bœsch wrote:
> > ---
> >  libavformat/assenc.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> The diff looks fine.  So if the code does what you want it to do, push.
>  Just one comment below.

I can elaborate on the purpose.

In .mkv, the dialogues of the .ssa/.ass files get muxed the same way, but
you can actually know whether it was a .ssa or a .ass by looking at the
CodecPrivate (found in avctx->extradata) which contains the original
header of the file.

This header typically has a section "[V4 Styles]" in case of .ssa (old
form) and "[V4+ Styles]" in case of .ass ("new" form, the most common
nowadays). So this can be used to determine what was the original form of
the dialogues.

As a result, we restore the Dialogue in their appropriate form depending
on this (first field with Marked=0 for .ssa, or the Layer if it was a

This is somehow important because it means that after this commit, we
don't extract .ass-like files with a .ssa header, so you don't end up with
inconsistencies and invalid files.

> > +        ass->ssa_mode = !strstr(avctx->extradata, "\n[V4+ Styles]");
> Is this supposed to have a leading newline char?

Yes, I'm just checking that it's at the beginning of a line. Before you
ask, this line can not be at the top of the file.

Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141014/1f4ff9ec/attachment.asc>

More information about the ffmpeg-devel mailing list