tesy
This commit is contained in:
parent
345fdc5f46
commit
8e99be6c35
@ -25,29 +25,21 @@ void RTSPManager::init()
|
|||||||
// 创建 media factory
|
// 创建 media factory
|
||||||
GstRTSPMediaFactory *RTSPManager::create_media_factory(const Camera &cam)
|
GstRTSPMediaFactory *RTSPManager::create_media_factory(const Camera &cam)
|
||||||
{
|
{
|
||||||
|
// 输出分辨率直接用相机原始分辨率
|
||||||
int out_width = cam.width;
|
int out_width = cam.width;
|
||||||
int out_height = cam.height;
|
int out_height = cam.height;
|
||||||
|
|
||||||
// 如果是 1280x960,则裁剪到 1280x720
|
// 构建 pipeline
|
||||||
std::string videocrop_str;
|
|
||||||
if (cam.width == 1280 && cam.height == 960)
|
|
||||||
{
|
|
||||||
out_height = 720;
|
|
||||||
int crop_top = (960 - 720) / 2;
|
|
||||||
videocrop_str = " ! videocrop top=" + std::to_string(crop_top) + " bottom=" + std::to_string(crop_top);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string launch_str =
|
std::string launch_str =
|
||||||
"( v4l2src device=" + cam.device +
|
"( v4l2src device=" + cam.device +
|
||||||
" ! video/x-raw,format=NV12,width=" + std::to_string(cam.width) +
|
" ! video/x-raw,format=NV12,width=" + std::to_string(out_width) +
|
||||||
",height=" + std::to_string(cam.height) +
|
",height=" + std::to_string(out_height) +
|
||||||
",framerate=" + std::to_string(cam.fps) + "/1"
|
",framerate=" + std::to_string(cam.fps) + "/1"
|
||||||
" ! queue max-size-buffers=8 leaky=2" +
|
" ! queue max-size-buffers=2 leaky=downstream"
|
||||||
videocrop_str +
|
" ! mpph264enc bps=2000000 gop=" +
|
||||||
" ! queue max-size-buffers=8 leaky=2"
|
std::to_string(cam.fps) + " b_frame=0"
|
||||||
" ! mpph264enc"
|
" ! h264parse"
|
||||||
" ! h264parse"
|
" ! rtph264pay name=pay0 pt=96 )";
|
||||||
" ! rtph264pay name=pay0 pt=96 )";
|
|
||||||
|
|
||||||
GstRTSPMediaFactory *factory = gst_rtsp_media_factory_new();
|
GstRTSPMediaFactory *factory = gst_rtsp_media_factory_new();
|
||||||
gst_rtsp_media_factory_set_launch(factory, launch_str.c_str());
|
gst_rtsp_media_factory_set_launch(factory, launch_str.c_str());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user