1
This commit is contained in:
parent
a48b2ef917
commit
c592e1b7cb
@ -95,6 +95,7 @@ GstElement *RTMPManager::create_pipeline(const Camera &cam, StreamType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string stream_name = cam.name + stream_type_suffix(type);
|
std::string stream_name = cam.name + stream_type_suffix(type);
|
||||||
|
|
||||||
std::string pipeline_str = "v4l2src device=" + cam.device +
|
std::string pipeline_str = "v4l2src device=" + cam.device +
|
||||||
" ! video/x-raw,format=NV12,width=" + std::to_string(width) +
|
" ! video/x-raw,format=NV12,width=" + std::to_string(width) +
|
||||||
",height=" + std::to_string(height) + ",framerate=" + std::to_string(fps) +
|
",height=" + std::to_string(height) + ",framerate=" + std::to_string(fps) +
|
||||||
@ -103,10 +104,7 @@ GstElement *RTMPManager::create_pipeline(const Camera &cam, StreamType type)
|
|||||||
std::to_string(bitrate) + " gop=" + std::to_string(fps) +
|
std::to_string(bitrate) + " gop=" + std::to_string(fps) +
|
||||||
" ! h264parse ! flvmux streamable=true name=mux "
|
" ! h264parse ! flvmux streamable=true name=mux "
|
||||||
"! rtmpsink location=\"rtmp://127.0.0.1/live/" +
|
"! rtmpsink location=\"rtmp://127.0.0.1/live/" +
|
||||||
stream_name +
|
stream_name + " live=1\" sync=false async-handling=true do-timestamp=true";
|
||||||
" live=1\" sync=false"
|
|
||||||
" timeout=5000000 " // 5秒超时(微秒单位)
|
|
||||||
"async-handling=true"; // 异步错误处理,防止阻塞
|
|
||||||
|
|
||||||
LOG_INFO("[RTMP] Creating pipeline for '" + stream_name + "': " + pipeline_str);
|
LOG_INFO("[RTMP] Creating pipeline for '" + stream_name + "': " + pipeline_str);
|
||||||
|
|
||||||
@ -328,6 +326,8 @@ void RTMPManager::stream_loop(Camera cam, StreamType type, StreamContext *ctx)
|
|||||||
status.running = false;
|
status.running = false;
|
||||||
status.last_result = StreamResult::CONNECTION_FAIL;
|
status.last_result = StreamResult::CONNECTION_FAIL;
|
||||||
status.last_error = err ? err->message : "GStreamer error";
|
status.last_error = err ? err->message : "GStreamer error";
|
||||||
|
LOG_ERROR("[RTMP] Stream error from '" + cam.name + "': " + status.last_error);
|
||||||
|
gst_element_set_state(pipeline, GST_STATE_NULL); // ✅ 防止卡死
|
||||||
if (err) g_error_free(err);
|
if (err) g_error_free(err);
|
||||||
try_set_start(status);
|
try_set_start(status);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user