Mercurial > mplayer.hg
changeset 14095:367ba4601d47
Add a file= suboption to set output file.
Patch by Olivier Rolland (( billl |at| users <dot> sf <dot> net )).
author | reimar |
---|---|
date | Fri, 03 Dec 2004 21:02:14 +0000 |
parents | a0197f7b0784 |
children | 47d2175fb4c8 |
files | DOCS/man/en/mplayer.1 help/help_mp-en.h libvo/vo_yuv4mpeg.c |
diffstat | 3 files changed, 44 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Fri Dec 03 20:55:00 2004 +0000 +++ b/DOCS/man/en/mplayer.1 Fri Dec 03 21:02:14 2004 +0000 @@ -2896,6 +2896,8 @@ Write the output as interlaced frames, top field first. .IPs interlaced_bf Write the output as interlaced frames, bottom field first. +.IPs file=<filename> +Write the output to the given file instead of the default stream.yuv. .REss .PD 1 .RS
--- a/help/help_mp-en.h Fri Dec 03 20:55:00 2004 +0000 +++ b/help/help_mp-en.h Fri Dec 03 21:02:14 2004 +0000 @@ -866,7 +866,7 @@ #define MSGTR_VO_YUV4MPEG_InterlacedInputNotRGB "Input not RGB, can't separate chrominance by fields!" #define MSGTR_VO_YUV4MPEG_WidthDivisibleBy2 "Image width must be divisible by 2." #define MSGTR_VO_YUV4MPEG_NoMemRGBFrameBuf "Not enough memory to allocate RGB framebuffer." -#define MSGTR_VO_YUV4MPEG_OutFileOpenError "Can't get memory or file handle to write \"stream.yuv\"!" +#define MSGTR_VO_YUV4MPEG_OutFileOpenError "Can't get memory or file handle to write \"%s\"!" #define MSGTR_VO_YUV4MPEG_OutFileWriteError "Error writing image to output!" #define MSGTR_VO_YUV4MPEG_UnknownSubDev "Unknown subdevice: %s" #define MSGTR_VO_YUV4MPEG_InterlacedTFFMode "Using interlaced output mode, top-field first."
--- a/libvo/vo_yuv4mpeg.c Fri Dec 03 20:55:00 2004 +0000 +++ b/libvo/vo_yuv4mpeg.c Fri Dec 03 21:02:14 2004 +0000 @@ -43,7 +43,7 @@ static vo_info_t info = { - "yuv4mpeg output for mjpegtools (to \"stream.yuv\")", + "yuv4mpeg output for mjpegtools", "yuv4mpeg", "Robert Kesterson <robertk@robertk.com>", "" @@ -62,6 +62,8 @@ static uint8_t *rgb_buffer = NULL; static uint8_t *rgb_line_buffer = NULL; +static char *yuv_filename = NULL; + static int using_format = 0; static FILE *yuv_out; static int write_bytes; @@ -126,11 +128,12 @@ write_bytes = image_width * image_height * 3 / 2; image = malloc(write_bytes); - yuv_out = fopen("stream.yuv", "wb"); + yuv_out = fopen(yuv_filename ? yuv_filename : "stream.yuv", "wb"); if (!yuv_out || image == 0) { mp_msg(MSGT_VO,MSGL_FATAL, - MSGTR_VO_YUV4MPEG_OutFileOpenError); + MSGTR_VO_YUV4MPEG_OutFileOpenError, + yuv_filename ? yuv_filename : "stream.yuv"); return -1; } image_y = image; @@ -462,6 +465,10 @@ if(rgb_line_buffer) free(rgb_line_buffer); rgb_line_buffer = NULL; + + if (yuv_filename) + free(yuv_filename); + yuv_filename = NULL; } @@ -472,28 +479,41 @@ static uint32_t preinit(const char *arg) { - int arg_unrecognized = 0; - if(arg) { - /* configure output mode */ - if (strcmp(arg, "interlaced")) - arg_unrecognized++; - else - config_interlace = Y4M_ILACE_TOP_FIRST; + int parse_err = 0; + unsigned int parse_pos = 0; - if (strcmp(arg, "interlaced_bf")) - arg_unrecognized++; - else - config_interlace = Y4M_ILACE_BOTTOM_FIRST; - - /* If both tests failed the argument is invalid */ - if (arg_unrecognized == 2) - { - mp_msg(MSGT_VO,MSGL_FATAL, - MSGTR_VO_YUV4MPEG_UnknownSubDev,arg); - return -ENOSYS; + while (arg[parse_pos] && !parse_err) { + if (strncmp (&arg[parse_pos], "interlaced", 10) == 0) { + parse_pos += 10; + config_interlace = Y4M_ILACE_TOP_FIRST; + } + else if (strncmp (&arg[parse_pos], "interlaced_bf", 13) == 0) { + parse_pos += 13; + config_interlace = Y4M_ILACE_BOTTOM_FIRST; + } + else if (strncmp (&arg[parse_pos], "file=", 5) == 0) { + int file_len; + parse_pos += 5; + file_len = strcspn (&arg[parse_pos], ":"); + if (file_len < 0) { + parse_err = 1; + break; } + yuv_filename = malloc (file_len + 1); + memcpy (yuv_filename, &arg[parse_pos], file_len); + yuv_filename[file_len] = 0; + parse_pos += file_len; + } + if (arg[parse_pos] == ':') parse_pos++; + else if (arg[parse_pos]) parse_err = 1; + } + if (parse_err) { + mp_msg(MSGT_VO,MSGL_FATAL, + MSGTR_VO_YUV4MPEG_UnknownSubDev,arg); + return -1; + } } /* Inform user which output mode is used */