{"id":23952,"date":"2025-04-19T09:01:09","date_gmt":"2025-04-19T01:01:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/23952.html"},"modified":"2025-04-19T09:01:09","modified_gmt":"2025-04-19T01:01:09","slug":"gstreamer-%e9%85%8d%e7%bd%ae%e8%a7%a3%e6%9e%90%e7%bc%96%e8%a7%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/23952.html","title":{"rendered":"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801"},"content":{"rendered":"<h3>\u4e00. \u5b89\u88c5gstreamer<\/h3>\n<h4>1.1 Windows\u4e0b\u5b89\u88c5<\/h4>\n<p>\u5b98\u7f51\u94fe\u63a5&#xff1a;https:\/\/gstreamer.freedesktop.org\/download\/#windows <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419010108-6802f5d4274c1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u4e24\u4e2a\u90fd\u8981\u4e0b\u8f7d\u3002\u5b89\u88c5\u7684\u65f6\u5019&#xff0c;\u5728custom\u9009\u62e9\u5b89\u88c5\u8def\u5f84\u3002\u7136\u540e\u8fd4\u56de\u4e0a\u4e00\u6b65\u9009\u62e9complete\u5b8c\u5168\u5b89\u88c5&#xff0c;\u4e24\u4e2a\u5b89\u88c5\u65b9\u5f0f\u4e00\u6837\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419010108-6802f5d4c3347.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>1.2 \u914d\u7f6e\u73af\u5883<\/h3>\n<p>\u5c06 D:\\\\gstreamer\\\\1.0\\\\msvc_x86_64\\\\bin \u6dfb\u52a0\u81f3\u73af\u5883\u53d8\u91cf<\/p>\n<p>\u5728vs\u5de5\u7a0b\u4e2d\u4f7f\u7528&#xff1a;<\/p>\n<li>\u5728c\/c&#043;&#043; &#8212;&#8212;-\u5e38\u89c4&#8212;&#8212;&#8211;\u9644\u52a0\u5305\u542b\u76ee\u5f55 \u589e\u52a0\u5982\u4e0b\u76ee\u5f55<\/li>\n<p>D:\\\\gstreamer\\\\1.0\\\\msvc_x86_64\\\\include\\\\gstreamer-1.0 D:\\\\gstreamer\\\\1.0\\\\msvc_x86_64\\\\include\\\\glib-2.0 D:\\\\gstreamer\\\\1.0\\\\msvc_x86_64\\\\include\\\\libxml2 D:\\\\gstreamer\\\\1.0\\\\msvc_x86_64\\\\include<\/p>\n<li>\u94fe\u63a5\u5668&#8212;-\u5e38\u89c4&#8212;-\u9644\u52a0\u5e93\u76ee\u5f55&#xff0c;\u589e\u52a0 \u5982\u4e0b\u76ee\u5f55<\/li>\n<p>D:\\\\gstreamer\\\\1.0\\\\msvc_x86_64\\\\lib<\/p>\n<li>\u94fe\u63a5\u5668&#8212;-\u8f93\u5165&#8212;&#8211;\u9644\u52a0\u4f9d\u8d56\u6027 \u589e\u52a0<\/li>\n<p>gobject-2.0.lib;glib-2.0.lib;gstreamer-1.0.lib<\/p>\n<li>\u8c03\u8bd5&#8212;-\u73af\u5883<\/li>\n<p>path&#061;%path%;F:\\\\gstreamer\\\\1.0\\\\x86\\\\bin<\/p>\n<h4>1.3 Ubuntu\u4e0b\u5b89\u88c5<\/h4>\n<p>\u9996\u5148\u66f4\u65b0\u7cfb\u7edf\u7684\u8f6f\u4ef6\u5305<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> update<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> <span class=\"token function\">install<\/span> libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e&#xff0c;\u68c0\u67e5GStreamer\u662f\u5426\u5b89\u88c5\u6b63\u786e\u3002<\/p>\n<p>gst-inspect-1.0 <span class=\"token parameter variable\">&#8211;version<\/span><\/p>\n<p>\u663e\u793a\u7248\u672c\u8bf4\u660e\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<h3>\u4e8c. \u6d4b\u8bd5<\/h3>\n<h4>2.1 \u547d\u4ee4\u884c\u6d4b\u8bd5<\/h4>\n<p>gst-launch-1.0.exe <span class=\"token parameter variable\">-v<\/span> playbin <span class=\"token assign-left variable\">uri<\/span><span class=\"token operator\">&#061;<\/span>file:\/C:<span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span>Users<span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span><span class=\"token number\">26366<\/span><span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span>Desktop<span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span>\u5ba3\u4f20\u7247\u6210\u7247.mp4<\/p>\n<p>\u8f93\u51fa\u89c6\u9891\u5373\u4e3a\u6210\u529f\u3002<\/p>\n<h4>2.2 c&#043;&#043;\u6d4b\u8bd5<\/h4>\n<p><span class=\"token comment\">\/\/ GstreamerHelloWorld.cpp : \u6b64\u6587\u4ef6\u5305\u542b &#034;main&#034; \u51fd\u6570\u3002\u7a0b\u5e8f\u6267\u884c\u5c06\u5728\u6b64\u5904\u5f00\u59cb\u5e76\u7ed3\u675f\u3002<\/span><br \/>\n<span class=\"token comment\">\/\/<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;gst\/gst.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;glib.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span>  argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\nGstElement<span class=\"token operator\">*<\/span> pipeline<span class=\"token punctuation\">;<\/span><br \/>\nGstElement<span class=\"token operator\">*<\/span> source<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">*<\/span> filter<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">*<\/span> sink<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/init<\/span><br \/>\n<span class=\"token function\">gst_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>argc<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>argv<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/creat pipeline<\/span><br \/>\npipeline <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">gst_pipeline_new<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;my-pipline&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>create elements<br \/>\nsource <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">gst_element_factory_make<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;fakesrc&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;source&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nfilter <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">gst_element_factory_make<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;identity&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;filter&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nsink <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">gst_element_factory_make<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;fakesink&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;sink&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/\u5c06\u5143\u7ec4\u6dfb\u52a0\u5230\u7ba1\u9053\u4e2d<\/span><br \/>\n<span class=\"token function\">gst_bin_add_many<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">GST_BIN<\/span><span class=\"token punctuation\">(<\/span>pipeline<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> source<span class=\"token punctuation\">,<\/span> filter<span class=\"token punctuation\">,<\/span> sink<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/\u8fde\u63a5<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span><span class=\"token function\">gst_element_link_many<\/span><span class=\"token punctuation\">(<\/span>source<span class=\"token punctuation\">,<\/span> filter<span class=\"token punctuation\">,<\/span> sink<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">g_warning<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;failed to link elements\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nstd<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;failed to link elements!\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">else<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\nstd<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;Hello GStreamer!\\\\n&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/*\u5728\u94fe\u63a5\u4e0d\u540c\u7684\u7ec4\u4ef6\u4e4b\u524d&#xff0c;\u4f60\u9700\u8981\u786e\u4fdd\u8fd9\u4e9b\u7ec4\u4ef6\u90fd\u88ab\u52a0\u5728\u540c\u4e00\u4e2a\u7bb1\u67dc\u4e2d&#xff0c;<br \/>\n\u56e0\u4e3a\u5c06\u4e00\u4e2a\u7ec4\u4ef6\u52a0\u8f7d\u5230\u4e00\u4e2a\u7bb1\u67dc\u4e2d\u4f1a\u7834\u574f\u8be5\u7ec4\u4ef6\u5df2\u5b58\u5728\u7684\u4e00\u4e9b\u94fe\u63a5\u5173\u7cfb\u3002<br \/>\n\u540c\u65f6&#xff0c;\u4f60\u4e0d\u80fd\u76f4\u63a5\u94fe\u63a5\u4e0d\u5728\u540c\u4e00\u7bb1\u67dc\u6216\u7ba1\u9053\u4e2d\u7684\u7ec4\u4ef6\u3002*\/<\/span><\/p>\n<p><span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8f93\u51faHello GStreamer!\u5373\u4e3a\u914d\u7f6e\u6210\u529f\u3002<\/p>\n<h3>\u4e09.\u5e94\u7528<\/h3>\n<h4>3.1 \u4f8b\u4e00&#xff1a;udp\u88f8\u6d41&#xff0c;\u672a\u4f7f\u7528RTP\u5c01\u88c5<\/h4>\n<p>\u7f16\u7801&#xff1a;<\/p>\n<p>gst-launch-1.0 filesrc <span class=\"token assign-left variable\">location<\/span><span class=\"token operator\">&#061;<\/span>C:<span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span>Users<span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span><span class=\"token number\">26366<\/span><span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span>Desktop<span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">\\\\<\/span>\u5ba3\u4f20\u7247\u6210\u7247.mp4 <span class=\"token operator\">!<\/span> qtdemux <span class=\"token operator\">!<\/span> avdec_h264 <span class=\"token operator\">!<\/span> x264enc <span class=\"token operator\">!<\/span> udpsink <span class=\"token assign-left variable\">host<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">192.168<\/span>.0.105 <span class=\"token assign-left variable\">port<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">5600<\/span><\/p>\n<p>\u5bf9\u5e94\u89e3\u7801&#xff1a;<\/p>\n<p>gst-launch-1.0 udpsrc <span class=\"token assign-left variable\">port<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">5600<\/span> <span class=\"token operator\">!<\/span> h264parse <span class=\"token operator\">!<\/span> avdec_h264 <span class=\"token operator\">!<\/span> videoconvert <span class=\"token operator\">!<\/span> autovideosink<\/p>\n<p>c&#043;&#043;\u89e3\u7801&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ GstreamerHelloWorld.cpp : \u6b64\u6587\u4ef6\u5305\u542b &#034;main&#034; \u51fd\u6570\u3002\u7a0b\u5e8f\u6267\u884c\u5c06\u5728\u6b64\u5904\u5f00\u59cb\u5e76\u7ed3\u675f\u3002<\/span><br \/>\n<span class=\"token comment\">\/\/<\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;gst\/gst.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;glib.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">static<\/span> GstElement<span class=\"token operator\">*<\/span> pipeline <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">static<\/span> GstBus<span class=\"token operator\">*<\/span> bus <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">static<\/span> GstMessage<span class=\"token operator\">*<\/span> msg <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u56de\u8c03\u51fd\u6570&#xff0c;\u7528\u4e8e\u5904\u7406 GStreamer \u6d88\u606f<\/span><br \/>\n<span class=\"token keyword\">static<\/span> gboolean  <span class=\"token function\">on_message<\/span><span class=\"token punctuation\">(<\/span>GstBus<span class=\"token operator\">*<\/span> bus<span class=\"token punctuation\">,<\/span> GstMessage<span class=\"token operator\">*<\/span> msg<span class=\"token punctuation\">,<\/span> gpointer data<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\nGError<span class=\"token operator\">*<\/span> err<span class=\"token punctuation\">;<\/span><br \/>\ngchar<span class=\"token operator\">*<\/span> debug_info<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">switch<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">GST_MESSAGE_TYPE<\/span><span class=\"token punctuation\">(<\/span>msg<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">case<\/span> GST_MESSAGE_ERROR<span class=\"token operator\">:<\/span><br \/>\n<span class=\"token function\">gst_message_parse_error<\/span><span class=\"token punctuation\">(<\/span>msg<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>err<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>debug_info<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">g_printerr<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Error received from element %s: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">GST_OBJECT_NAME<\/span><span class=\"token punctuation\">(<\/span>msg<span class=\"token operator\">-&gt;<\/span>src<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> err<span class=\"token operator\">-&gt;<\/span>message<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">g_printerr<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Debugging information: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> debug_info <span class=\"token operator\">?<\/span> debug_info <span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;none&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">g_clear_error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>err<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">g_free<\/span><span class=\"token punctuation\">(<\/span>debug_info<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">g_main_loop_quit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>GMainLoop<span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">default<\/span><span class=\"token operator\">:<\/span><br \/>\n<span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">return<\/span> TRUE<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span>  argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">gst_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>argc<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>argv<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">gst_debug_set_active<\/span><span class=\"token punctuation\">(<\/span>TRUE<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">gst_debug_set_default_threshold<\/span><span class=\"token punctuation\">(<\/span>GST_LEVEL_DEBUG<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>GMainLoop<span class=\"token operator\">*<\/span> loop <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">g_main_loop_new<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> FALSE<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u521b\u5efa GStreamer \u7ba1\u9053<\/span><br \/>\npipeline <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">gst_parse_launch<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;udpsrc port&#061;5600 ! h264parse ! avdec_h264 ! videoconvert ! autovideosink&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nbus <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">gst_element_get_bus<\/span><span class=\"token punctuation\">(<\/span>pipeline<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">gst_bus_add_watch<\/span><span class=\"token punctuation\">(<\/span>bus<span class=\"token punctuation\">,<\/span> on_message<span class=\"token punctuation\">,<\/span> loop<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">gst_object_unref<\/span><span class=\"token punctuation\">(<\/span>bus<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5f00\u59cb\u64ad\u653e<\/span><br \/>\n<span class=\"token function\">gst_element_set_state<\/span><span class=\"token punctuation\">(<\/span>pipeline<span class=\"token punctuation\">,<\/span> GST_STATE_PLAYING<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u8fd0\u884c\u4e3b\u5faa\u73af<\/span><br \/>\n<span class=\"token function\">g_print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Playing stream&#8230;\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">g_main_loop_run<\/span><span class=\"token punctuation\">(<\/span>loop<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6e05\u7406<\/span><br \/>\n<span class=\"token function\">gst_element_set_state<\/span><span class=\"token punctuation\">(<\/span>pipeline<span class=\"token punctuation\">,<\/span> GST_STATE_NULL<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">gst_object_unref<\/span><span class=\"token punctuation\">(<\/span>pipeline<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">g_main_loop_unref<\/span><span class=\"token punctuation\">(<\/span>loop<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>3.2 \u4f8b\u4e8c&#xff0c;\u4f7f\u7528RTP\u5c01\u88c5<\/h4>\n<p>\u7f16\u7801<\/p>\n<p>gst-launch-1.0 v4l2src <span class=\"token assign-left variable\">device<\/span><span class=\"token operator\">&#061;<\/span>\/dev\/video0 <span class=\"token operator\">!<\/span> videoconvert <span class=\"token operator\">!<\/span> <span class=\"token string\">&#039;video\/x-raw,format&#061;(string)NV12,width&#061;640,height&#061;480,framerate&#061;(fraction)30\/1&#039;<\/span> <span class=\"token operator\">!<\/span> queue <span class=\"token operator\">!<\/span> x264enc  <span class=\"token operator\">!<\/span> udpsink <span class=\"token assign-left variable\">host<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">127.0<\/span>.0.1 <span class=\"token assign-left variable\">port<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">5000<\/span> <span class=\"token assign-left variable\">sync<\/span><span class=\"token operator\">&#061;<\/span>false<\/p>\n<p>\u89e3\u7801&#xff1a;<\/p>\n<p>gst-launch-1.0 udpsrc <span class=\"token assign-left variable\">port<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">5000<\/span> <span class=\"token assign-left variable\">caps<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;application\/x-rtp, media&#061;(string)video, clock-rate&#061;(int)90000, encoding-name&#061;(string)H264&#039;<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n    <span class=\"token operator\">!<\/span> rtpjitterbuffer <span class=\"token assign-left variable\">latency<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">200<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n    <span class=\"token operator\">!<\/span> rtspsrc <span class=\"token operator\">!<\/span> avdec_h264 <span class=\"token operator\">!<\/span> videoconvert <span class=\"token operator\">!<\/span> autovideosink<\/p>\n<p>\u53c2\u6570\u89e3\u91ca&#xff1a;<\/p>\n<ul>\n<li>udpsrc port&#061;5000&#xff1a;\u8bbe\u7f6e GStreamer \u4ece UDP \u7aef\u53e3 5000 \u63a5\u6536\u6570\u636e\u3002&#xff08;\u53ef\u66ff\u6362&#xff1a;rtspsrc &#xff0c;filesrc &#xff0c;v4l2src&#xff09;<\/li>\n<li>caps&#xff1a;\u8bbe\u7f6e\u63a5\u6536\u6570\u636e\u7684\u5c5e\u6027&#xff0c;\u5305\u62ec\u5a92\u4f53\u7c7b\u578b&#xff08;video&#xff09;\u3001\u65f6\u949f\u9891\u7387&#xff08;90000&#xff0c;\u5bf9\u5e94\u4e8e 90 kHz\u7684\u65f6\u949f&#xff0c;\u5e38\u7528\u4e8e\u89c6\u9891&#xff09;\u3001\u7f16\u7801\u540d\u79f0&#xff08;H264&#xff09;\u3002<\/li>\n<li>rtpjitterbuffer&#xff1a;\u7528\u4e8e\u5904\u7406\u7f51\u7edc\u6296\u52a8&#xff0c;latency\u53c2\u6570\u8bbe\u7f6e\u4e3a\u7f13\u51b2\u533a\u7684\u5ef6\u8fdf\u65f6\u95f4&#xff08;\u5355\u4f4d\u4e3a\u7eb3\u79d2&#xff09;\u3002<\/li>\n<li>rtspsrc&#xff1a;\u4f7f\u7528 RTP \u6d41&#xff0c;\u9700\u8981\u4f7f\u7528 rtspsrc \u800c\u4e0d\u662f udpsrc<\/li>\n<li>avdec_h264&#xff1a;H.264 \u89c6\u9891\u89e3\u7801\u5668\u3002<\/li>\n<li>videoconvert&#xff1a;\u7528\u4e8e\u8f6c\u6362\u89c6\u9891\u5230\u663e\u793a\u8bbe\u5907\u652f\u6301\u7684\u683c\u5f0f\u3002<\/li>\n<li>autovideosink&#xff1a;\u81ea\u52a8\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u89c6\u9891\u6e32\u67d3\u5668&#xff08;\u4f8b\u5982&#xff0c;X \u670d\u52a1\u5668\u6216 GL \u6e32\u67d3\u5668&#xff09;\u7528\u6765\u5c55\u793a\u89c6\u9891\u3002<\/li>\n<\/ul>\n<p>gst-launch-1.0 udpsrc port&#061;14556 caps&#061;\u201capplication\/x-rtp, media&#061;(string)video, clock-rate&#061;(int)90000, enc oding-name&#061;(string)H264\u201d ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! autovideosink<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.6k\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u3010\u4ee3\u7801\u3011gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801\u3002_gstreamer\u5b89\u88c5<\/p>\n","protected":false},"author":2,"featured_media":23950,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,87,43,427],"topic":[],"class_list":["post-23952","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-87","tag-43","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/23952.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.6k\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u3010\u4ee3\u7801\u3011gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801\u3002_gstreamer\u5b89\u88c5\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/23952.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T01:01:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419010108-6802f5d4274c1.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/23952.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/23952.html\",\"name\":\"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T01:01:09+00:00\",\"dateModified\":\"2025-04-19T01:01:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/23952.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/23952.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/23952.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/23952.html","og_locale":"zh_CN","og_type":"article","og_title":"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.6k\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u3010\u4ee3\u7801\u3011gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801\u3002_gstreamer\u5b89\u88c5","og_url":"https:\/\/www.wsisp.com\/helps\/23952.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T01:01:09+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419010108-6802f5d4274c1.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/23952.html","url":"https:\/\/www.wsisp.com\/helps\/23952.html","name":"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T01:01:09+00:00","dateModified":"2025-04-19T01:01:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/23952.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/23952.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/23952.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"gstreamer \u914d\u7f6e+\u89e3\u6790\u7f16\u89e3\u7801"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/23952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=23952"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/23952\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/23950"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=23952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=23952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=23952"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=23952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}