2 #include "output-drv.hpp"
12 std::string
expand_options(const std::string
& opts
, uint32_t rn
, uint32_t rd
)
14 std::ostringstream ret
;
16 ret
<< "--fps " << rn
<< "/" << rd
<< " ";
17 ret
<< expand_arguments_common(opts
, "--", " ");
21 class output_driver_x264
: public output_driver
24 output_driver_x264(const std::string
& _filename
, const std::string
& _options
)
28 set_video_callback
<output_driver_x264
>(*this, &output_driver_x264::video_callback
);
38 const video_settings
& v
= get_video_settings();
39 framesize
= 4 * v
.get_width() * v
.get_height();
40 width
= v
.get_width();
41 height
= v
.get_height();
43 std::stringstream commandline
;
44 commandline
<< "x264 ";
45 commandline
<< expand_options(options
, v
.get_rate_num(), v
.get_rate_denum());
46 commandline
<< " - -o " << filename
<< " " << v
.get_width() << "x" << v
.get_height();
47 std::string s
= commandline
.str();
48 out
= popen(s
.c_str(), "w");
50 std::stringstream str
;
51 str
<< "Can't run x264 (" << s
<< ")";
52 throw std::runtime_error(str
.str());
56 void video_callback(uint64_t timestamp
, const uint8_t* raw_rgbx_data
)
58 I420_convert_common(raw_rgbx_data
, width
, height
, out
, true);
69 class output_driver_x264_factory
: output_driver_factory
72 output_driver_x264_factory()
73 : output_driver_factory("x264")
77 output_driver
& make(const std::string
& type
, const std::string
& name
, const std::string
& parameters
)
79 return *new output_driver_x264(name
, parameters
);