mbox series

[FFmpeg-devel,00/12] I added text to bitmap subtitle conversion functionality!

Message ID 20220503161328.842587-1-traian.coza@gmail.com
Headers show
Series I added text to bitmap subtitle conversion functionality! | expand

Message

Traian Coza May 3, 2022, 4:13 p.m. UTC
I added the possibility of converting text-based subtitle tracks (such as subrip or ass) to bitmap-based subtitle tracks (such as dvd_subtitle).

I accomplished this by using libass, and basically using the code from vf_subtitles.c to render text subtitles and store the images in the AVSubtitle structure.

Of course, this functionality will only work when ffmpeg is configured with --enable-libass.

Traian Coza (12):
  Implemented text to bitmap subtitles!
  Render only when necessary
  Retreive width and height from video stream!
  Initialize ass library only once!
  Cleaned up
  Wrote proper headers
  Close libass after using
  Added standard headers
  Rearranged files, all tests are passing!
  Rearranged files, all tests are passing!
  Added logging
  Added more logging

 fftools/Makefile         |   2 +
 fftools/ffmpeg.c         |  35 ++++-
 fftools/text_to_bitmap.c | 300 +++++++++++++++++++++++++++++++++++++++
 fftools/text_to_bitmap.h |  37 +++++
 libavcodec/avcodec.h     |   9 ++
 5 files changed, 382 insertions(+), 1 deletion(-)
 create mode 100644 fftools/text_to_bitmap.c
 create mode 100644 fftools/text_to_bitmap.h

Comments

Paul B Mahol May 3, 2022, 4:20 p.m. UTC | #1
On Tue, May 3, 2022 at 6:13 PM Traian Coza <traian.coza@gmail.com> wrote:

> I added the possibility of converting text-based subtitle tracks (such as
> subrip or ass) to bitmap-based subtitle tracks (such as dvd_subtitle).
>
> I accomplished this by using libass, and basically using the code from
> vf_subtitles.c to render text subtitles and store the images in the
> AVSubtitle structure.
>
> Of course, this functionality will only work when ffmpeg is configured
> with --enable-libass.
>
>
Sorry but i think this needs to be in libavfilter instead of libavcodec.

And for libavfilter one needs to add proper, not hacky, subtitle support to
library.



> Traian Coza (12):
>   Implemented text to bitmap subtitles!
>   Render only when necessary
>   Retreive width and height from video stream!
>   Initialize ass library only once!
>   Cleaned up
>   Wrote proper headers
>   Close libass after using
>   Added standard headers
>   Rearranged files, all tests are passing!
>   Rearranged files, all tests are passing!
>   Added logging
>   Added more logging
>
>  fftools/Makefile         |   2 +
>  fftools/ffmpeg.c         |  35 ++++-
>  fftools/text_to_bitmap.c | 300 +++++++++++++++++++++++++++++++++++++++
>  fftools/text_to_bitmap.h |  37 +++++
>  libavcodec/avcodec.h     |   9 ++
>  5 files changed, 382 insertions(+), 1 deletion(-)
>  create mode 100644 fftools/text_to_bitmap.c
>  create mode 100644 fftools/text_to_bitmap.h
>
> --
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Soft Works May 3, 2022, 4:27 p.m. UTC | #2
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Traian Coza
> Sent: Tuesday, May 3, 2022 6:13 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Traian Coza <traian.coza@gmail.com>
> Subject: [FFmpeg-devel] [PATCH 00/12] I added text to bitmap subtitle
> conversion functionality!
> 
> I added the possibility of converting text-based subtitle tracks (such
> as subrip or ass) to bitmap-based subtitle tracks (such as
> dvd_subtitle).
> 
> I accomplished this by using libass, and basically using the code from
> vf_subtitles.c to render text subtitles and store the images in the
> AVSubtitle structure.

Have you seen this: https://github.com/ffstaging/FFmpeg/pull/18

sw
Nicolas George May 3, 2022, 4:51 p.m. UTC | #3
Paul B Mahol (12022-05-03):
> Sorry but i think this needs to be in libavfilter instead of libavcodec.
> 
> And for libavfilter one needs to add proper, not hacky, subtitle support to
> library.

I completely agree.

Also, the patches neglect a lot of the directives in the developer
documentation, from having self-contained clean commits to the wording
of the commit messages.

Regards,
Traian Coza May 3, 2022, 5:01 p.m. UTC | #4
I already made the commits, tho, what do you suggest I do? Should I modify
the messages?
Leo Izen May 3, 2022, 5:05 p.m. UTC | #5
On 5/3/22 13:01, Traian Coza wrote:
> I already made the commits, tho, what do you suggest I do? Should I modify
> the messages?
> _______________________________________________

You'll have to send another patchset. You append -v2 to your "git 
format-patch" command-line to generate a second version of the patch set.

Speaking of which, please read 
https://ffmpeg.org/developer.html#Contributing since it appears you have 
not. For example, you need to rebase your branch before submitting so 
the commits are squashed as necessary. Read up on "git rebase -i" or 
interactive rebase with git.

Leo Izen (thebombzen)
Traian Coza May 3, 2022, 5:09 p.m. UTC | #6
Thanks, I'll do that. I did read a bit of Contributing, but not entirely.
And I read after writing the code, so there are some things I wasn't aware
of at the time of writing the code.
Soft Works May 4, 2022, 12:16 a.m. UTC | #7
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Soft
> Works
> Sent: Tuesday, May 3, 2022 6:27 PM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Cc: Traian Coza <traian.coza@gmail.com>
> Subject: Re: [FFmpeg-devel] [PATCH 00/12] I added text to bitmap
> subtitle conversion functionality!
> 
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Traian Coza
> > Sent: Tuesday, May 3, 2022 6:13 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Traian Coza <traian.coza@gmail.com>
> > Subject: [FFmpeg-devel] [PATCH 00/12] I added text to bitmap
> subtitle
> > conversion functionality!
> >
> > I added the possibility of converting text-based subtitle tracks
> (such
> > as subrip or ass) to bitmap-based subtitle tracks (such as
> > dvd_subtitle).
> >
> > I accomplished this by using libass, and basically using the code
> from
> > vf_subtitles.c to render text subtitles and store the images in the
> > AVSubtitle structure.
> 
> Have you seen this: https://github.com/ffstaging/FFmpeg/pull/18

With the subtitle filtering patchset, you could do the same with 
a fraction of code and (probably) a single code file.

You can use the textsub2video filter as a starting point to
create a textsub2graphicsub filter.

What you see there will look all familiar to you. The textsub2video
filter uses libass as well.
You'll need to change the output media type to subtitle and the
format to graphic subtitles and add AvSubtitleArea items for 
each bitmap in a frame (similar to AVSubtitleRect).

Your code will magically shrink.. :-)

Kind regards,
softworkz