Re: [FFmpeg-devel] [PATCH] vf_overlay: Add `timebase` option to set the time base source for the output video.

2016-03-10 Thread Vittorio Gambaletta (VittGam)

On 10/03/2016 19:14:10 CET, Michael Niedermayer wrote:

On Tue, Feb 09, 2016 at 09:12:53PM +0100, Paul B Mahol wrote:

On 1/20/16, Vittorio Gambaletta (VittGam) <ffmpeg-...@vittgam.net> wrote:
> With this commit it is possible to use vf_overlay to center a video over
> a black background, without having to know the video framerate in advance
> and set it as parameter to lavfi.
>
> Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>
> ---
>  doc/filters.texi |   14 ++
>  libavfilter/vf_overlay.c |   14 +-
>  2 files changed, 23 insertions(+), 5 deletions(-)
>

Pardon me, could you give command example where this is useful but
currently does not work,
but does work with this patch applied?


cc-ing the author of the patch ...


Thanks Michael for the CC.

This is useful where you generate the black background with lavfi, so it
is the main video for the overlay, and you don't know the framerate for
the secondary video in advance, but this secondary video is actually the
video that you want to center over the black background. So the "master"
timebase should be set from the secondary video in this case.

This is an example command line. I hope this is the correct one, it should
dynamically center the input video in a 720x400 box with 16:9 aspect ratio.

ffmpeg -f lavfi -i testsrc=s=720x400:r=25 -i {input} -filter_complex '[1:v:0] 
scale=width=min(720\,720/16*9*dar):height=min(400\,720/dar):eval=frame:flags=lanczos
 [out1]; [out1] [0:v:0] 
overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:eval=frame:shortest=1,setdar=r=16/9
 [finalv]' -map finalv -map 1:a:0? {output}

Without the patch, the output video will always have 25 fps. With the patch
and related parameter, it can ignore the 25 and have the framerate of the
overlaid video.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 1/2] ffmpeg_opt: Move the 'process manually set programs' block above 'process manually set metadata' in open_output_file().

2016-01-26 Thread Vittorio Gambaletta (VittGam)
Signed-off-by: Vittorio Gambaletta 
---
 ffmpeg_opt.c |  112 +-
 1 file changed, 56 insertions(+), 56 deletions(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 9b341cf..e03ad89 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -2358,6 +2358,62 @@ loop_end:
 }
 }
 
+/* process manually set programs */
+for (i = 0; i < o->nb_program; i++) {
+const char *p = o->program[i].u.str;
+int progid = i+1;
+AVProgram *program;
+
+while(*p) {
+const char *p2 = av_get_token(, ":");
+char *key;
+if (!p2)
+break;
+if(*p) p++;
+
+key = av_get_token(, "=");
+if (!key || !*p2)
+break;
+p2++;
+
+if (!strcmp(key, "program_num"))
+progid = strtol(p2, NULL, 0);
+}
+
+program = av_new_program(oc, progid);
+
+p = o->program[i].u.str;
+while(*p) {
+const char *p2 = av_get_token(, ":");
+char *key;
+if (!p2)
+break;
+if(*p) p++;
+
+key = av_get_token(, "=");
+if (!key) {
+av_log(NULL, AV_LOG_FATAL,
+   "No '=' character in program string %s.\n",
+   p2);
+exit_program(1);
+}
+if (!*p2)
+exit_program(1);
+p2++;
+
+if (!strcmp(key, "title")) {
+av_dict_set(>metadata, "title", p2, 0);
+} else if (!strcmp(key, "program_num")) {
+} else if (!strcmp(key, "st")) {
+int st_num = strtol(p2, NULL, 0);
+av_program_add_stream_index(oc, progid, st_num);
+} else {
+av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
+exit_program(1);
+}
+}
+}
+
 /* process manually set metadata */
 for (i = 0; i < o->nb_metadata; i++) {
 AVDictionary **m;
@@ -2418,62 +2474,6 @@ loop_end:
 }
 }
 
-/* process manually set programs */
-for (i = 0; i < o->nb_program; i++) {
-const char *p = o->program[i].u.str;
-int progid = i+1;
-AVProgram *program;
-
-while(*p) {
-const char *p2 = av_get_token(, ":");
-char *key;
-if (!p2)
-break;
-if(*p) p++;
-
-key = av_get_token(, "=");
-if (!key || !*p2)
-break;
-p2++;
-
-if (!strcmp(key, "program_num"))
-progid = strtol(p2, NULL, 0);
-}
-
-program = av_new_program(oc, progid);
-
-p = o->program[i].u.str;
-while(*p) {
-const char *p2 = av_get_token(, ":");
-char *key;
-if (!p2)
-break;
-if(*p) p++;
-
-key = av_get_token(, "=");
-if (!key) {
-av_log(NULL, AV_LOG_FATAL,
-   "No '=' character in program string %s.\n",
-   p2);
-exit_program(1);
-}
-if (!*p2)
-exit_program(1);
-p2++;
-
-if (!strcmp(key, "title")) {
-av_dict_set(>metadata, "title", p2, 0);
-} else if (!strcmp(key, "program_num")) {
-} else if (!strcmp(key, "st")) {
-int st_num = strtol(p2, NULL, 0);
-av_program_add_stream_index(oc, progid, st_num);
-} else {
-av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
-exit_program(1);
-}
-}
-}
-
 return 0;
 }
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/2] ffmpeg_opt: Allow -metadata option to set metadata on programs.

2016-01-26 Thread Vittorio Gambaletta (VittGam)
Signed-off-by: Vittorio Gambaletta 
---
 doc/ffmpeg.texi |4 ++--
 ffmpeg_opt.c|7 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index a38a32e..7d3266a 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -339,8 +339,8 @@ see @ref{date syntax,,the Date section in the 
ffmpeg-utils(1) manual,ffmpeg-util
 Set a metadata key/value pair.
 
 An optional @var{metadata_specifier} may be given to set metadata
-on streams or chapters. See @code{-map_metadata} documentation for
-details.
+on streams, chapters or programs. See @code{-map_metadata}
+documentation for details.
 
 This option overrides metadata set with @code{-map_metadata}. It is
 also possible to delete metadata by using an empty value.
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index e03ad89..669976b 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -2466,6 +2466,13 @@ loop_end:
 }
 m = >chapters[index]->metadata;
 break;
+case 'p':
+if (index < 0 || index >= oc->nb_programs) {
+av_log(NULL, AV_LOG_FATAL, "Invalid program index %d in 
metadata specifier.\n", index);
+exit_program(1);
+}
+m = >programs[index]->metadata;
+break;
 default:
 av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", 
o->metadata[i].specifier);
 exit_program(1);
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 2/2] ffmpeg_opt: Allow -metadata option to set metadata on programs.

2016-01-26 Thread Vittorio Gambaletta (VittGam)

Hi,

On 26/01/2016 17:37:56 CET, Michael Niedermayer wrote:

On Tue, Jan 26, 2016 at 03:13:09PM +0100, Vittorio Gambaletta (VittGam) wrote:

Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>
---
 doc/ffmpeg.texi |4 ++--
 ffmpeg_opt.c|7 +++
 2 files changed, 9 insertions(+), 2 deletions(-)


both patches applied

maybe you want to add a fate test for this

thanks


You're welcome!

I'm now going to have a look at FATE.

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavutil/mastering_display_metadata.h: change fields to be rationals as this is how they are typically coded.

2016-01-26 Thread Vittorio Gambaletta (VittGam)

Hi,

On 26/01/2016 22:09:02 CET, Neil Birkbeck wrote:

From: "Vittorio Gambaletta (VittGam)" <ffmpeg-...@vittgam.net>


This is not from me...

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavutil/mastering_display_metadata.h: change fields to be rationals as this is how they are typically coded.

2016-01-26 Thread Vittorio Gambaletta (VittGam)

On 26/01/2016 23:05:22 CET, Neil Birkbeck wrote:

Some sort of squash fail. Apologies.


No problem!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

2016-01-25 Thread Vittorio Gambaletta (VittGam)

Hi,

On 25/01/2016 19:35:58 CET, Michael Niedermayer wrote:

On Sun, Jan 24, 2016 at 03:54:34PM +0100, Vittorio Gambaletta (VittGam) wrote:

Hi,

On 24/01/2016 12:01:38 CET, Michael Niedermayer wrote:
>On Sun, Jan 24, 2016 at 06:06:36AM +0100, Vittorio Gambaletta (VittGam) wrote:
>>Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>
>>---
>> libavformat/mpegtsenc.c |   15 +--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>>diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>>index 2c12043..a20e229 100644
>>--- a/libavformat/mpegtsenc.c
>>+++ b/libavformat/mpegtsenc.c
>>@@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
>> AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", 
NULL, 0);
>>
>> if (s->nb_programs) {
>>-AVProgram *program = av_find_program_from_stream(s, NULL, i);
>>-if (program->id != service->sid)
>>+int j, k, found = 0;
>>+
>>+for (j = 0; j < s->nb_programs; j++)
>>+if (s->programs[j]->id == service->sid) {
>>+for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
>>+if (s->programs[j]->stream_index[k] == i) {
>>+found = 1;
>>+break;
>>+}
>>+break;
>>+}
>
>av_find_program_from_stream() should be run in a loop to enumerate
>the programs, see other uses of av_find_program_from_stream()

Wouldn't this solve the problem backwards?


yes, though it would avoid directly accessing the data structs.
no big problem really though, i see the av_find_program_from_stream()
isnt exactly optimal here
so applied

thanks


You're welcome!

Well, if the same logic needs to be reused somewhere else, it could
always be put in a new function, maybe av_check_stream_is_in_program().

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg_opt: Allow program metadata other than title to be set.

2016-01-24 Thread Vittorio Gambaletta (VittGam)

Hi,

On 24/01/2016 12:33:51 CET, Michael Niedermayer wrote:

On Sun, Jan 24, 2016 at 05:23:22AM +0100, Vittorio Gambaletta (VittGam) wrote:

This commit makes it possible to add optional metadata (such as 
"service_provider") to an mpegts output stream composed by multiple programs 
(mpts).

This is needed because the global metadata is not inherited by the single 
programs.

Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>
---
 ffmpeg_opt.c |   10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)


with this change the whole namespace except "st"/"program_num" would
be used for metadata. This might be a problem in the future if we
want to add some non metadata key/value


What would you suggest then? I have two ideas:

1. Move the 'process manually set programs' block above 'process
   manually set metadata' and have it handle `-metadata:p:`
2. Use a prefix: `-program st=0:st=1:metadata=service_provider=HelloWorld`
3. Change mpegtsenc to look for global metadata if program metadata
   is not present

The first is probably cleaner.

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffmpeg_opt: Allow program metadata other than title to be set.

2016-01-23 Thread Vittorio Gambaletta (VittGam)
This commit makes it possible to add optional metadata (such as 
"service_provider") to an mpegts output stream composed by multiple programs 
(mpts).

This is needed because the global metadata is not inherited by the single 
programs.

Signed-off-by: Vittorio Gambaletta 
---
 ffmpeg_opt.c |   10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 9b341cf..286c182 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -2461,15 +2461,11 @@ loop_end:
 exit_program(1);
 p2++;
 
-if (!strcmp(key, "title")) {
-av_dict_set(>metadata, "title", p2, 0);
-} else if (!strcmp(key, "program_num")) {
-} else if (!strcmp(key, "st")) {
+if (!strcmp(key, "st")) {
 int st_num = strtol(p2, NULL, 0);
 av_program_add_stream_index(oc, progid, st_num);
-} else {
-av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key);
-exit_program(1);
+} else if (strcmp(key, "program_num")) {
+av_dict_set(>metadata, key, p2, 0);
 }
 }
 }
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

2016-01-23 Thread Vittorio Gambaletta (VittGam)
Signed-off-by: Vittorio Gambaletta 
---
 libavformat/mpegtsenc.c |   15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 2c12043..a20e229 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);
 
 if (s->nb_programs) {
-AVProgram *program = av_find_program_from_stream(s, NULL, i);
-if (program->id != service->sid)
+int j, k, found = 0;
+
+for (j = 0; j < s->nb_programs; j++)
+if (s->programs[j]->id == service->sid) {
+for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
+if (s->programs[j]->stream_index[k] == i) {
+found = 1;
+break;
+}
+break;
+}
+
+if (!found)
 continue;
 }
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] vf_overlay: Add `timebase` option to set the time base source for the output video.

2016-01-20 Thread Vittorio Gambaletta (VittGam)
With this commit it is possible to use vf_overlay to center a video over
a black background, without having to know the video framerate in advance
and set it as parameter to lavfi.

Signed-off-by: Vittorio Gambaletta 
---
 doc/filters.texi |   14 ++
 libavfilter/vf_overlay.c |   14 +-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index f5f4bfc..e12f476 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8646,6 +8646,20 @@ main input until the end of the stream. A value of 0 
disables this
 behavior. Default value is 1.
 @end table
 
+@item timebase
+Set the time base source for the output video.
+
+It accepts the following values:
+@table @samp
+@item main
+use main input as time base source
+
+@item overlay
+use overlay input as time base source
+@end table
+
+Default value is @samp{main}.
+
 The @option{x}, and @option{y} expressions can contain the following
 parameters.
 
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 3eac7f0..c6cd4ce 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -119,6 +119,7 @@ typedef struct OverlayContext {
 uint8_t overlay_has_alpha;
 int format; ///< OverlayFormat
 int eval_mode;  ///< EvalMode
+int time_base;  ///< MAIN or OVERLAY
 
 FFDualInputContext dinput;
 
@@ -379,7 +380,7 @@ static int config_output(AVFilterLink *outlink)
 
 outlink->w = ctx->inputs[MAIN]->w;
 outlink->h = ctx->inputs[MAIN]->h;
-outlink->time_base = ctx->inputs[MAIN]->time_base;
+outlink->time_base = ctx->inputs[s->time_base]->time_base;
 
 return 0;
 }
@@ -589,14 +590,14 @@ static AVFrame *do_blend(AVFilterContext *ctx, AVFrame 
*mainpic,
  const AVFrame *second)
 {
 OverlayContext *s = ctx->priv;
-AVFilterLink *inlink = ctx->inputs[0];
 
 if (s->eval_mode == EVAL_MODE_FRAME) {
-int64_t pos = av_frame_get_pkt_pos(mainpic);
+AVFilterLink *inlink = ctx->inputs[s->time_base];
+int64_t pts = s->time_base ? second->pts : mainpic->pts;
+int64_t pos = av_frame_get_pkt_pos(s->time_base ? second : mainpic);
 
 s->var_values[VAR_N] = inlink->frame_count;
-s->var_values[VAR_T] = mainpic->pts == AV_NOPTS_VALUE ?
-NAN : mainpic->pts * av_q2d(inlink->time_base);
+s->var_values[VAR_T] = pts == AV_NOPTS_VALUE ? NAN : pts * 
av_q2d(inlink->time_base);
 s->var_values[VAR_POS] = pos == -1 ? NAN : pos;
 
 s->var_values[VAR_OVERLAY_W] = s->var_values[VAR_OW] = second->width;
@@ -673,6 +674,9 @@ static const AVOption overlay_options[] = {
 { "yuv444", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV444}, 
.flags = FLAGS, .unit = "format" },
 { "rgb","", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_RGB},
.flags = FLAGS, .unit = "format" },
 { "repeatlast", "repeat overlay of the last overlay frame", 
OFFSET(dinput.repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
+{ "timebase", "set time base source", OFFSET(time_base), AV_OPT_TYPE_INT, 
{.i64 = MAIN}, MAIN, OVERLAY, FLAGS, "timebase" },
+ { "main","use main input as time base source",0, 
AV_OPT_TYPE_CONST, {.i64=MAIN},.flags = FLAGS, .unit = "timebase" },
+ { "overlay", "use overlay input as time base source", 0, 
AV_OPT_TYPE_CONST, {.i64=OVERLAY}, .flags = FLAGS, .unit = "timebase" },
 { NULL }
 };
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffplay: Update docs after previous changes in ffplay mouse behaviour.

2016-01-19 Thread Vittorio Gambaletta (VittGam)
Signed-off-by: Vittorio Gambaletta 

---
 doc/ffplay.texi |5 -
 ffplay.c|3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index 2a35c21..4bc3ced 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -238,9 +238,12 @@ Seek to the previous/next chapter.
 or if there are no chapters
 Seek backward/forward 10 minutes.
 
-@item mouse click
+@item right mouse click
 Seek to percentage in file corresponding to fraction of width.
 
+@item left mouse double-click
+Toggle full screen.
+
 @end table
 
 @c man end
diff --git a/ffplay.c b/ffplay.c
index 5b473e9..2cfdf26 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3738,7 +3738,8 @@ void show_help_default(const char *opt, const char *arg)
"left/right  seek backward/forward 10 seconds\n"
"down/up seek backward/forward 1 minute\n"
"page down/page up   seek backward/forward 10 minutes\n"
-   "mouse click seek to percentage in file corresponding to 
fraction of width\n"
+   "right mouse click   seek to percentage in file corresponding to 
fraction of width\n"
+   "left double-click   toggle full screen\n"
);
 }
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 2/2] ffplay: Toggle full screen when double-clicking the video window with the left mouse button.

2016-01-19 Thread Vittorio Gambaletta (VittGam)

On 19/01/2016 23:40:22 CET, Marton Balint wrote:

On Tue, 19 Jan 2016, Marton Balint wrote:



On Tue, 19 Jan 2016, Vittorio Gambaletta (VittGam) wrote:


Now that the seek only happens with the right mouse button, it makes
sense to toggle full screen when double-clicking with the left mouse
button, like other video players do.

Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>



Thanks, applied.



Hmm, on second thought we forgot the docs update in ffplay.c and in 
doc/ffplay.texi. Could you send a patch for that as well?


Sure! Will do now.

Thanks,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 2/2] ffplay: Toggle full screen when double-clicking the video window with the left mouse button.

2016-01-18 Thread Vittorio Gambaletta (VittGam)
Now that the seek only happens with the right mouse button, it makes
sense to toggle full screen when double-clicking with the left mouse
button, like other video players do.

Signed-off-by: Vittorio Gambaletta 

---
 Changelog |1 +
 ffplay.c  |   10 ++
 2 files changed, 11 insertions(+)

diff --git a/Changelog b/Changelog
index d458991..59bfbb1 100644
--- a/Changelog
+++ b/Changelog
@@ -55,6 +55,7 @@ version :
 - spectrumsynth filter
 - ahistogram filter
 - only seek with the right mouse button in ffplay
+- toggle full screen when double-clicking with the left mouse button in ffplay
 
 
 version 2.8:
diff --git a/ffplay.c b/ffplay.c
index 2fa7165..5b473e9 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3473,6 +3473,16 @@ static void event_loop(VideoState *cur_stream)
 do_exit(cur_stream);
 break;
 }
+if (event.button.button == SDL_BUTTON_LEFT) {
+static int64_t last_mouse_left_click = 0;
+if (av_gettime_relative() - last_mouse_left_click <= 50) {
+toggle_full_screen(cur_stream);
+cur_stream->force_refresh = 1;
+last_mouse_left_click = 0;
+} else {
+last_mouse_left_click = av_gettime_relative();
+}
+}
 case SDL_MOUSEMOTION:
 if (cursor_hidden) {
 SDL_ShowCursor(1);
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 1/2] ffplay: Seek only when pressing the right mouse button on the video window.

2016-01-18 Thread Vittorio Gambaletta (VittGam)
Seeking by clicking on the video window can be annoying, because
the user might click on it accidentally while eg. trying to get
focus on it, and ffplay seeks instead.

This commit changes that behaviour to seek only when the right
mouse button is used to click and drag on the window.

Signed-off-by: Vittorio Gambaletta 

---
 Changelog |1 +
 ffplay.c  |4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index ed18cf1..d458991 100644
--- a/Changelog
+++ b/Changelog
@@ -54,6 +54,7 @@ version :
 - libstagefright support removed
 - spectrumsynth filter
 - ahistogram filter
+- only seek with the right mouse button in ffplay
 
 
 version 2.8:
diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..2fa7165 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3480,9 +3480,11 @@ static void event_loop(VideoState *cur_stream)
 }
 cursor_last_shown = av_gettime_relative();
 if (event.type == SDL_MOUSEBUTTONDOWN) {
+if (event.button.button != SDL_BUTTON_RIGHT)
+break;
 x = event.button.x;
 } else {
-if (event.motion.state != SDL_PRESSED)
+if (!(event.motion.state & SDL_BUTTON_RMASK))
 break;
 x = event.motion.x;
 }
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 1/2] ffplay: Seek only when pressing the right mouse button on the video window.

2016-01-16 Thread Vittorio Gambaletta (VittGam)

Hi,

It seems to me that whitespace was right on my end in the other
patches...

This time I've literally piped the mails to my mailserver using
netcat, like I always do with OpenWrt patches anyway, so please
check if I'm still getting something wrong with whitespace now.

Thank you,
Vittorio

On 16/01/2016 22:41:30 CET, Vittorio Gambaletta (VittGam) wrote:

Seeking by clicking on the video window can be annoying, because
the user might click on it accidentally while eg. trying to get
focus on it, and ffplay seeks instead.

This commit changes that behaviour to seek only when the right
mouse button is used to click and drag on the window.

Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>

---
 ffplay.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..2fa7165 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3480,9 +3480,11 @@ static void event_loop(VideoState *cur_stream)
 }
 cursor_last_shown = av_gettime_relative();
 if (event.type == SDL_MOUSEBUTTONDOWN) {
+if (event.button.button != SDL_BUTTON_RIGHT)
+break;
 x = event.button.x;
 } else {
-if (event.motion.state != SDL_PRESSED)
+if (!(event.motion.state & SDL_BUTTON_RMASK))
 break;
 x = event.motion.x;
 }
___
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


Re: [FFmpeg-devel] [PATCH 2/2] ffplay: Toggle full screen when double-clicking the video window with the left mouse button.

2016-01-16 Thread Vittorio Gambaletta (VittGam)

Hi,

On 16/01/2016 21:25:00 CET, Marton Balint wrote:

On Fri, 15 Jan 2016, Vittorio Gambaletta (VittGam) wrote:

Now that the seek only happens with the right mouse button, it makes
sense to toggle full screen when double-clicking with the left mouse
button, like other video players do.



I am not against this.


Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>

---
 ffplay.c |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/ffplay.c b/ffplay.c
index 2fa7165..582ca39 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3473,6 +3473,24 @@ static void event_loop(VideoState *cur_stream)
 do_exit(cur_stream);
 break;
 }
+{


Whitespace and indentation seems messed up in this patch as well.


+static int mouse_left_click_status = 0;
+static double mouse_left_click_last_x, mouse_left_click_last_y;
+if (event.button.button == SDL_BUTTON_LEFT) {
+if (mouse_left_click_status == 1 && av_gettime_relative() - 
cursor_last_shown <= 50
+&& fabs(event.button.x - mouse_left_click_last_x) <= 1 && 
fabs(event.button.y - mouse_left_click_last_y) <= 1) {
+toggle_full_screen(cur_stream);
+cur_stream->force_refresh = 1;
+mouse_left_click_status = 0;
+} else {
+mouse_left_click_status = 1;
+mouse_left_click_last_x = event.button.x;
+mouse_left_click_last_y = event.button.y;
+}
+} else {
+mouse_left_click_status = 0;
+}
+}


I don't think we need the complex stuff about not clicking too far out of the 
first click, what are the chances of a fast moving mouse with double clicking? 
Slim to none I guess. Are you aware of a case when this matters?


I don't know, I just looked at how the click counter is implemented in SDL2 and 
emulated that behaviour with SDL1. But it can be overkill, yes; in fact VLC 
does not seem to check this.

By the way, VLC doesn't even clear the status/timestamp when clicking another 
button, so maybe that is overkill too.


I think it is enough if you just store the timestamp of the last left click in 
an int64_t and check the time difference next time the user do a left click, 
this way you can detect double clicking with a single variable and you don't 
have to use cursor_last_shown which is updated on every motion as well.


Right, also I didn't think twice about the fact that cursor_last_shown is 
updated on motion too.

Thanks for the suggestions, I will send an updated patch soon.

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] ffplay: Seek only when pressing the right mouse button on the video window.

2016-01-16 Thread Vittorio Gambaletta (VittGam)

Hi,

On 16/01/2016 21:13:14 CET, Marton Balint wrote:

On Fri, 15 Jan 2016, Vittorio Gambaletta (VittGam) wrote:


Seeking by clicking on the video window can be annoying, because
the user might click on it accidentally while eg. trying to get
focus on it, and ffplay seeks instead.

This commit changes that behaviour to seek only when the right
mouse button is used to click and drag on the window.

Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>



Looks good, I will apply in a few days if no one steps up against it.

However your patch seem to have some whitespace errors probably caused by your 
mailer, and because of that it does not apply cleanly so you might consider 
sending patches next time as an attachment if your mailer messes something up 
inline.


Thank you for your suggestion, I thought I finally fixed that problem with my 
mailer while in fact I failed again...

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 1/2] ffplay: Seek only when pressing the right mouse button on the video window.

2016-01-16 Thread Vittorio Gambaletta (VittGam)
Seeking by clicking on the video window can be annoying, because
the user might click on it accidentally while eg. trying to get
focus on it, and ffplay seeks instead.

This commit changes that behaviour to seek only when the right
mouse button is used to click and drag on the window.

Signed-off-by: Vittorio Gambaletta 

---
 ffplay.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..2fa7165 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3480,9 +3480,11 @@ static void event_loop(VideoState *cur_stream)
 }
 cursor_last_shown = av_gettime_relative();
 if (event.type == SDL_MOUSEBUTTONDOWN) {
+if (event.button.button != SDL_BUTTON_RIGHT)
+break;
 x = event.button.x;
 } else {
-if (event.motion.state != SDL_PRESSED)
+if (!(event.motion.state & SDL_BUTTON_RMASK))
 break;
 x = event.motion.x;
 }
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/2] ffplay: Toggle full screen when double-clicking the video window with the left mouse button.

2016-01-16 Thread Vittorio Gambaletta (VittGam)
Now that the seek only happens with the right mouse button, it makes
sense to toggle full screen when double-clicking with the left mouse
button, like other video players do.

Signed-off-by: Vittorio Gambaletta 

---
 ffplay.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/ffplay.c b/ffplay.c
index 2fa7165..5b473e9 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3473,6 +3473,16 @@ static void event_loop(VideoState *cur_stream)
 do_exit(cur_stream);
 break;
 }
+if (event.button.button == SDL_BUTTON_LEFT) {
+static int64_t last_mouse_left_click = 0;
+if (av_gettime_relative() - last_mouse_left_click <= 50) {
+toggle_full_screen(cur_stream);
+cur_stream->force_refresh = 1;
+last_mouse_left_click = 0;
+} else {
+last_mouse_left_click = av_gettime_relative();
+}
+}
 case SDL_MOUSEMOTION:
 if (cursor_hidden) {
 SDL_ShowCursor(1);
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] ffplay: Seek only when pressing the right mouse button on the video window.

2016-01-15 Thread Vittorio Gambaletta (VittGam)

Seeking by clicking on the video window can be annoying, because
the user might click on it accidentally while eg. trying to get
focus on it, and ffplay seeks instead.

This commit changes that behaviour to seek only when the right
mouse button is used to click and drag on the window.

Signed-off-by: Vittorio Gambaletta 

---
 ffplay.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..2fa7165 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3480,9 +3480,11 @@ static void event_loop(VideoState *cur_stream)
 }
 cursor_last_shown = av_gettime_relative();
 if (event.type == SDL_MOUSEBUTTONDOWN) {
+if (event.button.button != SDL_BUTTON_RIGHT)
+break;
 x = event.button.x;
 } else {
-if (event.motion.state != SDL_PRESSED)
+if (!(event.motion.state & SDL_BUTTON_RMASK))
 break;
 x = event.motion.x;
 }
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] ffplay: Toggle full screen when double-clicking the video window with the left mouse button.

2016-01-15 Thread Vittorio Gambaletta (VittGam)

Now that the seek only happens with the right mouse button, it makes
sense to toggle full screen when double-clicking with the left mouse
button, like other video players do.

Signed-off-by: Vittorio Gambaletta 

---
 ffplay.c |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/ffplay.c b/ffplay.c
index 2fa7165..582ca39 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3473,6 +3473,24 @@ static void event_loop(VideoState *cur_stream)
 do_exit(cur_stream);
 break;
 }
+{
+static int mouse_left_click_status = 0;
+static double mouse_left_click_last_x, mouse_left_click_last_y;
+if (event.button.button == SDL_BUTTON_LEFT) {
+if (mouse_left_click_status == 1 && av_gettime_relative() - 
cursor_last_shown <= 50
+&& fabs(event.button.x - mouse_left_click_last_x) <= 1 && 
fabs(event.button.y - mouse_left_click_last_y) <= 1) {
+toggle_full_screen(cur_stream);
+cur_stream->force_refresh = 1;
+mouse_left_click_status = 0;
+} else {
+mouse_left_click_status = 1;
+mouse_left_click_last_x = event.button.x;
+mouse_left_click_last_y = event.button.y;
+}
+} else {
+mouse_left_click_status = 0;
+}
+}
 case SDL_MOUSEMOTION:
 if (cursor_hidden) {
 SDL_ShowCursor(1);
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffplay: Add ignore_keydown and ignore_mousedown options.

2016-01-14 Thread Vittorio Gambaletta (VittGam)

On 15/01/2016 00:09:37 CET, Ganesh Ajjanagadde wrote:

On Thu, Jan 14, 2016 at 6:05 PM, Marton Balint  wrote:

[..]
I think it would make sense to change ffplay so that only the right mouse
button would seek. This way we can avoid the issue. Anybody against this?


Kind of, it is slightly easier to tap the trackpad on my laptop than
to right click ;). But this may also be viewed as a negative, it is
quite easy to accidentally do it, and I have done that myself some
times.
In summary, can't think of a better idea myself, and I view it as a
cleaner solution than the proposed patch.


So, something like this:

diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..0ec98c6 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3480,9 +3480,11 @@ static void event_loop(VideoState *cur_stream)
 }
 cursor_last_shown = av_gettime_relative();
 if (event.type == SDL_MOUSEBUTTONDOWN) {
+if (event.button.button != SDL_BUTTON_RIGHT)
+break;
 x = event.button.x;
 } else {
-if (event.motion.state != SDL_PRESSED)
+if (event.motion.state != SDL_PRESSED || event.motion.button 
!= SDL_BUTTON_RIGHT)
 break;
 x = event.motion.x;
 }
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffplay: Add ignore_keydown and ignore_mousedown options.

2016-01-14 Thread Vittorio Gambaletta (VittGam)

Hi,

On 14/01/2016 23:15:16 CET, Ganesh Ajjanagadde wrote:

On Thu, Jan 14, 2016 at 3:56 PM, Vittorio Gambaletta (VittGam)
<ffmpeg-...@vittgam.net> wrote:

---
 ffplay.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..0837d58 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -336,6 +336,8 @@ static int decoder_reorder_pts = -1;
 static int autoexit;
 static int exit_on_keydown;
 static int exit_on_mousedown;
+static int ignore_keydown;
+static int ignore_mousedown;
 static int loop = 1;
 static int framedrop = -1;
 static int infinite_buffer = -1;
@@ -3357,6 +3359,9 @@ static void event_loop(VideoState *cur_stream)
 do_exit(cur_stream);
 break;
 }
+if (ignore_keydown) {
+break;
+}
 switch (event.key.keysym.sym) {
 case SDLK_ESCAPE:
 case SDLK_q:
@@ -3479,6 +3484,9 @@ static void event_loop(VideoState *cur_stream)
 cursor_hidden = 0;
 }
 cursor_last_shown = av_gettime_relative();
+if (ignore_mousedown) {
+break;
+}
 if (event.type == SDL_MOUSEBUTTONDOWN) {
 x = event.button.x;
 } else {
@@ -3669,6 +3677,8 @@ static const OptionDef options[] = {
 { "autoexit", OPT_BOOL | OPT_EXPERT, {  }, "exit at the end", "" 
},
 { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { _on_keydown }, "exit on key down", 
"" },
 { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { _on_mousedown }, "exit on mouse 
down", "" },
+{ "ignorekeydown", OPT_BOOL | OPT_EXPERT, { _keydown }, "don't act on key 
presses", "" },
+{ "ignoremousedown", OPT_BOOL | OPT_EXPERT, { _mousedown }, "don't seek on mouse 
down", "" },
 { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, {  }, "set number of times the playback 
shall be looped", "loop count" },
 { "framedrop", OPT_BOOL | OPT_EXPERT, {  }, "drop frames when cpu is too 
slow", "" },
 { "infbuf", OPT_BOOL | OPT_EXPERT, { _buffer }, "don't limit the input buffer 
size (useful with realtime streams)", "" },


I see no harm, but a new option should have a justification in the
commit message, i.e why do you want it, or what is your use case?


I find seeking by clicking on the video window annoying, because I
usually click on it to get focus on the window, and it seeks instead.

ignorekeydown is the complement of ignoremousedown.

Should I resend the patch with this comment?

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffplay: Add ignore_keydown and ignore_mousedown options.

2016-01-14 Thread Vittorio Gambaletta (VittGam)
---
 ffplay.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/ffplay.c b/ffplay.c
index d2e3dc6..0837d58 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -336,6 +336,8 @@ static int decoder_reorder_pts = -1;
 static int autoexit;
 static int exit_on_keydown;
 static int exit_on_mousedown;
+static int ignore_keydown;
+static int ignore_mousedown;
 static int loop = 1;
 static int framedrop = -1;
 static int infinite_buffer = -1;
@@ -3357,6 +3359,9 @@ static void event_loop(VideoState *cur_stream)
 do_exit(cur_stream);
 break;
 }
+if (ignore_keydown) {
+break;
+}
 switch (event.key.keysym.sym) {
 case SDLK_ESCAPE:
 case SDLK_q:
@@ -3479,6 +3484,9 @@ static void event_loop(VideoState *cur_stream)
 cursor_hidden = 0;
 }
 cursor_last_shown = av_gettime_relative();
+if (ignore_mousedown) {
+break;
+}
 if (event.type == SDL_MOUSEBUTTONDOWN) {
 x = event.button.x;
 } else {
@@ -3669,6 +3677,8 @@ static const OptionDef options[] = {
 { "autoexit", OPT_BOOL | OPT_EXPERT, {  }, "exit at the end", "" 
},
 { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { _on_keydown }, "exit on 
key down", "" },
 { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { _on_mousedown }, "exit 
on mouse down", "" },
+{ "ignorekeydown", OPT_BOOL | OPT_EXPERT, { _keydown }, "don't act 
on key presses", "" },
+{ "ignoremousedown", OPT_BOOL | OPT_EXPERT, { _mousedown }, "don't 
seek on mouse down", "" },
 { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, {  }, "set number of times 
the playback shall be looped", "loop count" },
 { "framedrop", OPT_BOOL | OPT_EXPERT, {  }, "drop frames when 
cpu is too slow", "" },
 { "infbuf", OPT_BOOL | OPT_EXPERT, { _buffer }, "don't limit the 
input buffer size (useful with realtime streams)", "" },
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Revert "matroskaenc: refuse to write AAC without valid extradata"

2015-09-21 Thread Vittorio Gambaletta (VittGam)

On 21/09/2015 12:15:48 CEST, Hendrik Leppkes wrote:

AAC without extradata is invalid, there is no discussion about that.
As wm4 says, just because ffmpeg accepts it anyway doesn't really change that.


Ok. So, how can I check that the resulting file actually has missing AAC 
extradata,
despite ffmpeg not complaining about it when fed with the output file?

The sample rate is definitely there in the output file, so ffmpeg might be just
reconstructing it from the other data it has:


Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)


If you need sample files I can provide them privately. It's broadcast mpeg-ts,
anyway.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Revert "matroskaenc: refuse to write AAC without valid extradata"

2015-09-21 Thread Vittorio Gambaletta (VittGam)

Il 21.09.2015 07:39:24 Ronald S. Bultje ha scritto:

Is this still necessary if you use the adtstoaasc bitstream filter?


Yes.

Il 21.09.2015 09:45:55 Hendrik Leppkes ha scritto:

Simply reverting and thus allowing broken files to be created once
again is not a good idea. I recommend to properly fix the problem and
not just revert.


The fact is that reverting seems to produce valid files anyway.

If I feed the "broken" output file to ffmpeg -i, the audio samplerate is
correctly shown, and there's no other warning about this issue.

Maybe it's just the input file that's broken (it is, since it also has
borked h264 timestamps...), but then ffmpeg is able to produce valid
Matroska files anyway.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel