From 869eddfc1ac1e6c5bf9f475588bb6f8ef4b8e145 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 6 Oct 2011 23:43:48 +0200 Subject: [PATCH] Custom FFmpeg recording sizes. --- general.h | 2 ++ record/ffemu.c | 2 +- ssnes.c | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/general.h b/general.h index 18242433ee..bd04f9fd33 100644 --- a/general.h +++ b/general.h @@ -278,6 +278,8 @@ struct global ffemu_t *rec; char record_path[MAXPATHLEN]; bool recording; + unsigned record_width; + unsigned record_height; #endif char title_buf[64]; diff --git a/record/ffemu.c b/record/ffemu.c index d8f3aee9e9..27aec22e8f 100644 --- a/record/ffemu.c +++ b/record/ffemu.c @@ -163,7 +163,7 @@ static bool init_video(struct video_info *video, struct ffemu_params *param) video->outbuf_size = 1 << 23; video->outbuf = av_malloc(video->outbuf_size); - // Just to make sure we can handle the biggest frames. Seemed to crash with just 256 * 224. + // Just to make sure we can handle the biggest frames. int size = avpicture_get_size(PIX_FMT_RGB32, param->fb_width, param->fb_height); video->conv_frame_buf = av_malloc(size); video->conv_frame = avcodec_alloc_frame(); diff --git a/ssnes.c b/ssnes.c index 7f40e661d6..653f767342 100644 --- a/ssnes.c +++ b/ssnes.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "driver.h" #include "file.h" #include "general.h" @@ -403,6 +404,7 @@ static void print_help(void) #ifdef HAVE_FFMPEG puts("\t-r/--record: Path to record video file.\n\t\tUsing .mkv extension is recommended, and codecs used are FFV1/FLAC."); + puts("\t--size: Overrides output video size when recording with FFmpeg (format: width:height)."); #endif puts("\t-v/--verbose: Verbose logging."); puts("\t-U/--ups: Specifies path for UPS patch that will be applied to ROM."); @@ -511,6 +513,7 @@ static void parse_input(int argc, char *argv[]) { "fullscreen", 0, NULL, 'f' }, #ifdef HAVE_FFMPEG { "record", 1, NULL, 'r' }, + { "size", 1, &val, 's' }, #endif { "verbose", 0, NULL, 'v' }, { "gameboy", 1, NULL, 'g' }, @@ -705,10 +708,37 @@ static void parse_input(int argc, char *argv[]) case 'p': g_extern.netplay_port = strtoul(optarg, NULL, 0); break; + case 'B': strlcpy(g_extern.bps_name, optarg, sizeof(g_extern.bps_name)); g_extern.bps_pref = true; break; + +#ifdef HAVE_FFMPEG + case 's': + { + errno = 0; + char *ptr; + g_extern.record_width = strtoul(optarg, &ptr, 0); + if ((*ptr != ':') || errno) + { + SSNES_ERR("Wrong format for --size.\n"); + print_help(); + exit(1); + } + + ptr++; + g_extern.record_height = strtoul(ptr, &ptr, 0); + if ((*ptr != '\0') || errno) + { + SSNES_ERR("Wrong format for --size.\n"); + print_help(); + exit(1); + } + break; + } +#endif + default: break; } @@ -859,7 +889,12 @@ static void init_recording(void) .rgb32 = false, }; - if (g_settings.video.hires_record) + if (g_extern.record_width || g_extern.record_height) + { + params.out_width = g_extern.record_width; + params.out_height = g_extern.record_height; + } + else if (g_settings.video.hires_record) { params.out_width = 512; params.out_height = 448;