[FFmpeg-devel] Improved SAMI support

Clément Bœsch u at pkh.me
Fri Sep 30 11:17:46 EEST 2016


On Fri, Sep 30, 2016 at 12:28:14AM +0200, Jehan Pagès wrote:
> Hello!
> 
> So I posted a patch about SAMI support
> (https://trac.ffmpeg.org/ticket/3118), but I was told it would be
> ignored on the bug tracker, therefore to use the dev mailing list. So
> patch attached, and a small description:
> 
> SAMI subtitles can have several languages (as explained in the spec:
> https://msdn.microsoft.com/en-us/library/ms971327.aspx). But currently
> this is not supported by ffmpeg. What ffmpeg does is simply using
> subtitles for all language, and when 2 subtitles uses the same
> timestamp (which obviously happen for most text in the file since they
> are made for the same video), the one later defined in the file will
> override the first definition.
> Example:
> 
> > <SYNC Start=5905>Some text in Korean (for instance)
> > […]
> > <SYNC Start=5905>The same text but in English.
> 
> Result: the Korean text will never be displayed.
> Also you can end up with mix of languages (versions of a subtitle in
> another lang may have additional timestamps which don't get
> overriden). As a consequence, I have to edit nearly every SMI file
> which comes into my hand and delete all text from the language I don't
> want myself. And that's extremely annoying.
> 

> My attached patch is a first step. It will only take into account
> subtitles set for the default language (which means, the first defined
> in the SAMI file, cf. the spec), or without a language (therefore a
> subtitle can be common to all langs). Of course, the perfect version
> should extract 1 subtitle track per lang in the file. This first patch
> does not (maybe another one later!). But that's still a huge
> improvement from the current code since usually all the SMI files I
> find, the default language is indeed the one I need (since they were
> done for this purpose). I have used this patch for the last 2 days,
> and that's already a huge relief for me. :-)
> 
> Could this be integrated into ffmpeg?

Creating multiple streams is essential IMO (the api is ready;
lavf/subtitles supports this). You can check how VobSub are handled.

Then using regex is not reliable enough. And if you absolutely want to use
it, you need to add configure checks because it's likely not portable
enough. But I'd very much encourage you to have a proper parser.

Regards,

-- 
Clément B.


More information about the ffmpeg-devel mailing list