Skip to content

Commit

Permalink
Merge pull request #54 from soreau/opencl-fixup
Browse files Browse the repository at this point in the history
Opencl fixup
  • Loading branch information
ammen99 authored Dec 1, 2019
2 parents 0a9b090 + c44d9aa commit 2317ee8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/frame-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/frame-writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct FrameWriterParams
bool opencl;
bool force_yuv;
int opencl_device;
int bframes;
};

class FrameWriter
Expand Down
27 changes: 22 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <option_name>=<option_value>
-p <option_name>=<option_value>)");
#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:
Expand All @@ -561,7 +572,7 @@ With no FILE, start recording the current screen.
The video file will be stored as <outputname>.ext in the
current working directory.
)");
)" "\n");
exit(EXIT_SUCCESS);
}

Expand All @@ -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;

Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2317ee8

Please sign in to comment.