[FFmpeg-cvslog] ffmpeg: fix reading commands from stdin

Michael Niedermayer git at videolan.org
Tue Aug 30 20:35:51 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Aug 30 20:17:07 2011 +0200| [e312543c82b493422911213ab792cb94f3a9e5b4] | committer: Michael Niedermayer

ffmpeg: fix reading commands from stdin

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e312543c82b493422911213ab792cb94f3a9e5b4
---

 ffmpeg.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 6453e05..739b866 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2325,8 +2325,13 @@ static int transcode(OutputFile *output_files,
             if (key == 'c' || key == 'C'){
                 char ret[4096], target[64], cmd[256], arg[256]={0};
                 double ts;
+                int k;
                 fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
-                if(scanf("%4095[^\n\r]%*c", ret) == 1 && sscanf(ret, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &ts, cmd, arg) >= 3){
+                i=0;
+                while((k=read_key()) > 0 && k!='\n' && k!='\r' && i<sizeof(ret)-1)
+                    ret[i++]= k;
+                ret[i]= 0;
+                if(k>0 && sscanf(ret, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &ts, cmd, arg) >= 3){
                     for(i=0;i<nb_output_streams;i++) {
                         int r;
                         ost = &output_streams[i];



More information about the ffmpeg-cvslog mailing list