ethand91 / mediasoup3-record-demo

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

Bash script with ffmpeg ? #57

Closed yarekc closed 3 years ago

yarekc commented 3 years ago

Do you think it is possible to record a mediasoup stream with some bash script and ffmpeg ? (without having to write some node server side script)

(similar solution to broadcast script provided here: mediasoup-demo/ffmpeg.sh at v3 · versatica/mediasoup-demo · GitHub)

Regards

ethand91 commented 3 years ago

Create an sdp.txt file with the following contents.

v=0
o=- 0 0 IN IP4 [mediasoup server ip]
s=FFmpeg
c=IN IP4 [mediasoup server ip]
t=0 0
m=video [mediasoup consumer rtp port] RTP/AVP [video codec payloadType]
a=rtpmap :[video codec payloadType] VP8/90000
a=sendonly
m=audio [mediasoup consumer rtp port] RTP/AVP [audio codec payloadType]
a=rtpmnap:[audio codec payloadType] opus/48000/2
a=sendonly 

then create the script

#!/bin/bash

ffmpeg -protocol_whitelist file,udp,rtp -fflags +genpts -f sdp -i sdp.txt -map 0:v:0 -c:v copy -map 0:a:0 -strict 2 -c:a copy -flags +global_header file.webm
yarekc commented 3 years ago

Thanks you !

1) I have 2 question: can you a real sample of the sdp.txt (because you never know if you have to use double quote, simple quote, escape strings on parameters such as: [video codec payloadType]

2) How to get the [mediasoup consumer rtp port] from JS ? - since the goal is to control the recording with JS with buttons like "startRecord" and "stopRecord"

Regards