2 #include "output-drv.hpp"
11 std::string
expand_options(const std::string
& opts
, uint32_t rn
, uint32_t rd
)
13 std::ostringstream ret
;
15 ret
<< "--fps " << rn
<< "/" << rd
<< " ";
16 ret
<< expand_arguments_common(opts
, "--", " ");
20 class output_driver_x264
: public output_driver
23 output_driver_x264(const std::string
& _filename
, const std::string
& _options
)
27 set_video_callback
<output_driver_x264
>(*this, &output_driver_x264::video_callback
);
37 const video_settings
& v
= get_video_settings();
38 framesize
= 4 * v
.get_width() * v
.get_height();
39 width
= v
.get_width();
40 height
= v
.get_height();
42 std::stringstream commandline
;
43 commandline
<< "x264 ";
44 commandline
<< expand_options(options
, v
.get_rate_num(), v
.get_rate_denum());
45 commandline
<< " - -o " << filename
<< " " << v
.get_width() << "x" << v
.get_height();
46 std::string s
= commandline
.str();
47 out
= popen(s
.c_str(), "w");
49 std::stringstream str
;
50 str
<< "Can't run x264 (" << s
<< ")";
51 throw std::runtime_error(str
.str());
55 void video_callback(uint64_t timestamp
, const uint8_t* raw_rgbx_data
)
57 I420_convert_common(raw_rgbx_data
, width
, height
, out
, true);
68 class output_driver_x264_factory
: output_driver_factory
71 output_driver_x264_factory()
72 : output_driver_factory("x264")
76 output_driver
& make(const std::string
& type
, const std::string
& name
, const std::string
& parameters
)
78 return *new output_driver_x264(name
, parameters
);