[FFmpeg-devel] [PATCH] ffmpeg: insert bitmap subtitles as video in filters.
Clément Bœsch
ubitux at gmail.com
Thu Jul 26 20:33:01 CEST 2012
On Thu, Jul 26, 2012 at 07:41:17PM +0200, Nicolas George wrote:
> With this feature, it becomes possible to perform commonly
> requested tasks, such as hardcoding bitmap subtitles.
>
> This will be reverted once libavfilter has proper support
> for subtitles. All the changes have the string "sub2video"
> in them, it makes it easy to spot the parts.
>
Will this be enough to drop the bitmap hardsub from ffplay?
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> Changelog | 1 +
> doc/ffmpeg.texi | 14 +++++
> ffmpeg.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 3 files changed, 172 insertions(+), 4 deletions(-)
>
> diff --git a/Changelog b/Changelog
> index 3b2200f..4433a16 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -23,6 +23,7 @@ version next:
> - RTMPTS protocol support
> - RTMPE protocol support
> - RTMPTE protocol support
> +- bitmap subtitles in filters (experimental and temporary)
>
>
> version 0.11:
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index 904a505..6d71532 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -989,6 +989,20 @@ ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
> @end example
> @end table
>
> +As a special exception, you can use a bitmap subtitle stream as input: it
> +will be converted into a video with the same size as the largest video in
> +the file, or 720×576 if no video is present. Note that this is an
> +experimental and temporary solution. It will be removed once libavfilter has
> +proper support for subtitles.
> +
I'm wondering: what about dropping the "Note" and...
> +For example, to hardcode subtitles on top of a DVB-T recording stored in
> +MPEG-TS format, delaying the subtitles by 1 second:
> + at example
> +ffmpeg -i input.ts -filter_complex \
> + '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
> + -sn -map '#0x2dc' output.mkv
> + at end example
> +
... change overlay into "burnsub" (or similar), just by making
(temporarily) burnsub an alias for overlay. The main benefit will be that
when we make the real burnsub filter, nothing will change for the user;
the hack is hidden from a user point of view.
It might require to write a special init function to add a few sanity
checks; for example to prevent users from trying to hardsub a text
subtitles (print a message that make sense when he is trying to, and
eventually redirect him to a long text about the issue).
> @section Preset files
> A preset file contains a sequence of @var{option}=@var{value} pairs,
> one for each line, specifying a sequence of options which would be
> diff --git a/ffmpeg.c b/ffmpeg.c
> index ff17ba3..fd0e7f7 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -249,6 +249,12 @@ typedef struct InputStream {
> int resample_channels;
> uint64_t resample_channel_layout;
>
> + struct sub2video {
> + int64_t last_pts;
> + AVFilterBufferRef *ref;
> + int w, h;
> + } sub2video;
> +
> /* a pool of free buffers for decoded data */
> FrameBuffer *buffer_pool;
> int dr1;
> @@ -504,6 +510,139 @@ static void update_benchmark(const char *fmt, ...)
> }
> }
>
> +/* sub2video hack */
> +
Could you add a TODO/FIXME/XXX/whatever to describe a bit what should be
done?
[...]
I'm not familiar with bitmap subtitles so I can't comment much on the rest
of the patch.
Thanks,
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120726/acce1d90/attachment.asc>
More information about the ffmpeg-devel
mailing list