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 a20b763..e6492f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -535,10 +535,21 @@ 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 - yuv format, before sending it to the gpu.\n\n + -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. + + -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: @@ -561,7 +572,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); } @@ -575,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; @@ -597,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) { @@ -635,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;