ethand91 / mediasoup3-record-demo

Simple Record Demo using Mediasoup 3 and GStreamer
198 stars 93 forks source link

How can I record in another computer instead of the computer which the medaisoup server is running? #50

Closed 704760107 closed 3 years ago

704760107 commented 3 years ago

Hello! I changed some codes,and saved sdp as a document named "1.sdp",then I tried to ues FFmpeg command "ffmpeg -protocol_whitelist "file,udp,rtp" -i 1.sdp -acodec copy -vcodec copy out.webm" to record.I got the correct video in the computer which the server was running, but I couldn't get anything in another computer with the same command. I thought maybe ffmpeg command was wrong,so I changed code so that I can run code to record in another computer,but it didn't work.It also worked well in the computer which the server was running. All in all,I just want to record video in another computer. This is my sdp: v=0 o=- 0 0 IN IP4 127.0.0.1 s=FFmpeg c=IN IP4 10.113.121.146 t=0 0 m=video 10002 RTP/AVP 101 a=rtpmap:101 VP8/90000 a=sendonly m=audio 10000 RTP/AVP 100 a=rtpmap:100 opus/48000/2 a=sendonly

After running a while,the ffmpeg process will close,the wrong infomation is as the same as running with sdp whose ip is wrong. This is log: ffmpeg::process::data [data:'ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers\n' + ' built with gcc 10 (Ubuntu 10.2.0-13ubuntu1)\n' + ' configuration: --enable-libvpx --enable-libopus --enable-libvorbis --disable-x86asm\n' + ' libavutil 56. 51.100 / 56. 51.100\n' + ' libavcodec 58. 91.100 / 58. 91.100\n' + ' libavformat 58. 45.100 / 58. 45.100\n' + ' libavdevice 58. 10.100 / 58. 10.100\n' + ' libavfilter 7. 85.100 / 7. 85.100\n' + ' libswscale 5. 7.100 / 5. 7.100\n' + ' libswresample 3. 7.100 / 3. 7.100\n' + 'Splitting the commandline.\n' + "Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.\n" + "Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.\n" + "Reading option '-protocol_whitelist' ... matched as AVOption 'protocol_whitelist' with argument 'pipe,udp,rtp'.\n" + "Reading option '-fflags' ..."] ffmpeg::process::data [data:" matched as AVOption 'fflags' with argument '+genpts'.\n" + "Reading option '-f' ... matched as option 'f' (force format) with argument 'sdp'.\n" + "Reading option '-i' ... matched as input url with argument 'pipe:0'.\n" + "Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:v:0'.\n" + "Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'.\n" + "Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:a:0'.\n" + "Reading option '-strict' ..."] ffmpeg::process::data [data:'Routing option strict to both codec and muxer layer\n' + " matched as AVOption 'strict' with argument '-2'.\n" + "Reading option '-c:a' ..."] ffmpeg::process::data [data:" matched as option 'c' (codec name) with argument 'copy'.\n" + "Reading option '-flags' ..."] ffmpeg::process::data [data:" matched as AVOption 'flags' with argument '+global_header'.\n" + "Reading option '../files/1.webm' ..."] ffmpeg::process::data [data:' matched as output url.\n' + 'Finished splitting the commandline.\n' + 'Parsing a group of options: global .\n' + 'Applying option loglevel (set logging level) with argument debug.\n' + 'Successfully parsed a group of options.\n' + 'Parsing a group of options: input url pipe:0.\n' + 'Applying option re (read input at native frame rate) with argument 1.\n' + 'Applying option f (force format) with argument sdp.\n' + 'Successfully parsed a group of options.\n' + 'Opening an input file: pipe:0.\n'] ffmpeg::process::data [data:"[sdp @ 0x55ed988cfac0] Opening 'pipe:0' for reading\n"] ffmpeg::process::data [data:'[sdp @ 0x55ed988cfac0] video codec set to: vp8\n'] ffmpeg::process::data [data:'[sdp @ 0x55ed988cfac0] audio codec set to: opus\n' + '[sdp @ 0x55ed988cfac0] audio samplerate set to: 48000\n' + '[sdp @ 0x55ed988cfac0] audio channels set to: 2\n'] ffmpeg::process::data [data:'[udp @ 0x55ed988d80c0] end receive buffer size reported is 425984\n'] ffmpeg::process::data [data:'[udp @ 0x55ed988d79c0] end receive buffer size reported is 425984\n'] ffmpeg::process::data [data:'[sdp @ 0x55ed988cfac0] setting jitter buffer size to 500\n'] ffmpeg::process::data [data:'[udp @ 0x55ed988d1100] end receive buffer size reported is 425984\n'] ffmpeg::process::data [data:'[udp @ 0x55ed988d0c40] end receive buffer size reported is 425984\n'] ffmpeg::process::data [data:'[sdp @ 0x55ed988cfac0] setting jitter buffer size to 500\n' + '[sdp @ 0x55ed988cfac0] Before avformat_find_stream_info() pos: 227 bytes read:227 seeks:0 nb_streams:2\n'] ffmpeg::process::data [data:'[sdp @ 0x55ed988cfac0] Could not find codec parameters for stream 0 (Video: vp8, 1 reference frame, yuv420p): unspecified size\n' + "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n" + '[sdp @ 0x55ed988cfac0] After avformat_find_stream_info() pos: 227 bytes read:227 seeks:0 frames:0\n'] ffmpeg::process::data [data:"Input #0, sdp, from 'pipe:0':\n" + ' Metadata:\n' + ' title : FFmpeg\n' + ' Duration: N/A, bitrate: N/A\n' + ' Stream #0:0, 0, 1/90000: Video: vp8, 1 reference frame, yuv420p, 90k tbr, 90k tbn, 90k tbc\n' + ' Stream #0:1, 0, 1/48000: Audio: opus, 48000 Hz, stereo, fltp\n' + 'Successfully opened the file.\n' + 'Parsing a group of options: output url ../files/1.webm.\n' + 'Applying option map (set input stream mapping) with argument 0:v:0.\n' + 'Applying option c:v (codec name) with argument copy.\n' + 'Applying option map (set input stream mapping) with argument 0:a:0.\n' + 'Applying option c:a (codec name) with argument copy.\n' + 'Successfully parsed a group of options.\n' + 'Opening an output file: ../files/1.webm.\n' + "File '../files/1.webm' already exists. Exiting.\n" + '[AVIOContext @ 0x55ed988d8ac0] Statistics: 227 bytes read, 0 seeks\n'] ffmpeg::process::close

ethand91 commented 3 years ago

You are running mediasoup on server A and you want to record it on server B? If so the SDP is wrong.

o=- 0 0 IN IP4 127.0.0.1

127.0.0.1 should be the IP of server A (since you are receiving media from server A i.e mediasoup)