Skip to content

Instantly share code, notes, and snippets.

@goraj
Created February 24, 2018 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goraj/72f3fd8c0f027d8c5d773cd5bc9f48cc to your computer and use it in GitHub Desktop.
Save goraj/72f3fd8c0f027d8c5d773cd5bc9f48cc to your computer and use it in GitHub Desktop.
video_recorder_setup_videoio.cpp
bool video_recorder::setup_videoio(cv::Mat & mat, double fps) {
std::string cmdline = ffmpeg_path_.string() +
" -framerate " + std::to_string(static_cast<int>(fps)) +
" -f image2pipe -vcodec png -i - -c:v libx264 -pix_fmt yuv444p" +
" -preset faster " +
//" -preset ultrafast " +
" -crf 14" +
//" -qp 0 " +
" -vf drawtext=\"fontcolor = white:fontfile = " +
" calibril.ttf : text = '%{localtime\\:%H %M %S}'\" " +
" -y -report " + filename;
pipe_stdin = std::make_shared<boost::process::opstream>();
c = std::make_shared<boost::process::child>(cmdline,
(boost::process::std_out & boost::process::std_err) > "logerr.txt",
boost::process::std_in < *pipe_stdin
);
if (c->running()) {
cout << "recorder::setup_videoio video_writer created using fps: " << fps << endl;
return true;
}
else {
cout << "recorder::setup_videoio video_writer could not be opened" << endl;
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment