gpt4 book ai didi

ffmpeg - 检测为 UDP 的 RTP 数据包

转载 作者:行者123 更新时间:2023-12-04 23:26:55 25 4
gpt4 key购买 nike

这是我正在尝试做的事情:

WebRTC endpoint > RTP Endpoint > ffmpeg > RTMP server.

这就是我的 SDP 文件的样子。
var cm_offer = "v=0\n" +
"o=- 3641290734 3641290734 IN IP4 127.0.0.1\n" +
"s=nginx\n" +
"c=IN IP4 127.0.0.1\n" +
"t=0 0\n" +
"m=audio 60820 RTP/AVP 0\n" +
"a=rtpmap:0 PCMU/8000\n" +
"a=recvonly\n" +
"m=video 59618 RTP/AVP 101\n" +
"a=rtpmap:101 H264/90000\n" +
"a=recvonly\n";

发生的事情是,wireshark 可以检测到端口 59618 的传入数据包,但不是 RTP 数据包而是 UDP 数据包。我正在尝试使用以下命令使用 ffmpeg 捕获数据包:
ubuntu@ip-132-31-40-100:~$ ffmpeg -i udp://127.0.0.1:59618 -vcodec copy stream.mp4
ffmpeg version git-2017-01-22-f1214ad Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
libavutil 55. 44.100 / 55. 44.100
libavcodec 57. 75.100 / 57. 75.100
libavformat 57. 63.100 / 57. 63.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 69.100 / 6. 69.100
libavresample 3. 2. 0 / 3. 2. 0
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100

我得到的只是一个闪烁的光标,并且退出(ctrl + c)后stream.mp4文件没有写入磁盘。

所以你能帮我弄清楚:
  • 为什么wireshark 不能将数据包检测为RTP(我怀疑它与SDP 有关)
  • 当 RTP 端点推送到不发回答案的 ffmpeg 时如何处理 SDP 答案。

  • 这是整个代码(修改了hello world教程)
    /*
    * (C) Copyright 2014-2015 Kurento (http://kurento.org/)
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */

    function getopts(args, opts)
    {
    var result = opts.default || {};
    args.replace(
    new RegExp("([^?=&]+)(=([^&]*))?", "g"),
    function($0, $1, $2, $3) { result[$1] = decodeURI($3); });

    return result;
    };

    var args = getopts(location.search,
    {
    default:
    {
    ws_uri: 'wss://' + location.hostname + ':8433/kurento',
    ice_servers: undefined
    }
    });

    function setIceCandidateCallbacks(webRtcPeer, webRtcEp, onerror)
    {
    webRtcPeer.on('icecandidate', function(candidate) {
    console.log("Local candidate:",candidate);

    candidate = kurentoClient.getComplexType('IceCandidate')(candidate);

    webRtcEp.addIceCandidate(candidate, onerror)
    });

    webRtcEp.on('OnIceCandidate', function(event) {
    var candidate = event.candidate;

    console.log("Remote candidate:",candidate);

    webRtcPeer.addIceCandidate(candidate, onerror);
    });
    }


    function setIceCandidateCallbacks2(webRtcPeer, rtpEp, onerror)
    {
    webRtcPeer.on('icecandidate', function(candidate) {
    console.log("Localr candidate:",candidate);

    candidate = kurentoClient.getComplexType('IceCandidate')(candidate);

    rtpEp.addIceCandidate(candidate, onerror)
    });
    }


    window.addEventListener('load', function()
    {
    console = new Console();

    var webRtcPeer;
    var pipeline;
    var webRtcEpt;

    var videoInput = document.getElementById('videoInput');
    var videoOutput = document.getElementById('videoOutput');

    var startButton = document.getElementById("start");
    var stopButton = document.getElementById("stop");

    startButton.addEventListener("click", function()
    {
    showSpinner(videoInput, videoOutput);

    var options = {
    localVideo: videoInput,
    remoteVideo: videoOutput
    };


    if (args.ice_servers) {
    console.log("Use ICE servers: " + args.ice_servers);
    options.configuration = {
    iceServers : JSON.parse(args.ice_servers)
    };
    } else {
    console.log("Use freeice")
    }

    webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error)
    {
    if(error) return onError(error)

    this.generateOffer(onOffer)
    });

    function onOffer(error, sdpOffer)
    {
    if(error) return onError(error)

    kurentoClient(args.ws_uri, function(error, client)
    {
    if(error) return onError(error);

    client.create("MediaPipeline", function(error, _pipeline)
    {
    if(error) return onError(error);

    pipeline = _pipeline;

    pipeline.create("WebRtcEndpoint", function(error, webRtc){
    if(error) return onError(error);

    webRtcEpt = webRtc;

    setIceCandidateCallbacks(webRtcPeer, webRtc, onError)

    webRtc.processOffer(sdpOffer, function(error, sdpAnswer){
    if(error) return onError(error);

    webRtcPeer.processAnswer(sdpAnswer, onError);
    });
    webRtc.gatherCandidates(onError);

    webRtc.connect(webRtc, function(error){
    if(error) return onError(error);

    console.log("Loopback established");
    });
    });



    pipeline.create("RtpEndpoint", function(error, rtp){
    if(error) return onError(error);

    //setIceCandidateCallbacks2(webRtcPeer, rtp, onError)


    var cm_offer = "v=0\n" +
    "o=- 3641290734 3641290734 IN IP4 127.0.0.1\n" +
    "s=nginx\n" +
    "c=IN IP4 127.0.0.1\n" +
    "t=0 0\n" +
    "m=audio 60820 RTP/AVP 0\n" +
    "a=rtpmap:0 PCMU/8000\n" +
    "a=recvonly\n" +
    "m=video 59618 RTP/AVP 101\n" +
    "a=rtpmap:101 H264/90000\n" +
    "a=recvonly\n";



    rtp.processOffer(cm_offer, function(error, cm_sdpAnswer){
    if(error) return onError(error);

    //webRtcPeer.processAnswer(cm_sdpAnswer, onError);
    });
    //rtp.gatherCandidates(onError);

    webRtcEpt.connect(rtp, function(error){
    if(error) return onError(error);

    console.log("RTP endpoint connected to webRTC");
    });
    });









    });
    });
    }
    });
    stopButton.addEventListener("click", stop);


    function stop() {
    if (webRtcPeer) {
    webRtcPeer.dispose();
    webRtcPeer = null;
    }

    if(pipeline){
    pipeline.release();
    pipeline = null;
    }

    hideSpinner(videoInput, videoOutput);
    }

    function onError(error) {
    if(error)
    {
    console.error(error);
    stop();
    }
    }
    })


    function showSpinner() {
    for (var i = 0; i < arguments.length; i++) {
    arguments[i].poster = 'img/transparent-1px.png';
    arguments[i].style.background = "center transparent url('img/spinner.gif') no-repeat";
    }
    }

    function hideSpinner() {
    for (var i = 0; i < arguments.length; i++) {
    arguments[i].src = '';
    arguments[i].poster = 'img/webrtc.png';
    arguments[i].style.background = '';
    }
    }

    /**
    * Lightbox utility (to display media pipeline image in a modal dialog)
    */
    $(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
    event.preventDefault();
    $(this).ekkoLightbox();
    });

    最佳答案

    当您使用 WebRTC 时,RTP 流使用 DTLS/SRTP 加密。
    因此,您无法在 Wireshark 等网络跟踪中看到它。

    我不确定 ffmpeg 是否可以正确解码它们。

    您可能会尝试使用 WebRTC 网关来实现您的目标。

    关于ffmpeg - 检测为 UDP 的 RTP 数据包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42516225/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com