[FFmpeg-devel] Maintainer responsibilities
Hello, I am the maintainer of the dejudder filter. I haven't done anything to it since it contributed it almost two years ago. I follow this list, never seeing anything specifically mentioning it. Is there something else I should be doing as the maintainer? -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Status of dvdsub "forced_subs_only" patch
Oliver Fromme wrote: > Michael Niedermayer wrote: > > On Sun, Jun 29, 2014 at 05:36:32PM +0200, Oliver Fromme wrote: > > > [...] > > > The problem with dropping rectangles in utils.c is that there > > > might be multiple output streams. The flag ("forced subtitles > > > only") might be set for some output streams, but not for others. > > > So, if we dropped some rectangles from the AVSubtitle structure > > > in utils.c, they will be missing from other output streams that > > > are encoded afterwards. > > > > You can put the, to be kept rectangles in a new AVSubtitle struct. > > Oh, it didn't occur to me to generate an new AVSubtitle struct > in utils.c. Thanks for pointing that out. > > I'll give that a try and make a new patch. > > Best regards > Oliver Has there been any update on this? I would like to be able to pick out only the forced subtitles from a dvdsub track. This looks like it was my best bet. I can't find any documentation of this or figure out a useful place to put -forced_subs_only 1 in the command line: ffmpeg -forced_subs_only 1 -i tmp.mkv -map 0 -c:s dvdsub out.mkv I get ... Codec AVOption forced_subs_only (Only show forced subtitles) specified for input file #0 (tmp.mkv) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some decoder which was not actually used for any stream. tmp.mkv is just: Stream #0:0(eng): Subtitle: dvd_subtitle, 720x480 (default) Metadata: LANGUAGE: eng ENCODER : Lavc55.69.100 dvdsub -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Status of dvdsub "forced_subs_only" patch
Ok, I seem to have a partial solution. I thought that the place to put this would be in the dvdsubenc.c. So I made the following changes (sorry for inline patch) diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c index 425f0af..7cae3f4 100644 --- a/libavcodec/dvdsubenc.c +++ b/libavcodec/dvdsubenc.c @@ -30,6 +30,7 @@ typedef struct { AVClass *class; uint32_t global_palette[16]; int even_rows_fix; +int only_enc_forced; } DVDSubtitleContext; // ncnt is the nibble counter @@ -277,6 +278,9 @@ static int encode_dvd_subtitles(AVCodecContext *avctx, forced = 1; break; } +if (!forced && dvdc->only_enc_forced) + return 0; + vrect = *h->rects[0]; if (rects > 1) { @@ -453,6 +457,7 @@ static int dvdsub_encode(AVCodecContext *avctx, #define SE AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { {"even_rows_fix", "Make number of rows even (workaround for some players)", OFFSET(even_rows_fix), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SE}, +{"only_enc_forced", "Only encode forced subtitles", OFFSET(only_enc_forced), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SE}, { NULL }, }; Ok, with this change, ffmpeg compiles fine. To do my testing, I have a file called subs.mkv that just has two subtitle tracks. Both tracks have about 1000 subtitles. Track 0 has 46 forced subtitles, and track 1 has zero. The commands I am using are ffmpeg -i subs.mkv -map 0 -c:s dvdsub -only_enc_forced 1 only.mkv This produces a smaller file. (from 7.9M to 240K) If I pull out the subs & idx's using mkvextract tracks rec.mkv 0:subs-0.sub 1:subs-1.sub produces strange results. The idx's are the same size (49K & 61K) as the original idx's, but the .sub files are smaller (2.3M & 2.8M from 4.9M and 5.5M) However, something isn't right. If I try to open these new sub/idx's in BDsup2sub I get: "ERROR: Invalid control buffer size" However, if I put the only.mkv through ffmpeg again with: ffmpeg -i only.mkv -map 0 -c:s dvdsub recode.mkv And then pull the mkv's out with similar mkvextract command, it get the 46 (in 0) and 0 (in 1) subtitles I was expecting. The file sizes are also saner (idx's 2.2K & 219B, .subs 184K and 0B) So, it seems like what I am doing produces a mangled dvdsub track, but one that ffmpeg can make sense of. It isn't just some muxing thing since if I run only.mkv through mkvmerge, it doesn't get fixed. How can I finish this patch? -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Status of dvdsub "forced_subs_only" patch
> On Tuesday, September 16, 2014 1:34 PM, Nicholas Robbins > wrote: > > Ok, I seem to have a partial solution. > > I thought that the place to put this would be in the dvdsubenc.c. So I made > the > following changes (sorry for inline patch) > > So, it seems like what I am doing produces a mangled dvdsub track, but one > that > ffmpeg can make sense of. It isn't just some muxing thing since if I run > only.mkv through mkvmerge, it doesn't get fixed. > > How can I finish this patch? Any thoughts on this? I don't think I should submit this patch since it produces corrupted tracks. But it works good enough for me (I just wash the subtitle mkv with ffmpeg again) -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Status of dvdsub "forced_subs_only" patch
> On Wednesday, September 17, 2014 1:43 PM, Nicholas Robbins > wrote: > > > >> On Tuesday, September 16, 2014 1:34 PM, Nicholas Robbins > wrote: >> > Ok, I seem to have a partial solution. >> >> I thought that the place to put this would be in the dvdsubenc.c. So I made > the >> following changes (sorry for inline patch) >> > >> So, it seems like what I am doing produces a mangled dvdsub track, but one > that >> ffmpeg can make sense of. It isn't just some muxing thing since if I > run >> only.mkv through mkvmerge, it doesn't get fixed. >> >> How can I finish this patch? > > Any thoughts on this? I don't think I should submit this patch since it > produces corrupted tracks. But it works good enough for me (I just wash the > subtitle mkv with ffmpeg again) I've looked this over again and, while this is my first foray into encoders, I don't see why my patch should produce a corrupted dvdsub track. Any suggestions? -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [patch] Only decode forced dvd-subtitles
Ok, not to beat a dead horse, but I think I've gotten this working. I think it might work better in lavc/dvdsubdec.c. AFAICT this works and doesn't produce mangled tracks. Patch at end of email. (Sorry for the inline patch) If this is a good patch, I'll add the appropriate documentation and do a proper commit-patch diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 7355c03..874c28b 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -39,6 +39,7 @@ typedef struct DVDSubContext uint8_t alpha[256]; uint8_t *buf; int buf_size; + int only_dec_forced; #ifdef DEBUG int sub_id; #endif @@ -548,6 +549,9 @@ static int dvdsub_decode(AVCodecContext *avctx, if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) goto no_subtitle; +if (ctx->only_dec_forced && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) +goto no_subtitle; + #if defined(DEBUG) { char ppm_name[32]; @@ -652,6 +656,7 @@ static av_cold int dvdsub_close(AVCodecContext *avctx) #define VD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD }, +{ "only_dec_forced", "Only decode forced subtitles", OFFSET(only_dec_forced), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, VD}, { NULL } }; static const AVClass dvdsub_class = { ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [patch] Only decode forced dvd-subtitles
> On Friday, September 19, 2014 12:31 PM, Carl Eugen Hoyos > wrote: > > Nicholas Robbins ffmpeg.org> writes: > >> +{ "only_dec_forced", "Only decode forced > subtitles", > > Please use the same option name as for pgs subtitles. > > Carl Eugen Ok, I'll do that. Also I noticed that dvdsubdec.c says: #define VD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD } While pgssubdec.c says: #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { {"forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD}, Shouldn't dvdsubdec have SD rather than VD for readability at least? Also, this requires the option be set by "-forced_subs_only 1". How does one implement boolean options so I could set it by "-forced_subs_only"? -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [patch] Only decode forced dvd-subtitles
> On Friday, September 19, 2014 1:15 PM, wm4 wrote: > > Sorry, but didn't the discussion go towards that ffmpeg.c should filter > out subtitles flagged as forced? > > And in fact, the PGS decoder should be changed to flag forced subs > correctly. I've never peeked inside ffmpeg.c so I don't know if I can figure out how to remove the unforced subs there, but if that is the only way to get this patch in, I'll see if I can figure it out. -N ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] Only decode forced subtitle entries from dvdsub track.
Signed-off-by: Nicholas Robbins --- libavcodec/dvdsubdec.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 7355c03..de1ecbf 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -39,6 +39,7 @@ typedef struct DVDSubContext uint8_t alpha[256]; uint8_t *buf; int buf_size; + int forced_subs_only; #ifdef DEBUG int sub_id; #endif @@ -548,6 +549,9 @@ static int dvdsub_decode(AVCodecContext *avctx, if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) goto no_subtitle; +if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) +goto no_subtitle; + #if defined(DEBUG) { char ppm_name[32]; @@ -652,6 +656,7 @@ static av_cold int dvdsub_close(AVCodecContext *avctx) #define VD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD }, +{ "forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, VD}, { NULL } }; static const AVClass dvdsub_class = { -- 1.8.5.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] libavcodec/dvdsubdec: Add option forced_subs_only to only decode forced subtitle frames.
Signed-off-by: Nicholas Robbins --- libavcodec/dvdsubdec.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index c7973f0..bb28d9e 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -39,6 +39,7 @@ typedef struct DVDSubContext uint8_t alpha[256]; uint8_t *buf; int buf_size; + int forced_subs_only; #ifdef DEBUG int sub_id; #endif @@ -548,6 +549,9 @@ static int dvdsub_decode(AVCodecContext *avctx, if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) goto no_subtitle; +if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) +goto no_subtitle; + #if defined(DEBUG) { char ppm_name[32]; @@ -652,6 +656,7 @@ static av_cold int dvdsub_close(AVCodecContext *avctx) #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD }, +{ "forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD}, { NULL } }; static const AVClass dvdsub_class = { -- 1.8.5.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] Only decode forced subtitles frames.
--- libavcodec/dvdsubdec.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 7355c03..de1ecbf 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -39,6 +39,7 @@ typedef struct DVDSubContext uint8_t alpha[256]; uint8_t *buf; int buf_size; + int forced_subs_only; #ifdef DEBUG int sub_id; #endif @@ -548,6 +549,9 @@ static int dvdsub_decode(AVCodecContext *avctx, if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) goto no_subtitle; +if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) +goto no_subtitle; + #if defined(DEBUG) { char ppm_name[32]; @@ -652,6 +656,7 @@ static av_cold int dvdsub_close(AVCodecContext *avctx) #define VD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD }, +{ "forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, VD}, { NULL } }; static const AVClass dvdsub_class = { -- 1.8.5.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] libavcodec/dvdsubdec: Add option forced_subs_only to only decode forced subtitle frames.
ping On Saturday, September 20, 2014 7:54 AM, Nicholas Robbins wrote: > > >Signed-off-by: Nicholas Robbins >--- >libavcodec/dvdsubdec.c | 5 + >1 file changed, 5 insertions(+) > >diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c >index c7973f0..bb28d9e 100644 >--- a/libavcodec/dvdsubdec.c >+++ b/libavcodec/dvdsubdec.c >@@ -39,6 +39,7 @@ typedef struct DVDSubContext > uint8_t alpha[256]; > uint8_t *buf; > int buf_size; >+ int forced_subs_only; >#ifdef DEBUG > int sub_id; >#endif >@@ -548,6 +549,9 @@ static int dvdsub_decode(AVCodecContext *avctx, > if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) > goto no_subtitle; > >+if (ctx->forced_subs_only && !(sub->rects[0]->flags & >AV_SUBTITLE_FLAG_FORCED)) >+goto no_subtitle; >+ >#if defined(DEBUG) > { > char ppm_name[32]; >@@ -652,6 +656,7 @@ static av_cold int dvdsub_close(AVCodecContext *avctx) >#define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM >static const AVOption options[] = { > { "palette", "set the global palette", OFFSET(palette_str), > AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD }, >+{ "forced_subs_only", "Only show forced subtitles", >OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD}, > { NULL } >}; >static const AVClass dvdsub_class = { >-- >1.8.5.5 > > >___ >ffmpeg-devel mailing list >ffmpeg-devel@ffmpeg.org >http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] doc/decoders: adding documentation for lavc/dvdsubdec.c option "forced_subs_only"
Signed-off-by: Nicholas Robbins --- doc/decoders.texi | 5 + 1 file changed, 5 insertions(+) diff --git a/doc/decoders.texi b/doc/decoders.texi index 6910dc1..56ce928 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -190,6 +190,11 @@ The format for this option is a string containing 16 24-bits hexadecimal numbers (without 0x prefix) separated by comas, for example @code{0d00ee, ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, 7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. + +@item forced_subs_only +Only decoded subtitle entries marked as forced. Some titles have forced +and non-forced subtitles in the same track. Setting this flag to @code{1} +will only keep the forced subtitles. Default value is @code{0}. @end table @section libzvbi-teletext -- 1.8.5.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] doc/decoders: adding documentation for lavc/dvdsubdec.c option "forced_subs_only"
Signed-off-by: Nicholas Robbins --- doc/decoders.texi | 5 + 1 file changed, 5 insertions(+) diff --git a/doc/decoders.texi b/doc/decoders.texi index 6910dc1..ae20cea 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -190,6 +190,11 @@ The format for this option is a string containing 16 24-bits hexadecimal numbers (without 0x prefix) separated by comas, for example @code{0d00ee, ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, 7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. + +@item forced_subs_only +Only decode subtitle entries marked as forced. Some titles have forced +and non-forced subtitles in the same track. Setting this flag to @code{1} +will only keep the forced subtitles. Default value is @code{0}. @end table @section libzvbi-teletext -- 1.8.5.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] doc/decoders: adding documentation for lavc/dvdsubdec.c option "forced_subs_only"
> On Monday, September 22, 2014 3:28 PM, Nicholas Robbins > wrote: > +Only decoded subtitle entries marked as forced. Some titles have forced Should be 'decode' not 'decoded'. Resent patch -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Fw: [FFmpeg-user] How to create trapezoid videos with ffmpeg?
> On Thursday, October 16, 2014 11:59 AM, Moritz Barsnick > wrote: > > Hi Zenny, > > On Wed, Oct 15, 2014 at 10:55:40 +0200, Zenny wrote: >> New to ffmpeg. How can one create a trapezoid shaped video as a >> overlay to the background as seen at >> http://www.youtube.com/watch?v=_380o5B9MrA (starts at 00:02:25) using >> ffmpeg command? > > I can't seem to find a filter which does that directly, but the > "perspective" does a similar transformation, in an inverse way. I > believe it "virtually pulls the given viewpoints to the corners." > Using > it with values pointing at viewpoints outside of the frame gives the > approximate effect of what you're trying to achieve, see my example > below. Interestingly, that filter smears the edges colors of the input > across the rest of the output frame. (I'm not sure whether that's a bug > or a feature.) > > Here's an example, using a test source with an overlayed outline and > grid lines, to may the effect more clearly visible. It uses the SDL > display driver as output to screen, but you can output to a file > alternatively: > > ffmpeg -re -f lavfi -i > "testsrc,drawbox=x=1:y=1:w=iw-2:h=ih-2:t=1:c=white,drawgrid=w=iw/10:h=ih/10:t=1:c=white@0.5" > > -filter_complex "[0:v]perspective=x0=-100:y0=-100:x2=-100:y2=H+100[ovl1]; > [0:v]pad=w=iw*2[ovl0]; [ovl0][ovl1]overlay=x=W/2[vidout]" -map > "[vidout]" -pix_fmt yuv420p -f sdl - > > I use the "-filter_complex" chain to combine the original and the > transformed output side-by-side. The relevant "perspective" filter > section is: > > "perspective=x0=-100:y0=-100:x2=-100:y2=H+100" > > Note the reference points _outside_ of the frame to achieve a trapezoid > size reduction. The filter you are looking for should probably accept > actual corner values. That said, such a filter could probably be > derived from the "perspective" filter's code. (I failed at finding > an > easy way to do this though.) > > Moritz Ok, it seems like this should be easier. If we had a filter that did the same thing as vf_perspective but with inverse options this would be easy. So instead telling it what points you want to send to the corners, you tell it where you want the corners sent. I ran the math and the formulas to map between the two different ways of specifying the projective transformation are a bit messy. For instance, if you want to send the corners to x0:y0:x1:y1:x2:y2:x3:y3 the first option for the vf_perspective should be (W (x2 y0 - x0 y2) (x3 (y0 - y1) + x0 (y1 - y3) + x1 (-y0 + y3)) (x3 (y1 - y2) + x1 (y2 - y3) + x2 (-y1 + y3)))/(-x0 (x3^2 (y1 - y2) (-2 y1 y2 + y0 (y1 + y2)) - 2 x2 x3 y1 (y1 - y2) (y0 - y3) + x2^2 y0 (y1 - y3)^2) + x2 x3 (y0 - y1)^2 (-x3 y2 + x2 y3) + x1 (x3^2 y1 (y0 - y2)^2 + 2 x0 x3 (y1 - y2) y2 (y0 - y3) - x0^2 y1 (y2 - y3)^2 - 2 x2 (y1 - y2) (y0 - y3) (x3 y0 + x0 y3) + x2^2 (y0 - y3) (y0 (y1 - 2 y3) + y1 y3)) + x0^2 (x2 y2 (y1 - y3)^2 - x3 (y1 - y2) (2 y1 y2 - y1 y3 - y2 y3)) + x1^2 (x0 y0 (y2 - y3)^2 - x3 (y0 - y2)^2 y3 - x2 (y0 - y3) (y0 (y2 - 2 y3) + y2 y3))) not something you can put on the command line or even want to work out by hand. However, it would be totally doable to calculate in filter initialization. So is it possible to make a filter that is basically just a wrapper around another filter? This hypothetical filter (call it vf_keystone) would just call vf_perspective with crazy options. Clearly I could just copy the vf_perspective filter and then insert these changes, but than any future changes to vf_perspective wouldn't filter down to vf_keystone. Is this possible? -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [FFmpeg-user] How to create trapezoid videos with ffmpeg?
> On Friday, October 17, 2014 2:30 PM, Nicholas Robbins > wrote: > > > Ok, it seems like this should be easier. If we had a filter that did the same > thing as vf_perspective but with inverse options this would be easy. So > instead > telling it what points you want to send to the corners, you tell it where you > want the corners sent. > > I ran the math and the formulas to map between the two different ways of > specifying the projective transformation are a bit messy. For instance, if > you > want to send the corners to x0:y0:x1:y1:x2:y2:x3:y3 the first option for the > vf_perspective should be > > > not something you can put on the command line or even want to work out by > hand. > However, it would be totally doable to calculate in filter initialization. > > So is it possible to make a filter that is basically just a wrapper around > another filter? This hypothetical filter (call it vf_keystone) would just > call > vf_perspective with crazy options. Clearly I could just copy the > vf_perspective > filter and then insert these changes, but than any future changes to > vf_perspective wouldn't filter down to vf_keystone. > > Is this possible? > > -Nick Upon further thought and a closer read of the vf_perspective code, I think an easier option would be to insert an option of "sense" or "mode" or something. Then condition the code at lines 144-160 (these lines calculate the matrix used for the transformation) and then put in another block conditioned on the "mode" that finds the inverse matrix rather than the matrix currently found. Is this a reasonable approach? If so, I think I'll put this in in a little while. -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Patch to create trapezoid videos with ffmpeg.
> On Saturday, October 18, 2014 8:55 AM, Nicholas Robbins > wrote: > >> On Saturday, October 18, 2014 8:36 AM, Moritz Barsnick > wrote: > >> You basically got it right. (I happened to follow the thread on >> ffmpeg-devel, thanks for forwarding it.) >> >> a) An inverse calculation, like in your example given. But that's just >> totally over the top, no-one can be expected to be capable of such a >> calculation. I tried to figure it out from the code, but couldn't. > > I happen to be a mathematician, and I've taught courses on projective > geometry and perspective. If you know the right question to ask > mathematically > it's straight forward, but the answer is a mess. > >> b) What I meant - and you got it totally right on ffmpeg-devel - is to >> re-use the code from the perspective filter, because it contains all >> the transformations, considerations, and colorspace cruft. Just the >> wrong parameters. So the questions regarding "how to re-use a > filter's >> algorithms/mechanisms without duplicating its code" are spot-on. > > I'm leaning to making it an option to the perspective filter, so you can say > how you want the parameters intrepreted, as the locations in the source of > the > corners of the new video or the locations in the new video of the corners of > the > source. > > I don't know anything about the colorspace stuff but that could presumably > be put in. If I understand correctly (a big if), the array pv in the context > stores the inverse locations of the new image. If that is outside of the > original image, it could just be set to [0,0,0,0] or whatever, but I don't > know about color formats or anything. > > If you want to handle that, I'll tackle the inverse transformation part. > > -Nick > >> That said, I pointed out that the perspective filter is doing peculiar >> things with the color edges when using such "negative" > parameters. I see what it is doing, I think it is just interpolating from the data it has. The "peculiar" things you see it doing is probably due to the fact that it might not sample croma at every pixel. I find that if I put a two pixel black frame around the image first it works fine. >> Have >> a look at my testsrc example's output. Possibly the perspective filter >> was only written with "inside" reference points in mind. The > opposite >> filter would also need to be able to fill the remaining "empty" > space >> with some kind of transparency/alpha channel, so that overlaying the >> warped frame over another stream is possible. That's basically what the >> original poster was looking for, and what makes sense to me from a user >> perspective. I imagine you if you add a two pixel pad of transparent black (0x), it would do what you suggest. I've attached a patch. Apply the patch, recompile and see if ./ffplay -f lavfi -i testsrc -vf pad="iw+4:ih+4:2:2:0x",perspective=x0=W/4:y0=H/4:x1=3*W/4:y1=H/4:sense=destination does what you want. If this works, I'll add documentation and submit it. >> Moritzdiff --git a/libavfilter/vf_perspective.c b/libavfilter/vf_perspective.c index a796bd4..8cfaf05 100644 --- a/libavfilter/vf_perspective.c +++ b/libavfilter/vf_perspective.c @@ -46,6 +46,7 @@ typedef struct PerspectiveContext { int height[4]; int hsub, vsub; int nb_planes; +int sense; int (*perspective)(AVFilterContext *ctx, void *arg, int job, int nb_jobs); @@ -53,6 +54,12 @@ typedef struct PerspectiveContext { #define OFFSET(x) offsetof(PerspectiveContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit } + +enum PERSPECTIVESense { +PERSPECTIVE_SENSE_SOURCE = 0, ///< coordinates give locations in source of corners of destination. +PERSPECTIVE_SENSE_DESTINATION = 1, ///< coordinates give locations in destination of corners of source. +}; static const AVOption perspective_options[] = { { "x0", "set top left x coordinate", OFFSET(expr_str[0][0]), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, @@ -66,6 +73,10 @@ static const AVOption perspective_options[] = { { "interpolation", "set interpolation", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=LINEAR}, 0, 1, FLAGS, "interpolation" }, { "linear", "", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, "interpolation" }, { "cubic", ""
[FFmpeg-devel] [PATCH] libavfi: added option to vf_perspective to specify transformation by giving destinations of corners of source.
Signed-off-by: Nicholas Robbins --- doc/filters.texi | 21 +++ libavfilter/vf_perspective.c | 85 +--- 2 files changed, 86 insertions(+), 20 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index b847635..c612052 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6718,6 +6718,9 @@ A description of the accepted parameters follows. @item y3 Set coordinates expression for top left, top right, bottom left and bottom right corners. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged. +If the @code{sense} option is set to @code{source}, then the specified points will be sent +to the corners of the destination. If the @code{sense} option is set to @code{destination}, +then the corners of the source will be sent to the specified coordinates. The expressions can use the following variables: @@ -6737,6 +6740,24 @@ It accepts the following values: @end table Default value is @samp{linear}. + +@item sense +Set interpretation of coordinate options. + +It accepts the following values: +@table @samp +@item 0, source + +Send point in the source specified by the given coordinates to +the corners of the destination. + +@item 1, destination + +Send the corners of the source to the point in the destination specified +by the given coordinates. + +Default value is @samp{source}. +@end table @end table @section phase diff --git a/libavfilter/vf_perspective.c b/libavfilter/vf_perspective.c index a796bd4..bf06d02 100644 --- a/libavfilter/vf_perspective.c +++ b/libavfilter/vf_perspective.c @@ -46,6 +46,7 @@ typedef struct PerspectiveContext { int height[4]; int hsub, vsub; int nb_planes; +int sense; int (*perspective)(AVFilterContext *ctx, void *arg, int job, int nb_jobs); @@ -54,6 +55,11 @@ typedef struct PerspectiveContext { #define OFFSET(x) offsetof(PerspectiveContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +enum PERSPECTIVESense { +PERSPECTIVE_SENSE_SOURCE = 0, ///< coordinates give locations in source of corners of destination. +PERSPECTIVE_SENSE_DESTINATION = 1, ///< coordinates give locations in destination of corners of source. +}; + static const AVOption perspective_options[] = { { "x0", "set top left x coordinate", OFFSET(expr_str[0][0]), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, { "y0", "set top left y coordinate", OFFSET(expr_str[0][1]), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, @@ -66,6 +72,12 @@ static const AVOption perspective_options[] = { { "interpolation", "set interpolation", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=LINEAR}, 0, 1, FLAGS, "interpolation" }, { "linear", "", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, "interpolation" }, { "cubic", "", 0, AV_OPT_TYPE_CONST, {.i64=CUBIC}, 0, 0, FLAGS, "interpolation" }, +{ "sense", "specify the sense of the coordinates", OFFSET(sense), AV_OPT_TYPE_INT, {.i64=PERSPECTIVE_SENSE_SOURCE}, 0, 1, FLAGS, "sense"}, +{ "source", "specify locations in source to send to corners in destination", +0, AV_OPT_TYPE_CONST, {.i64=PERSPECTIVE_SENSE_SOURCE}, 0, 0, FLAGS, "sense"}, +{ "destination", "specify locations in destination to send corners of source", +0, AV_OPT_TYPE_CONST, {.i64=PERSPECTIVE_SENSE_DESTINATION}, 0, 0, FLAGS, "sense"}, + { NULL } }; @@ -105,7 +117,8 @@ enum { VAR_W, VAR_H, VAR_VARS_NB }; static int config_input(AVFilterLink *inlink) { -double x0, x1, x2, x3, x4, x5, x6, x7, q; +double x0, x1, x2, x3, x4, x5, x6, x7, x8, q; +double t0, t1, t2, t3; AVFilterContext *ctx = inlink->dst; PerspectiveContext *s = ctx->priv; double (*ref)[2] = s->ref; @@ -141,32 +154,64 @@ static int config_input(AVFilterLink *inlink) if (!s->pv) return AVERROR(ENOMEM); -x6 = ((ref[0][0] - ref[1][0] - ref[2][0] + ref[3][0]) * - (ref[2][1] - ref[3][1]) - - ( ref[0][1] - ref[1][1] - ref[2][1] + ref[3][1]) * - (ref[2][0] - ref[3][0])) * h; -x7 = ((ref[0][1] - ref[1][1] - ref[2][1] + ref[3][1]) * - (ref[1][0] - ref[3][0]) - - ( ref[0][0] - ref[1][0] - ref[2][0] + ref[3][0]) * - (ref[1][1] - ref[3][1])) * w; -q = ( ref[1][0] - ref[3][0]) * (ref[2][1] - ref[3][1]) - - ( ref[2][0] - ref[3][0]) * (ref[1][1] - ref[3][1]); - -x0 = q * (ref[1][0] - ref[0][0]) * h + x6 * ref[1][0]; -x1 = q * (ref[2][0] - ref[0][0]) * w + x7 * ref[2][0]; -x2 = q * ref[0][0] * w * h; -x3 = q * (ref[1][1] - ref[0][1]) * h +
Re: [FFmpeg-devel] [PATCH]Mention in the documentation that fieldmatch needs cfr input
> On Wednesday, October 29, 2014 12:25 PM, Carl Eugen Hoyos > wrote: > > Calvin Walton kepstin.ca> writes: > >> For content that was in mpeg2 with field flags set >> appropriate for display on an interlaced TV > > This is unrelated to this issue: > FFmpeg simply ignores the flag and interprets the > input as progressive. > >> which basically accounts for all DVD content > > I live in PAL-country but from user reports and > samples (like the one in question) I know that > this unfortunately isn't true;-( > > This whole issue is about vob files that contain > both progressive 24000/1001 and (hard-) telecined > 3/1001 video in the same stream (with actual > switching frame rates). > It appears to me that decimate should detect the > frame rate changes and not drop anything for the > progressive content. > > Carl Eugen I've also seen mixed hard telecined (24->29.97) and interlaced (29.97) in the same stream, or hard telecined and 29.97 progressive. This whole thing makes me wish we used PAL here. Also metric paper, but that is a different gripe. Not now, but later, I would be interested in helping to adapt decimate to do what we want. A detectfps filter might be useful too, and would be a subset of the work. Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]Mention in the documentation that fieldmatch needs cfr input
> On Wednesday, October 29, 2014 1:33 PM, Carl Eugen Hoyos > wrote: > > Nicholas Robbins ffmpeg.org> writes: > >> Not now, but later, I would be interested in helping to >> adapt decimate to do what we want. A detectfps filter >> might be useful too, and would be a subset of the work. > > I believe if decimate just detects 23.9 -> 29.97 and > 29.97 -> 23.9 it will fix nearly all use cases. > > Carl Eugen If it is running after fieldmatch, then it needs to detect 23.9 29.9 (w 1/5 duplicates duplicates, ouput of fieldmatch on TC material) 29.9 (w/o duplicates, interlaced or progressive, but not TC) A bonus would be to differentiate 29.9 that was originally 23.9 (Film, TC with 3:2) or originally 24.9 (PAL, TC with 3:3:2:2:2) If the input to -vf "fieldmatch,decimate" is mixed 30fps progressive and the result of TC then it decimate will always see 30fps frame rate, but some frames will be duplicated, or am I missing something? -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add setfps filter
> On Thursday, October 15, 2015 7:18 AM, Paul B Mahol wrote: > > On 10/15/15, Nicolas George wrote: >> Le quartidi 24 vendemiaire, an CCXXIV, Paul B Mahol a ecrit : >>> IMHO, it is far easier to use this filter than some complicated setpts >>> expression. >> >> True, but shortcuts in the setpts filter would be a better solution for >> that: having a bunch of filters that do slightly different things with the >> PTS is very bad for users because they have a hard time figuring which one >> is suited for their needs. >> >> (Also, the thing that this setfps filter does is evil, so it should not be >> encouraged.) > > It should duplicate assumefps from avs/vs. How is -vf setfps=24000/1001 different from putting -r 24000/1001 on the input file? -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Past Duration too large
It seems like this is more an ffmpeg-user question. I asked there and got no responses. During some of my encodes, I get quite a lot of these warnings. What do they mean? For example: here is a chuck of the output I am talking about Past duration 0.998009 too large= 718546kB time=01:33:23.23 bitrate=1050.5kbits/s dup=0 drop=7 Past duration 0.994011 too large Past duration 0.990013 too large Past duration 0.92 too large Past duration 0.995995 too large Past duration 0.991997 too large Past duration 0.987999 too large Past duration 0.998009 too large Past duration 0.994011 too large Past duration 0.990013 too large= 718665kB time=01:33:24.54 bitrate=1050.5kbits/s dup=0 drop=7 that repeats pretty much constantly. In a 1h48m encode, it happens 42417 times. What is this telling me? The command is: /usr/bin/ffmpeg -hide_banner -benchmark -i laptop.film.mkv -map 0 -c:a copy -c:s copy -c:v libx264 -preset veryfast -crf 17 -r 24000/1001 laptop.mkv the input file is a mkv with ntsc-film material claiming to be ntsc rate. (23.97 framerate per the frames, but container thinks it is 29.97 fps) I can provide the uncut output if that is helpful. -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/vf_dejudder: use the name 's' for the pointer to the private context
On Thursday, August 20, 2015 3:13 PM, Ganesh Ajjanagadde wrote: > > >On Thu, Aug 20, 2015 at 2:59 PM, Michael Niedermayer > wrote: >> On Thu, Aug 20, 2015 at 02:06:18PM -0400, Ganesh Ajjanagadde wrote: >>> On Thu, Aug 20, 2015 at 1:53 PM, Clément Bœsch wrote: >>> > On Thu, Aug 20, 2015 at 01:10:43PM -0400, Ganesh Ajjanagadde wrote: >>> > [...] >>> >> I know what s is doing, I just fail to see the connection between the >>> >> name >>> >> "s" and "filter private context". >>> > >>> > s originally stands for struct iirc >>> >>> If that is the case, then it is essentially the most uninformative >>> name one can use. >> >>> At least "p" tells us that it is private. >> >> if p means private what would be used for public ? > >Personally I am not in favor of p, >as it is still too ambiguous as you rightly point out. >I instead favor the short abbreviation approach. >Nevertheless, I still consider this better than s, >if people have a non negotiable constraint of requiring a single character. As the original author of the filter. I have absolutely no opinion. -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]doc: Improve fieldmatch documentation
On Wednesday, September 2, 2015 7:50 AM, Carl Eugen Hoyos wrote: >Hi! > >As Clément always pointed out correctly, the issues users see with >fieldmatch and mixed telecined and progressive content have nothing >to do with decimate (and of course not fieldmatch) but with the >specifics of our fps filter (see my ignored mail for details). > >Attached patch should help, please comment. > >Carl Eugen As the author of dejudder it does not produce exactly evenly paced frames. It basically does a rolling average of the last n (default of 4 for pullup 30->24 fps) frames for the PTS of the next frame. If the judder is just noise, and you are using it as denoiser on the PTS's of the input frames, it should work for that. However, it would work better with a larger n. If the PTS's are just randomly noised, then the standard deviation should scale as 1/n. If the judder is periodic, then you want to fit your n to that judder, if you don't know just pick a large n. The default n is 4 which is for the judder of dropping every fifth frame (as pullup does on telecined 23 material) Do you have a sample where dejudder used like this helps? If so does it work better with larger n? Your suggestion is for material that is a mix of 30 fps progressive and 24->30 telecined? I don't know that you would want to decimate that. It will produce judder from the dropped frames. That might be a usecase for the new framerate filter. Or are you offering a suggestion for mixed 24fps progressive and 24->30 telecined? In that case it seems like this should work. You are using dejudder & fps to produce a stream of frames lies ABCDDEFGHH... then decimate drops the dups. Seems brutal. Is there a reason why this filter chain is preferable to pullup,dejudder? (perhaps with fps) or is this just another option? Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]doc: Improve fieldmatch documentation
> On Wednesday, September 2, 2015 5:43 PM, Carl Eugen Hoyos > wrote: > I didn't test because it works fine afaict. Great >> Or are you offering a suggestion for mixed 24fps >> progressive and 24->30 telecined? > > Yes. > >> In that case it seems like this should work. > > This is what my tests showed. > (But I don't have a long sample.) > >> You are using dejudder & fps to produce a stream of >> frames lies ABCDDEFGHH... then decimate drops the >> dups. Seems brutal. > > Why / how? It just seems strange to me to make those extra frames just to throw them away. Seems mean to the frames I guess. But, if it works.. >> Is there a reason why this filter chain is preferable >> to >> pullup,dejudder? (perhaps with fps) or is this >> just another option? > > pullup is a faster alternative that may not produce > perfect output, I don't think it works (or can be used) > with the fps filter (that I consider being broken or at > least showing unexpected behaviour. > > Carl Eugen Ok, good to know. Glad to see anyone besides me is using dejudder. -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]doc: Improve fieldmatch documentation
> On Thursday, September 3, 2015 8:45 AM, Carl Eugen Hoyos > wrote: > > Nicholas Robbins ffmpeg.org> writes: > >> >> You are using dejudder & fps to produce a stream of >> >> frames lies ABCDDEFGHH... then decimate drops the >> >> dups. Seems brutal. >> > >> > Why / how? >> >> It just seems strange to me to make those extra frames >> just to throw them away. Seems mean to the frames I >> guess. But, if it works.. > I meant in the 24fps progressive original. There you start with A/A B/B C/C D/D fps=30 turns it into A/A B/B C/C D/D D/D which decimate turns back into A/A B/B C/C D/D No harm. Just seems like a strange work-around. Your revised documentation is clear to me. -Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add setfps filter
On Friday, October 2, 2015 2:00 PM, Moritz Barsnick wrote: > > >On Fri, Oct 02, 2015 at 19:47:12 +0200, Paul B Mahol wrote: >> fps filter duplicated or removes frames to produce cfr output. >> This filter changes fps and do not remove or duplicate single >> frame so output becomes faster or slower when played when >> fps increase or decrease. > >Ah! So, in other words, it takes input frames, totally disregads their >pts/dts, and puts each one into a cfr output stream at the given fps? > >That solves a lot of problems and ridiculous math. :-) I will try it. > >Cheers, > >Moritz Can't this be accomplished by the setpts filter? Nick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel