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
<< "--timebase " << rd
<< "/" << rn
<< " ";
16 ret
<< expand_arguments_common(opts
, "--", "=");
20 class output_driver_ivfenc
: public output_driver
23 output_driver_ivfenc(const std::string
& _filename
, const std::string
& _options
)
27 set_video_callback
<output_driver_ivfenc
>(*this, &output_driver_ivfenc::video_callback
);
30 ~output_driver_ivfenc()
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
<< "ivfenc --width=" << v
.get_width() << " --height=" << v
.get_height() << " ";
44 commandline
<< expand_options(options
, v
.get_rate_num(), v
.get_rate_denum());
45 commandline
<< " - " << filename
;
46 std::string s
= commandline
.str();
47 out
= popen(s
.c_str(), "w");
49 std::stringstream str
;
50 str
<< "Can't run ivfenc (" << 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_ivfenc_factory
: output_driver_factory
71 output_driver_ivfenc_factory()
72 : output_driver_factory("ivfenc")
76 output_driver
& make(const std::string
& type
, const std::string
& name
, const std::string
& parameters
)
78 return *new output_driver_ivfenc(name
, parameters
);