Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-17 Thread Michael Niedermayer
On Tue, Mar 17, 2015 at 07:44:54AM -0500, Jeremy Luce wrote:
 It appears that c/C doesn't pause the input threads, which results in
 higher CPU usage than the 'p' pause method. Also, since the input
 threads continue to read data, the input buffer will continue to grow,
 which may lead to undesirable results. I'm not sure if this is by
 design or not, so I'm hesitant to attempt to fix it. These are the
 main reasons why my method was implemented differently than c/C.
 
 If I were to add some visual feedback for 'p', is there anything I
 could tweak that would make you more comfortable with this approach?
 If not, would pausing the input threads on c/C be a viable option?

i think pausing the input threads with c/C is what should be done

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-17 Thread Jeremy Luce
It appears that c/C doesn't pause the input threads, which results in
higher CPU usage than the 'p' pause method. Also, since the input
threads continue to read data, the input buffer will continue to grow,
which may lead to undesirable results. I'm not sure if this is by
design or not, so I'm hesitant to attempt to fix it. These are the
main reasons why my method was implemented differently than c/C.

If I were to add some visual feedback for 'p', is there anything I
could tweak that would make you more comfortable with this approach?
If not, would pausing the input threads on c/C be a viable option?

Jeremy


 it seems any key unpauses transcoding

 also theres no vissual feedback that ffmpeg is paused or how the
 user can unpause it
 this is bad in case the user pressed p by mistake

 also the c and C keys already effectivly pause ffmpeg
 p should not be implemented entirely differently than how they work.
 If c/C have problems these problems should be fixed

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


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-16 Thread Jeremy Luce
Here is the updated patch with documentation and proper line breaks.
Jeremy


On Fri, Mar 13, 2015 at 1:02 PM, Michael Niedermayer michae...@gmx.at wrote:
 On Wed, Mar 11, 2015 at 08:34:39AM -0500, Jeremy Luce wrote:
 Resubmitting with [PATCH] tag and unified diff.

 Adds functionality to pause transcoding with 'p' key and upause with 'u'
 key over stdin. Pauses in the main transcode loop as well as the
 input_thread loop.
 [...]

 @@ -3346,7 +3371,9 @@ static int check_keyboard_interaction(int64_t cur_time)
  C  Send/Que command to all matching filters\n
  D  cycle through available debug modes\n
  h  dump packets/hex press to cycle
 through the 3 states\n
 +p  pause transcoding\n

 this looks like the diff has been corrupted with line breaks

 also this is missing documentation in doc/*

 [...]
 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 I am the wisest man alive, for I know one thing, and that is that I know
 nothing. -- Socrates

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

From 8d7f26a99ea0f189968c483b0d5f0cc09a98b5d6 Mon Sep 17 00:00:00 2001
From: jluce50 jeremyl...@gmail.com
Date: Fri, 6 Mar 2015 17:13:40 -0600
Subject: [PATCH] Add pause/resume via keyboard interaction. Docs updated to
 include keyboard interaction (incl. new pause commands)

---
 doc/ffmpeg.texi | 38 ++
 ffmpeg.c| 51 ++-
 2 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 6772f2f..0001144 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1276,6 +1276,44 @@ search for the file @file{libvpx-1080p.avpreset}.
 If no such file is found, then ffmpeg will search for a file named
 @var{arg}.avpreset in the same directories.
 
+@section While transcoding
+
+@table @key
+@item ?
+show help
+
+@item +
+increase verbosity
+
+@item -
+decrease verbosity
+
+@item d
+send command to first matching filter supporting it
+
+@item C
+send/queue command to all matching filters
+
+@item D
+cycle through available debug modes
+
+@item h
+packets/hex press to cycle through the 3 states
+
+@item p
+pause transcoding
+
+@item q
+quit
+
+@item u
+unpause transcoding
+
+@item s
+Show QP histogram
+
+@end table
+
 @c man end OPTIONS
 
 @chapter Tips
diff --git a/ffmpeg.c b/ffmpeg.c
index 6604ff0..37b351a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -120,6 +120,9 @@ const char *const forced_keyframes_const_names[] = {
 static void do_video_stats(OutputStream *ost, int frame_size);
 static int64_t getutime(void);
 static int64_t getmaxrss(void);
+static int64_t gettime_relative_minus_pause(void);
+static void pause_transcoding(void);
+static void unpause_transcoding(void);
 
 static int run_as_daemon  = 0;
 static int nb_frames_dup = 0;
@@ -146,6 +149,9 @@ int nb_output_files   = 0;
 FilterGraph **filtergraphs;
 intnb_filtergraphs;
 
+int64_t paused_start = 0;
+int64_t paused_time = 0;
+
 #if HAVE_TERMIOS_H
 
 /* init terminal so that we can grab keys */
@@ -1447,7 +1453,6 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
 last_time = cur_time;
 }
 
-
 oc = output_files[0]-ctx;
 
 total_size = avio_size(oc-pb);
@@ -3256,18 +3261,38 @@ static OutputStream *choose_output(void)
 return ost_min;
 }
 
+static void pause_transcoding(void)
+{
+if (!paused_start)
+paused_start = av_gettime_relative();
+}
+
+static void unpause_transcoding(void)
+{
+if (paused_start) {
+paused_time += av_gettime_relative() - paused_start;
+paused_start = 0;
+}
+}
+
 static int check_keyboard_interaction(int64_t cur_time)
 {
 int i, ret, key;
 static int64_t last_time;
-if (received_nb_signals)
+if (received_nb_signals) {
+unpause_transcoding();
 return AVERROR_EXIT;
+}
 /* read_key() returns 0 on EOF */
 if(cur_time - last_time = 10  !run_as_daemon){
 key =  read_key();
 last_time = cur_time;
 }else
 key = -1;
+// Reserve 'u' for unpausing a paused transcode, but allow any key to
+// unpause for backward compatibility
+if (key == 'u' || key != -1) unpause_transcoding();
+if (key == 'p') pause_transcoding();
 if (key == 'q')
 return AVERROR_EXIT;
 if (key == '+') av_log_set_level(av_log_get_level()+10);
@@ -3346,7 +3371,9 @@ static int check_keyboard_interaction(int64_t cur_time)
 C  Send/Que command to all matching filters\n
 D  cycle through available debug modes\n
 h  dump packets/hex press to cycle through the 3 states\n
+p  pause transcoding\n
 

Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-16 Thread Michael Niedermayer
On Mon, Mar 16, 2015 at 11:23:33AM -0500, Jeremy Luce wrote:
 Here is the updated patch with documentation and proper line breaks.
 Jeremy
 
 
 On Fri, Mar 13, 2015 at 1:02 PM, Michael Niedermayer michae...@gmx.at wrote:
  On Wed, Mar 11, 2015 at 08:34:39AM -0500, Jeremy Luce wrote:
  Resubmitting with [PATCH] tag and unified diff.
 
  Adds functionality to pause transcoding with 'p' key and upause with 'u'
  key over stdin. Pauses in the main transcode loop as well as the
  input_thread loop.
  [...]
 
  @@ -3346,7 +3371,9 @@ static int check_keyboard_interaction(int64_t 
  cur_time)
   C  Send/Que command to all matching 
  filters\n
   D  cycle through available debug modes\n
   h  dump packets/hex press to cycle
  through the 3 states\n
  +p  pause transcoding\n
 
  this looks like the diff has been corrupted with line breaks
 
  also this is missing documentation in doc/*
 
  [...]
  --
  Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
 
  I am the wisest man alive, for I know one thing, and that is that I know
  nothing. -- Socrates
 
  ___
  ffmpeg-devel mailing list
  ffmpeg-devel@ffmpeg.org
  http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 

  doc/ffmpeg.texi |   38 ++
  ffmpeg.c|   51 ++-
  2 files changed, 84 insertions(+), 5 deletions(-)
 f4321165de7a06c32e23b05989016f5e9d5158e0  
 0001-Add-pause-resume-via-keyboard-interaction.patch
 From 8d7f26a99ea0f189968c483b0d5f0cc09a98b5d6 Mon Sep 17 00:00:00 2001
 From: jluce50 jeremyl...@gmail.com
 Date: Fri, 6 Mar 2015 17:13:40 -0600
 Subject: [PATCH] Add pause/resume via keyboard interaction. Docs updated to
  include keyboard interaction (incl. new pause commands)




 
 ---
  doc/ffmpeg.texi | 38 ++
  ffmpeg.c| 51 ++-
  2 files changed, 84 insertions(+), 5 deletions(-)
 
 diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
 index 6772f2f..0001144 100644
 --- a/doc/ffmpeg.texi
 +++ b/doc/ffmpeg.texi
 @@ -1276,6 +1276,44 @@ search for the file @file{libvpx-1080p.avpreset}.
  If no such file is found, then ffmpeg will search for a file named
  @var{arg}.avpreset in the same directories.
  
 +@section While transcoding
 +
 +@table @key
 +@item ?
 +show help
 +
 +@item +
 +increase verbosity
 +
 +@item -
 +decrease verbosity
 +
 +@item d
 +send command to first matching filter supporting it
 +
 +@item C
 +send/queue command to all matching filters
 +
 +@item D
 +cycle through available debug modes
 +
 +@item h
 +packets/hex press to cycle through the 3 states
 +
 +@item p
 +pause transcoding
 +
 +@item q
 +quit
 +

 +@item u
 +unpause transcoding

it seems any key unpauses transcoding

also theres no vissual feedback that ffmpeg is paused or how the
user can unpause it
this is bad in case the user pressed p by mistake

also the c and C keys already effectivly pause ffmpeg
p should not be implemented entirely differently than how they work.
If c/C have problems these problems should be fixed

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-14 Thread compn
On Wed, 11 Mar 2015 08:34:39 -0500
Jeremy Luce jeremyl...@gmail.com wrote:

 Resubmitting with [PATCH] tag and unified diff.
 
 Adds functionality to pause transcoding with 'p' key and upause with
 'u' key over stdin. Pauses in the main transcode loop as well as the
 input_thread loop.

did not review patch, idea sounds good.

what about ability to pause job to file ? like you have to reboot but
you are in the middle of a encoding job. it would write to a file and
resume with some option.

-compn
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-13 Thread Michael Niedermayer
On Wed, Mar 11, 2015 at 08:34:39AM -0500, Jeremy Luce wrote:
 Resubmitting with [PATCH] tag and unified diff.
 
 Adds functionality to pause transcoding with 'p' key and upause with 'u'
 key over stdin. Pauses in the main transcode loop as well as the
 input_thread loop.
[...]

 @@ -3346,7 +3371,9 @@ static int check_keyboard_interaction(int64_t cur_time)
  C  Send/Que command to all matching filters\n
  D  cycle through available debug modes\n
  h  dump packets/hex press to cycle
 through the 3 states\n
 +p  pause transcoding\n

this looks like the diff has been corrupted with line breaks

also this is missing documentation in doc/*

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-13 Thread Michael Niedermayer
On Fri, Mar 13, 2015 at 01:48:48PM -0500, Jeremy Luce wrote:
 I'll fix the breaks and resubmit.
 
 I don't see the keyboard interaction documented anywhere but in the
 source code. Where would be the desired location for this info?

somewhere hmm, in the ffmpeg docs, doc/ffmpeg.texi seems the obvious
option

Thanks

[]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-13 Thread Jeremy Luce
I'll fix the breaks and resubmit.

I don't see the keyboard interaction documented anywhere but in the
source code. Where would be the desired location for this info?
Jeremy


On Fri, Mar 13, 2015 at 1:02 PM, Michael Niedermayer michae...@gmx.at wrote:
 On Wed, Mar 11, 2015 at 08:34:39AM -0500, Jeremy Luce wrote:
 Resubmitting with [PATCH] tag and unified diff.

 Adds functionality to pause transcoding with 'p' key and upause with 'u'
 key over stdin. Pauses in the main transcode loop as well as the
 input_thread loop.
 [...]

 @@ -3346,7 +3371,9 @@ static int check_keyboard_interaction(int64_t cur_time)
  C  Send/Que command to all matching filters\n
  D  cycle through available debug modes\n
  h  dump packets/hex press to cycle
 through the 3 states\n
 +p  pause transcoding\n

 this looks like the diff has been corrupted with line breaks

 also this is missing documentation in doc/*

 [...]
 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 I am the wisest man alive, for I know one thing, and that is that I know
 nothing. -- Socrates

 ___
 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] Add ability to pause transcoding via keyboard interaction

2015-03-13 Thread Jeremy Luce
It's been a couple days, so I wanted to follow up. Would someone mind
providing some feedback on this? Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-13 Thread Michael Niedermayer
On Fri, Mar 13, 2015 at 08:34:48AM -0500, Jeremy Luce wrote:
 It's been a couple days, so I wanted to follow up. Would someone mind
 providing some feedback on this? Thanks!

what is the advantage of this compared to simply stoping the process?
like by hiting ctrl-z ?

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add ability to pause transcoding via keyboard interaction

2015-03-13 Thread Jeremy Luce
In my case it would be used by a multi-platform application that does
on-the-fly transcoding. It would be nice if this behavior was platform
agnostic (there's no ctrl-z equivalent in Windows that I know of).
Doing this with OS-specific keys or at the thread level in the
application code is less than ideal.
Jeremy


On Fri, Mar 13, 2015 at 11:12 AM, Michael Niedermayer michae...@gmx.at wrote:
 On Fri, Mar 13, 2015 at 08:34:48AM -0500, Jeremy Luce wrote:
 It's been a couple days, so I wanted to follow up. Would someone mind
 providing some feedback on this? Thanks!

 what is the advantage of this compared to simply stoping the process?
 like by hiting ctrl-z ?

 [...]

 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 The bravest are surely those who have the clearest vision
 of what is before them, glory and danger alike, and yet
 notwithstanding go out to meet it. -- Thucydides

 ___
 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