Recording

Rheomesh can export raw RTP packets to record audio and video using GStreamer or ffmpeg. Rheomesh provides two useful methods for recording.

  • generate_sdp can generate a simple SDP to receive RTP packets.
  • start_recording starts transporting RTP packets to an endpoint.

Prepare Transport

At first, please prepare RecordingTransport.

let recording_transport = router
  .create_recording_transport(recording_ip, recording_port)
  .await
  .expect("Failed to create recording_transport");

Generate SDP

let sdp = recording_transport
  .generate_sdp(publisher_id)
  .await
  .expect("Failed to generate SDP");

The publisher_id can be obtained from the Publisher object. See Getting Started for details.

You can use this SDP with both ffmpeg and GStreamer. For example, write SDP to stream.sdp file.

Using ffmpeg

For playback:

# -protocol_whitelist: Allow file, rtp, udp protocols
# -analyzeduration: Time to analyze input stream (10 seconds)
# -probesize: Input probing size (50MB)
$ ffplay -protocol_whitelist file,rtp,udp -analyzeduration 10000000 -probesize 50000000 -f sdp -i stream.sdp

For recording to file:

$ ffmpeg -protocol_whitelist file,rtp,udp -i stream.sdp -c copy output.mkv

Using GStreamer

For playback:

$ gst-launch-1.0 udpsrc port=30001 ! \
  application/x-rtp,payload=103,encoding-name=H264 ! \
  rtph264depay ! \
  h264parse ! \
  avdec_h264 ! \
  videoconvert ! \
  autovideosink

For recording to file:

$ gst-launch-1.0 udpsrc port=30001 ! \
  application/x-rtp,payload=103,encoding-name=H264 ! \
  rtph264depay ! \
  h264parse ! \
  avdec_h264 ! \
  matroskamux ! \
  filesink location=output.mkv

Start transporting packets

let track = recording_transport.start_recording(publisher_id).await.expect("Failed to start recording");

results matching ""

    No results matching ""