我使用node.js 从WebRTC服务器(我使用mediasoup)获得RTP流,并从流中获取解密的RTP数据包原始数据.我想将此RTP数据转发到ffmpeg,然后我可以将其保存到文件,或将其作为RTMP流推送到其他媒体服务器.我想最好的方法是创建描述音频和视频流的SDP文件,并通过新的套接字发送数据包.
ffmpeg命令是:
ffmpeg -loglevel debug -protocol_whitelist file,crypto,udp,rtp -re -vcodec libvpx -acodec opus -i test.sdp -vcodec libx264 -acodec aac -y output.mp4
我试图通过UDP发送数据包:
v=0
o=mediasoup 7199daf55e496b370e36cd1d25b1ef5b9dff6858 0 IN IP4 192.168.193.182
s=7199daf55e496b370e36cd1d25b1ef5b9dff6858
c=IN IP4 192.168.193.182
t=0 0
m=audio 33301 RTP/AVP 111
a=rtpmap:111 /opus/48000
a=fmtp:111 minptime=10;useinbandfec=1
a=rtcp-fb:111 transport-cc
a=sendrecv
m=video 33302 RTP/AVP 100
a=rtpmap:100 /VP8/90000
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=sendrecv
Run Code Online (Sandbox Code Playgroud)
但我总是得到(删除无聊的部分):
Opening an input file: test.sdp.
[sdp @ 0x103dea0]
Format sdp probed with …Run Code Online (Sandbox Code Playgroud) 我想定义我的函数输入的结构.
这个模块定义了我的函数(它的一部分是伪代码):
-module(my_service).
-export([my_function/2]).
-type my_enum() :: 1 | 2 | 5.
-record(my_record, {id = null :: string(), name = null :: string(), myType = null :: my_enum()}).
-spec my_function(MyValue#my_record) -> Result#my_record.
my_function(ClientRequest, MyValue) when is_record(Entry, my_record) ->
Response = client:request(get, "http://www.example.com/api?value=" + MyValue#my_record.name),
case Response of
{ok, Status, Head, Body} ->
Result = parse_response(Body, my_record);
Error ->
Error
end.
Run Code Online (Sandbox Code Playgroud)
这就是我想要的方式:
-module(test1).
-import(io, [format/2]).
main(_) ->
application:start(inets),
MyTestValue = #my_record{name => "test value", myType => 2},
X = my_service:my_function(MyTestValue),
io:format("Response: …Run Code Online (Sandbox Code Playgroud)