[PATCH weston] wcap: Fix up --help.

Kristian Høgsberg hoegsberg at gmail.com
Mon Jul 23 08:09:57 PDT 2012


On Sun, Jul 22, 2012 at 06:51:27PM -0600, Scott Moreau wrote:
> ---
>  wcap/main.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

I don't like the example filenames in the help text, but you have a
point that dumping YUV4MPEG2 to the terminal isn't nice and it's not
clear that that's what --yuv4mpeg2 does.  Instead, I've gone for this
change, which clarifies help message slightly and then catches the
dump-to-terminal case and provides an example of how to encode to webm
in that case.

diff --git a/wcap/main.c b/wcap/main.c
index 466030e..3b671b0 100644
--- a/wcap/main.c
+++ b/wcap/main.c
@@ -150,11 +150,11 @@ output_yuv_frame(struct wcap_decoder *decoder)
 static void
 usage(int exit_code)
 {
-	fprintf(stderr, "usage: wcap-snapshot "
+	fprintf(stderr, "usage: wcap-decode "
 		"[--help] [--yuv4mpeg2] [--frame=<frame>] [--all] \n"
 		"\t[--rate=<num:denom>] <wcap file>\n\n"
 		"\t--help\t\t\tthis help text\n"
-		"\t--yuv2mpeg4\t\tdump wcap file in yuv4mpeg format\n"
+		"\t--yuv2mpeg4\t\tdump wcap file to stdout in yuv4mpeg format\n"
 		"\t--frame=<frame>\t\twrite out the given frame number as png\n"
 		"\t--all\t\t\twrite all frames as pngs\n"
 		"\t--rate=<num:denom>\treplay frame rate for yuv4mpeg2,\n"
@@ -205,6 +205,15 @@ int main(int argc, char *argv[])
 
 	decoder = wcap_decoder_create(argv[1]);
 
+	if (yuv4mpeg2 && isatty(1)) {
+		fprintf(stderr, "Not dumping yuv4mpeg2 data to terminal.  Pipe output to a file or a process.\n");
+		fprintf(stderr, "For example, to encode to webm, use something like\n\n");
+		fprintf(stderr, "\t$ wcap-decode  --yuv4mpeg2 ../capture.wcap |\n"
+			"\t\tvpxenc --target-bitrate=1024 --best -t 4 -o foo.webm -\n\n");
+
+		exit(EXIT_FAILURE);
+	}
+
 	if (yuv4mpeg2) {
 		printf("YUV4MPEG2 C420jpeg W%d H%d F%d:%d Ip A0:0\n",
 		       decoder->width, decoder->height, num, denom);

> diff --git a/wcap/main.c b/wcap/main.c
> index 09e0aa7..757aadb 100644
> --- a/wcap/main.c
> +++ b/wcap/main.c
> @@ -147,15 +147,18 @@ output_yuv_frame(struct wcap_decoder *decoder)
>  static void
>  usage(int exit_code)
>  {
> -	fprintf(stderr, "usage: wcap-snapshot "
> +	fprintf(stderr, "usage: wcap-decode"
>  		"[--help] [--yuv4mpeg2] [--frame=<frame>] [--all] \n"
> -		"\t[--rate=<num:denom>] <wcap file>\n\n"
> +		"\t[--rate=<num:denom>] <wcap file> [ > rawi420.vid ]\n\n"
>  		"\t--help\t\t\tthis help text\n"
>  		"\t--yuv2mpeg4\t\tdump wcap file in yuv4mpeg format\n"
>  		"\t--frame=<frame>\t\twrite out the given frame number as png\n"
>  		"\t--all\t\t\twrite all frames as pngs\n"
>  		"\t--rate=<num:denom>\treplay frame rate for yuv4mpeg2,\n"
> -		"\t\t\t\tspecified as an integer fraction\n\n");
> +		"\t\t\t\tspecified as an integer fraction\n\n"
> +		"\tEXAMPLES:\n\n"
> +		"\twcap-decode --all capture.wcap\n\n"
> +		"\twcap-decode --yuv4mpeg2 capture.wcap > wayland.vid\n\n");
>  
>  	exit(exit_code);
>  }
> -- 
> 1.7.10.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list