[FFmpeg-cvslog] seek-test: support printing multiple packets

Michael Niedermayer git at videolan.org
Fri May 4 14:49:43 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri May  4 14:27:44 2012 +0200| [49d935b5d2981e0ca71ba0b62c89335b589a6b4e] | committer: Michael Niedermayer

seek-test: support printing multiple packets

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

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

 libavformat/seek-test.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/libavformat/seek-test.c b/libavformat/seek-test.c
index ccfe90f..49ac3ac 100644
--- a/libavformat/seek-test.c
+++ b/libavformat/seek-test.c
@@ -61,18 +61,25 @@ int main(int argc, char **argv)
     const char *filename;
     AVFormatContext *ic = NULL;
     int i, ret, stream_id;
+    int j;
     int64_t timestamp;
     AVDictionary *format_opts = NULL;
-    int64_t seekfirst;
+    int64_t seekfirst = AV_NOPTS_VALUE;
     int firstback=0;
-
-    if(argc == 4 && !strcmp(argv[2], "-seekforw")){
-        seekfirst = atoi(argv[3]);
-    } else if(argc == 4 && !strcmp(argv[2], "-seekback")){
-        seekfirst = atoi(argv[3]);
-        firstback = 1;
-    } else
-        seekfirst = AV_NOPTS_VALUE;
+    int frame_count = 1;
+
+    for(i=2; i<argc; i+=2){
+        if       (!strcmp(argv[i], "-seekforw")){
+            seekfirst = atoi(argv[i+1]);
+        } else if(!strcmp(argv[i], "-seekback")){
+            seekfirst = atoi(argv[i+1]);
+            firstback = 1;
+        } else if(!strcmp(argv[i], "-frames")){
+            frame_count = atoi(argv[i+1]);
+        } else {
+            argc = 1;
+        }
+    }
 
     av_dict_set(&format_opts, "channels", "1", 0);
     av_dict_set(&format_opts, "sample_rate", "22050", 0);
@@ -111,6 +118,7 @@ int main(int argc, char **argv)
         char ts_buf[60];
 
         if(ret>=0){
+            for(j=0; j<frame_count; j++) {
             ret= av_read_frame(ic, &pkt);
             if(ret>=0){
                 char dts_buf[60];
@@ -122,6 +130,7 @@ int main(int argc, char **argv)
             } else
                 printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
             printf("\n");
+            }
         }
 
         if(i>25) break;



More information about the ffmpeg-cvslog mailing list