This commit is contained in:
cxh 2025-09-17 09:44:40 +08:00
parent 2a49aef598
commit 345fdc5f46

View File

@ -33,7 +33,6 @@ GstRTSPMediaFactory *RTSPManager::create_media_factory(const Camera &cam)
if (cam.width == 1280 && cam.height == 960) if (cam.width == 1280 && cam.height == 960)
{ {
out_height = 720; out_height = 720;
// 使用 videocrop 元素从顶部裁剪 120 像素,总共裁剪 960->720
int crop_top = (960 - 720) / 2; int crop_top = (960 - 720) / 2;
videocrop_str = " ! videocrop top=" + std::to_string(crop_top) + " bottom=" + std::to_string(crop_top); videocrop_str = " ! videocrop top=" + std::to_string(crop_top) + " bottom=" + std::to_string(crop_top);
} }
@ -43,12 +42,11 @@ GstRTSPMediaFactory *RTSPManager::create_media_factory(const Camera &cam)
" ! video/x-raw,format=NV12,width=" + std::to_string(cam.width) + " ! video/x-raw,format=NV12,width=" + std::to_string(cam.width) +
",height=" + std::to_string(cam.height) + ",height=" + std::to_string(cam.height) +
",framerate=" + std::to_string(cam.fps) + "/1" ",framerate=" + std::to_string(cam.fps) + "/1"
" ! queue max-size-buffers=4 leaky=2" " ! queue max-size-buffers=8 leaky=2" +
" ! videoconvert"
" ! video/x-raw,format=NV12" +
videocrop_str + videocrop_str +
" ! queue max-size-buffers=4 leaky=2" " ! queue max-size-buffers=8 leaky=2"
" ! mpph264enc" " ! mpph264enc"
" ! 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();