修改live流
This commit is contained in:
parent
0c8eac2622
commit
389de678f9
@ -69,59 +69,46 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam)
|
|||||||
const std::string stream = cam.name + "_main";
|
const std::string stream = cam.name + "_main";
|
||||||
const std::string app = "camera";
|
const std::string app = "camera";
|
||||||
|
|
||||||
// live → 外网
|
|
||||||
const std::string live_rtmp = "rtmp://36.153.162.171:19435/" + app + "/" + stream + "?vhost=live";
|
const std::string live_rtmp = "rtmp://36.153.162.171:19435/" + app + "/" + stream + "?vhost=live";
|
||||||
|
|
||||||
// record → 本地 SRS(录像)
|
|
||||||
const std::string record_rtmp = "rtmp://127.0.0.1:2935/" + app + "/" + stream + "?vhost=record";
|
const std::string record_rtmp = "rtmp://127.0.0.1:2935/" + app + "/" + stream + "?vhost=record";
|
||||||
|
|
||||||
std::string pipeline_str = "v4l2src name=src device=" + cam.device +
|
std::string pipeline_str = "v4l2src name=src device=" + cam.device +
|
||||||
" io-mode=dmabuf "
|
" io-mode=dmabuf "
|
||||||
|
"! video/x-raw,format=NV12,width=1920,height=1080,framerate=" +
|
||||||
"! video/x-raw,format=NV12,width=1920,height=1080,"
|
|
||||||
"framerate=" +
|
|
||||||
std::to_string(cam.fps) +
|
std::to_string(cam.fps) +
|
||||||
"/1 "
|
"/1 "
|
||||||
|
|
||||||
"! videoscale "
|
"! videoscale "
|
||||||
"! video/x-raw,width=" +
|
"! video/x-raw,width=" +
|
||||||
std::to_string(cam.width) + ",height=" + std::to_string(cam.height) +
|
std::to_string(cam.width) + ",height=" + std::to_string(cam.height) +
|
||||||
" "
|
" ! queue max-size-buffers=2 leaky=downstream "
|
||||||
|
"! mpph264enc rc-mode=cbr bps=" +
|
||||||
"! queue max-size-buffers=2 max-size-time=0 leaky=downstream "
|
std::to_string(cam.bitrate) + " gop=" + std::to_string(cam.fps) +
|
||||||
|
|
||||||
"! mpph264enc rc-mode=cbr "
|
|
||||||
"bps=" +
|
|
||||||
std::to_string(cam.bitrate) +
|
|
||||||
" "
|
|
||||||
"gop=" +
|
|
||||||
std::to_string(cam.fps) +
|
|
||||||
" "
|
|
||||||
" header-mode=each-idr profile=baseline "
|
" header-mode=each-idr profile=baseline "
|
||||||
|
|
||||||
"! h264parse config-interval=1 "
|
"! h264parse config-interval=1 "
|
||||||
"! tee name=t "
|
"! tee name=t "
|
||||||
|
|
||||||
// ===== record:永远开 =====
|
// ========= 录像(永远启用)============
|
||||||
"t. ! queue max-size-buffers=5 leaky=downstream "
|
"t. ! queue max-size-buffers=8 leaky=downstream "
|
||||||
"! flvmux streamable=true "
|
"! flvmux name=rec_mux streamable=true "
|
||||||
"! rtmpsink location=\"" +
|
"! rtmpsink name=rec_sink location=\"" +
|
||||||
record_rtmp +
|
record_rtmp +
|
||||||
"\" sync=false async=false "
|
"\" sync=false async=false drop-on-latency=true "
|
||||||
|
|
||||||
// ===== live:valve 控制 =====
|
// ========= live(valve 控制)===========
|
||||||
"t. ! queue max-size-buffers=5 leaky=downstream "
|
"t. ! queue max-size-buffers=8 leaky=downstream "
|
||||||
"! valve name=live_valve drop=true "
|
"! valve name=live_valve drop=true "
|
||||||
"! flvmux streamable=true "
|
"! queue max-size-buffers=8 leaky=downstream "
|
||||||
"! rtmpsink location=\"" +
|
"! flvmux name=live_mux streamable=true "
|
||||||
live_rtmp + "\" sync=false async=false";
|
"! rtmpsink name=live_sink location=\"" +
|
||||||
|
live_rtmp + "\" sync=false async=false drop-on-latency=true ";
|
||||||
|
|
||||||
GError* error = nullptr;
|
GError* err = nullptr;
|
||||||
GstElement* pipeline = gst_parse_launch(pipeline_str.c_str(), &error);
|
GstElement* pipeline = gst_parse_launch(pipeline_str.c_str(), &err);
|
||||||
if (error)
|
if (err)
|
||||||
{
|
{
|
||||||
LOG_ERROR("[RTMP] Pipeline creation failed: " + std::string(error->message));
|
LOG_ERROR("[RTMP] Pipeline creation failed: " + std::string(err->message));
|
||||||
g_error_free(error);
|
g_error_free(err);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user