2017-03-20 58 views
0

node.jsを使用してWebRTCサーバー(私はmediasoupを使用)からRTPストリームを取得し、ストリームから復号化されたRTPパケットの生データを取得します。私はこのRTPデータをffmpegに転送したいと思います。私は、オーディオとビデオの両方のストリームを記述し、UDPを介してパケットを送信するSDPファイルを作成します。 SDP:FFMPEGへのストリームRTPパケット

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 33400 RTP/AVP 111 
a=rtpmap:111 /opus/48000 
a=fmtp:111 minptime=10;useinbandfec=1 
a=rtcp-fb:111 transport-cc 
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 
a=mid:audio 
a=recvonly 
m=video 33402 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=extmap:2 urn:ietf:params:rtp-hdrext:toffset 
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time 
a=extmap:4 urn:3gpp:video-orientation 
a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay 
a=mid:video 
a=recvonly 
a=rtcp-mux 

コマンド: ffmpegの-loglevelデバッグ-analyzeduration 2147483647 -probesize 2147483647 -protocol_whitelistファイル、暗号化、UDP、RTP -re -vcodec VP8 -acodec作品-i test.sdp -vcodec H264 -acodec AAC -y output.mp4

ログ:

ffmpeg version 3.2 
Copyright (c) 2000-2016 the FFmpeg developers 


    built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11) 

    configuration: --prefix=/opt/kaltura/ffmpeg-3.2 --libdir=/opt/kaltura/ffmpeg-3.2/lib --shlibdir=/opt/kaltura/ffmpeg-3.2/lib --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC -I/opt/kaltura/include' --extra-ldflags=-L/opt/kaltura/lib --disable-devices --enable-bzlib --enable-libgsm --enable-libmp3lame --enable-libschroedinger --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-avisynth --enable-libxvid --enable-filter=movie --enable-avfilter --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libvpx --enable-libspeex --enable-libass --enable-postproc --enable-pthreads --enable-static --enable-shared --enable-gpl --disable-debug --disable-optimizations --enable-gpl --enable-pthreads --enable-swscale --enable-vdpau --enable-bzlib --disable-devices --enable-filter=movie --enable-version3 --enable-indev=lavfi --enable-x11grab 

    libavutil  55. 34.100/55. 34.100 

    libavcodec  57. 64.100/57. 64.100 

    libavformat 57. 56.100/57. 56.100 

    libavdevice 57. 1.100/57. 1.100 

    libavfilter  6. 65.100/6. 65.100 

    libswscale  4. 2.100/4. 2.100 

    libswresample 2. 3.100/2. 3.100 

    libpostproc 54. 1.100/54. 1.100 

Splitting the commandline. 

Reading option '-loglevel' ... 
matched as option 'loglevel' (set logging level) with argument 'debug'. 

Reading option '-analyzeduration' ... 
matched as AVOption 'analyzeduration' with argument '2147483647'. 

Reading option '-probesize' ... 
matched as AVOption 'probesize' with argument '2147483647'. 

Reading option '-protocol_whitelist' ... 
matched as AVOption 'protocol_whitelist' with argument 'file,crypto,udp,rtp'. 

Reading option '-re' ... 
matched as option 're' (read input at native frame rate) with argument '1'. 

Reading option '-vcodec' ... 
matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'vp8'. 

Reading option '-acodec' ... 
matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'opus'. 
Reading option '-i' ... matched as input file with argument 'test.sdp'. 
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'h264'. 
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'aac'. 
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. 
Reading option 'output.mp4' ... matched as output file. 
Finished splitting the commandline. 
Parsing a group of options: global . 
Applying option loglevel (set logging level) with argument debug. 
Applying option y (overwrite output files) with argument 1. 
Successfully parsed a group of options. 
Parsing a group of options: input file test.sdp. 
Applying option re (read input at native frame rate) with argument 1. 
Applying option vcodec (force video codec ('copy' to copy stream)) with argument vp8. 
Applying option acodec (force audio codec ('copy' to copy stream)) with argument opus. 
Successfully parsed a group of options. 
Opening an input file: test.sdp. 
[sdp @ 0xb1ef00] Format sdp probed with size=2048 and score=50 
[sdp @ 0xb1ef00] audio codec set to: (null) 
[sdp @ 0xb1ef00] audio samplerate set to: 44100 
[sdp @ 0xb1ef00] audio channels set to: 1 
[sdp @ 0xb1ef00] video codec set to: (null) 
[udp @ 0xb21940] end receive buffer size reported is 131072 
[udp @ 0xb21660] end receive buffer size reported is 131072 
[sdp @ 0xb1ef00] setting jitter buffer size to 500 
[udp @ 0xb21da0] end receive buffer size reported is 131072 
[udp @ 0xb22060] end receive buffer size reported is 131072 
[sdp @ 0xb1ef00] setting jitter buffer size to 500 

[sdp @ 0xb1ef00] Before avformat_find_stream_info() pos: 889 bytes read:889 seeks:0 nb_streams:2 

[vp8 @ 0xb27600] Header size larger than data provided 

    Last message repeated 2 times 
[sdp @ 0xb1ef00] Non-increasing DTS in stream 1: packet 2 with DTS 0, packet 3 with DTS 0 
[vp8 @ 0xb27600] Header size larger than data provided 

... repeats many times until I kill the socket ... 

    Last message repeated 1 times 
[sdp @ 0xb1ef00] Non-increasing DTS in stream 1: packet 273 with DTS 553050, packet 274 with DTS 553050 
[vp8 @ 0xb27600] Header size larger than data provided 

received id=7199daf55e496b370e36cd1d25b1ef5b9dff6858 type=bye 
PeerConnection close. id=7199daf55e496b370e36cd1d25b1ef5b9dff6858 
-- PeerConnection.closed, err: undefined 
-- peers in the room = 0 
[sdp @ 0xb1ef00] decoding for stream 1 failed 
[sdp @ 0xb1ef00] Could not find codec parameters for stream 1 (Video: vp8, 1 reference frame, yuv420p): unspecified size 
Consider increasing the value for the 'analyzeduration' and 'probesize' options 
[sdp @ 0xb1ef00] After avformat_find_stream_info() pos: 889 bytes read:889 seeks:0 frames:584 
Input #0, sdp, from 'test.sdp': 
    Metadata: 
    title   : 7199daf55e496b370e36cd1d25b1ef5b9dff6858 
    Duration: N/A, start: 0.000000, bitrate: N/A 
    Stream #0:0, 309, 1/90000: Audio: opus, 48000 Hz, mono, fltp 
    Stream #0:1, 275, 1/90000: Video: vp8, 1 reference frame, yuv420p, 90k tbr, 90k tbn, 90k tbc 
Successfully opened the file. 
Parsing a group of options: output file output.mp4. 
Applying option vcodec (force video codec ('copy' to copy stream)) with argument h264. 
Applying option acodec (force audio codec ('copy' to copy stream)) with argument aac. 
Successfully parsed a group of options. 
Opening an output file: output.mp4. 
Matched encoder 'libx264' for codec 'h264'. 

[file @ 0xbc56e0] 
Setting default whitelist 'file,crypto' 

Successfully opened the file. 

detected 1 logical cores 

[graph 0 input from stream 0:1 @ 0xb1eca0] 
Setting 'video_size' to value '0x0' 

[buffer @ 0xbc54e0] 
Unable to parse option value "0x0" as image size 

[graph 0 input from stream 0:1 @ 0xb1eca0] 
Setting 'pix_fmt' to value '0' 

[graph 0 input from stream 0:1 @ 0xb1eca0] 
Setting 'time_base' to value '1/90000' 

[graph 0 input from stream 0:1 @ 0xb1eca0] Setting 'pixel_aspect' to value '0/1' 
[graph 0 input from stream 0:1 @ 0xb1eca0] Setting 'sws_param' to value 'flags=2' 
[graph 0 input from stream 0:1 @ 0xb1eca0] Setting 'frame_rate' to value '90000/1' 
[buffer @ 0xbc54e0] Unable to parse option value "0x0" as image size 
[buffer @ 0xbc54e0] Error setting option video_size to value 0x0. 
[graph 0 input from stream 0:1 @ 0xb1eca0] Error applying options to the filter. 
Error opening filters! 
[AVIOContext @ 0xbc57c0] Statistics: 0 seeks, 0 writeouts 

[AVIOContext @ 0xb1f8c0] 
Statistics: 889 bytes read, 0 seeks 

あなたはコーデックを認識せずに解析されたログSDPの冒頭で、見ることができるように

Opening an input file: test.sdp. 
[sdp @ 0xb1ef00] Format sdp probed with size=2048 and score=50 
[sdp @ 0xb1ef00] audio codec set to: (null) 
[sdp @ 0xb1ef00] audio samplerate set to: 44100 
[sdp @ 0xb1ef00] audio channels set to: 1 
[sdp @ 0xb1ef00] video codec set to: (null) 

次に、ソケットからパケットを読み取ろうとしています。

Opening an input file: test.sdp. 
[sdp @ 0xb1ef00] Format sdp probed with size=2048 and score=50 
[sdp @ 0xb1ef00] audio codec set to: (null) 
[sdp @ 0xb1ef00] audio samplerate set to: 44100 
[sdp @ 0xb1ef00] audio channels set to: 1 
[sdp @ 0xb1ef00] video codec set to: (null) 

私は「DTSを非増加」と「提供されたデータよりもヘッダサイズより大きい」のエラーがあると思われる:私はソケットを閉じるとき のみ、ffmpegのは、正しいコーデックを見つける、この時間をSDPを解析し続け間違ったコーデックでの使用のためにパケットの誤った解析が原因で発生します。

SDPの順番を確認したところ、他の例と同じように見えました。

誰かが説明を提案できますか?

ところで、オーディオはうまく動作しますが、OPUSのシンプルさのためだと思います。

ありがとうございました。

答えて

1

答えはここにある:Stream RTP to FFMPEG using SDP

コーデック名が間違っている、私はコード化された名前の前に余分なスラッシュを削除し、それが問題を解決しました。

関連する問題