[FFmpeg-devel] [PATCH] Whisper audio filter
Michael Niedermayer
michael at niedermayer.cc
Sat Jul 19 02:24:23 EEST 2025
Hi Vittorio
On Tue, Jul 15, 2025 at 09:44:48AM +0200, Vittorio Palmisano wrote:
[...]
> > > + if (!av_strcasecmp(wctx->format, "srt")) {
> > > + buf =
> > > + av_asprintf
> > > + ("%d\n%02ld:%02ld:%02ld.%03ld --> %02ld:%02ld:%02ld.%03ld\n%s\n\n",
> > > + wctx->index, start_t / 3600000,
> > > + (start_t / 60000) % 60, (start_t / 1000) % 60,
> > > + start_t % 1000, end_t / 3600000, (end_t / 60000) % 60,
> > > + (end_t / 1000) % 60, end_t % 1000, text_cleaned);
> > > + } else if (!av_strcasecmp(wctx->format, "json")) {
> > > + buf = av_asprintf("{\"start\":%ld,\"end\":%ld,\"text\":\"%s\"}\n",
> > > start_t, end_t, text_cleaned);
> > > + } else
> > > + buf = av_strdup(text_cleaned);
> >
> > Do you think it would make sense to use avcodec_encode_subtitle() ?
> > It would avoid hardcoding these "writers" and could use any we support
>
> avcodec_encode_subtitle should be used to generate a subtitle track, right?
I suspect this may become too complex, but for reference
this would also need
avformat_alloc_output_context2() / avformat_write_header()
loop
av_interleaved_write_frame()
av_write_trailer()
see doc/examples/remux.c, this shows demuxing and muxing, we dont need demuxing
also needs opening encoder and encoding subtitles
so i think its probably better to leave the hardcoded simple writers
your patch uses already
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Some people wanted to paint the bikeshed green, some blue and some pink.
People argued and fought, when they finally agreed, only rust was left.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250719/3b57fac5/attachment.sig>
More information about the ffmpeg-devel
mailing list