[Ffmpeg-devel] [PATCH] let ffplay can play more pixel format

Limin Wang lance.lmwang
Thu Feb 15 03:22:31 CET 2007


Hi,

* Michel Bardiaux <mbardiaux at mediaxim.be> [2007-02-14 12:19:45 +0100]:

> Limin Wang wrote:
> >Hi there,
> >
> >It's very useful to preview the raw video by ffplay I think. The patch
> >will support ffplay to play yuv422p, yuv444p, etc instead of yuv420 only.
> >Please review it.
> >
> >* How to test it:
> >lmwang at laptop:~/yuvad/open/h264/x264$ ./x264 --progress --frames 100 -o
> >/tmp/foremean_cif.h264 /home/lmwang/download/test_sequence/foreman_cif.yuv
> >352x288
> >lmwang at laptop:~/yuvad/open/h264/ffmpeg$ ./ffmpeg -i /tmp/foreman_cif.h264
> >-pix_fmt yuv422p /tmp/2.yuv
> >lmwang at laptop:~/yuvad/open/h264/ffmpeg$ ./ffplay -x 352 -y 288 -pix_fmt
> >yuv422p /tmp/2.yuv
> 
> Now might be a good time to add a -s WxH to ffplay too, and stop abusing 
> -x -y which have not been intended for giving the wxh of rawvideo.

Have add -s WxH option, please review the new patch. training white space has
been deleted also.


> > 
> >In addition, how about to add -pix_fmt help option for ffmpeg and ffplay? 
> >It's
> >very crazy to find out what's the pixel format name from the code.
> >
> 
> 
> 
> -- 
> Michel Bardiaux
> R&D Director
> T +32 [0] 2 790 29 41
> F +32 [0] 2 790 29 02
> E mailto:mbardiaux at mediaxim.be
> 
> Mediaxim NV/SA
> Vorstlaan 191 Boulevard du Souverain
> Brussel 1160 Bruxelles
> http://www.mediaxim.com/
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
-------------- next part --------------
Index: ffplay.c
===================================================================
--- ffplay.c	(revision 7961)
+++ ffplay.c	(working copy)
@@ -186,6 +186,9 @@
 static int fs_screen_height;
 static int screen_width = 0;
 static int screen_height = 0;
+static int frame_width = 0;
+static int frame_height = 0;
+static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
 static int audio_disable;
 static int video_disable;
 static int wanted_audio_stream= 0;
@@ -1866,9 +1869,10 @@
     ap->initial_pause = 1; /* we force a pause when starting an RTSP
                               stream */
 
-    ap->width = screen_width;
-    ap->height= screen_height;
+    ap->width = frame_width;
+    ap->height= frame_height;
     ap->time_base= (AVRational){1, 25};
+    ap->pix_fmt = frame_pix_fmt;
 
     err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
     if (err < 0) {
@@ -2335,8 +2339,20 @@
     }
 }
 
-void opt_width(const char *arg)
+static void opt_frame_size(const char *arg)
 {
+    if (parse_image_size(&screen_width, &screen_height, arg) < 0) {
+        fprintf(stderr, "Incorrect frame size\n");
+        exit(1);
+    }
+    if ((frame_width % 2) != 0 || (frame_height % 2) != 0) {
+        fprintf(stderr, "Frame size must be a multiple of 2\n");
+        exit(1);
+    }
+}
+
+static void opt_width(const char *arg)
+{
     screen_width = atoi(arg);
     if(screen_width<=0){
         fprintf(stderr, "invalid width\n");
@@ -2344,7 +2360,7 @@
     }
 }
 
-void opt_height(const char *arg)
+static void opt_height(const char *arg)
 {
     screen_height = atoi(arg);
     if(screen_height<=0){
@@ -2362,6 +2378,11 @@
     }
 }
 
+static void opt_frame_pix_fmt(const char *arg)
+{
+    frame_pix_fmt = avcodec_get_pix_fmt(arg);
+}
+
 #ifdef CONFIG_NETWORK
 void opt_rtp_tcp(void)
 {
@@ -2382,7 +2403,7 @@
         show_help();
 }
 
-void opt_seek(const char *arg)
+static void opt_seek(const char *arg)
 {
     start_time = parse_date(arg, 1);
 }
@@ -2410,6 +2431,7 @@
     { "h", 0, {(void*)show_help}, "show help" },
     { "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
     { "y", HAS_ARG, {(void*)opt_height}, "force displayed height", "height" },
+    { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
     { "fs", OPT_BOOL, {(void*)&is_full_screen}, "force full screen" },
     { "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
     { "vn", OPT_BOOL, {(void*)&video_disable}, "disable video" },
@@ -2418,6 +2440,7 @@
     { "bytes", OPT_BOOL, {(void*)&seek_by_bytes}, "seek by bytes" },
     { "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
     { "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
+    { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format", "format" },
     { "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
     { "debug", HAS_ARG | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
     { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" },



More information about the ffmpeg-devel mailing list