From dfb8a1c1009ed107c370cb31cc66c19373004e05 Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Fri, 4 Oct 2019 13:55:43 -0600 Subject: [PATCH 1/3] Add -e/--opencl option to --help output --- src/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a20b763..76ec36e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -535,9 +535,17 @@ With no FILE, start recording the current screen. -o, --output Specify the output where the video is to be recorded. -p, --codec-param Change the codec parameters. - -p = + -p =)"); +#ifdef HAVE_OPENCL + printf(R"( + + -e, --opencl Use the -e[#] or --opencl[=#] in conjunction with -t or --force-yuv option + to use opencl for gpu accelerated conversion of data to yuv. # is one + of the devices listed when running without specifying #.)"); +#endif + printf(R"( - -t, force-yuv Use the -t or --force-yuv option to force conversion of the data to + -t, --force-yuv Use the -t or --force-yuv option to force conversion of the data to yuv format, before sending it to the gpu.\n\n Examples: From b6748c3a30f14992bcfbbab15571179406e0e3dc Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Fri, 4 Oct 2019 13:59:21 -0600 Subject: [PATCH 2/3] Fix newlines in --help output The newline characters within R"()" where printed literally and not used as newlines. Fix this by adding printf specifically for this case. Also add a newline to the end of the --help output so the command returns the prompt after the help text and not at the end of the last line. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 76ec36e..0230f76 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -546,7 +546,7 @@ With no FILE, start recording the current screen. printf(R"( -t, --force-yuv Use the -t or --force-yuv option to force conversion of the data to - yuv format, before sending it to the gpu.\n\n + yuv format, before sending it to the gpu.)" "\n\n" R"( Examples: Video Only: @@ -569,7 +569,7 @@ With no FILE, start recording the current screen. The video file will be stored as .ext in the current working directory. -)"); +)" "\n"); exit(EXIT_SUCCESS); } From c44d9aadf07c6eb49b3845d0ba527c2713ebfa1c Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Sat, 23 Nov 2019 10:48:47 -0700 Subject: [PATCH 3/3] Add --bframes option Some cards do not support B-Frames so add an option to control max_b_frames. In the typical case, this option should be used with 0 as arg (-b 0), which will disable bframes. --- src/frame-writer.cpp | 3 +++ src/frame-writer.hpp | 1 + src/main.cpp | 13 +++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/frame-writer.cpp b/src/frame-writer.cpp index 928e243..26f12cb 100644 --- a/src/frame-writer.cpp +++ b/src/frame-writer.cpp @@ -170,6 +170,9 @@ void FrameWriter::init_video_stream() videoCodecCtx->height = params.height; videoCodecCtx->time_base = (AVRational){ 1, FPS }; + if (params.bframes != -1) + videoCodecCtx->max_b_frames = params.bframes; + if (params.codec.find("vaapi") != std::string::npos) { videoCodecCtx->pix_fmt = AV_PIX_FMT_VAAPI; diff --git a/src/frame-writer.hpp b/src/frame-writer.hpp index a8b0058..4b74594 100644 --- a/src/frame-writer.hpp +++ b/src/frame-writer.hpp @@ -63,6 +63,7 @@ struct FrameWriterParams bool opencl; bool force_yuv; int opencl_device; + int bframes; }; class FrameWriter diff --git a/src/main.cpp b/src/main.cpp index 0230f76..e6492f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -546,7 +546,10 @@ With no FILE, start recording the current screen. printf(R"( -t, --force-yuv Use the -t or --force-yuv option to force conversion of the data to - yuv format, before sending it to the gpu.)" "\n\n" R"( + yuv format, before sending it to the gpu. + + -b, --bframes This option is used to set the maximum number of b-frames to be used. + If b-frames are not supported by your hardware, set this to 0.)" "\n\n" R"( Examples: Video Only: @@ -583,6 +586,7 @@ int main(int argc, char *argv[]) params.force_yuv = false; params.opencl = false; params.opencl_device = -1; + params.bframes = -1; PulseReaderParams pulseParams; @@ -605,13 +609,14 @@ int main(int argc, char *argv[]) { "help", no_argument, NULL, 'h' }, { "force-yuv", no_argument, NULL, 't' }, { "opencl", optional_argument, NULL, 'e' }, + { "bframes", optional_argument, NULL, 'b' }, { 0, 0, NULL, 0 } }; int c, i; std::string param; size_t pos; - while((c = getopt_long(argc, argv, "o:f:m:x:g:c:p:d:la::te::h", opts, &i)) != -1) + while((c = getopt_long(argc, argv, "o:f:m:x:g:c:p:d:b:la::te::h", opts, &i)) != -1) { switch(c) { @@ -643,6 +648,10 @@ int main(int argc, char *argv[]) params.hw_device = optarg; break; + case 'b': + params.bframes = optarg ? atoi(optarg) : -1; + break; + case 'l': params.enable_ffmpeg_debug_output = true; break;