h264_streamer.cpp
Go to the documentation of this file.
2 
3 namespace web_video_server
4 {
5 
8  LibavStreamer(request, connection, nh, "mp4", "libx264", "video/mp4")
9 {
10  /* possible quality presets:
11  * ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
12  * no latency improvements observed with ultrafast instead of medium
13  */
14  preset_ = request.get_query_param_value_or_default("preset", "ultrafast");
15 }
16 
18 {
19 }
20 
22 {
23  av_opt_set(codec_context_->priv_data, "preset", preset_.c_str(), 0);
24  av_opt_set(codec_context_->priv_data, "tune", "zerolatency", 0);
25  av_opt_set_int(codec_context_->priv_data, "crf", 20, 0);
26  av_opt_set_int(codec_context_->priv_data, "bufsize", 100, 0);
27  av_opt_set_int(codec_context_->priv_data, "keyint", 30, 0);
28  av_opt_set_int(codec_context_->priv_data, "g", 1, 0);
29 
30  // container format options
31  if (!strcmp(format_context_->oformat->name, "mp4")) {
32  // set up mp4 for streaming (instead of seekable file output)
33  av_dict_set(&opt_, "movflags", "+frag_keyframe+empty_moov+faststart", 0);
34  }
35 }
36 
38  LibavStreamerType("mp4", "libx264", "video/mp4")
39 {
40 }
41 
44  ros::NodeHandle& nh)
45 {
46  return boost::shared_ptr<ImageStreamer>(new H264Streamer(request, connection, nh));
47 }
48 
49 }
AVFormatContext * format_context_
H264Streamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, ros::NodeHandle &nh)
std::string get_query_param_value_or_default(const std::string &name, const std::string &default_value) const
virtual boost::shared_ptr< ImageStreamer > create_streamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, ros::NodeHandle &nh)


web_video_server
Author(s): Mitchell Wills
autogenerated on Tue Mar 1 2022 00:04:38