Replies: 1 comment 2 replies
-
You understanding is correct in the sense that indeed, you can't just dump the packets in a file to generate a valid video file. You can indeed extract raw video/audio data from the packets, however, the packetization payload is codec-dependent and the format way more complex than you guessed for h264. It is defined in RFC 6184. The main reason is that NAL units sizes can be wildly different from the MTU, therefore they may be grouped on a single packets, but also fragmented over multiple packets. For OPUS it is simpler, as defined in RFC 7587. To properly generate proper audio/video files you would need to write the data in a container with timing information. The simplest way to record such a file is actually to input the RTP stream in ffmpeg or gstreamer and convert it. I think there might be a larger issue though: if you only need to record video from a web client, you should not use RTP because you don't need the real-time aspect and you probably don't want the video to be videoconference-grade quality (RTP is lossy, meaning part of the information might be lost), instead, you should encode the video in the browser and upload video chunks as files. Filtering with |
Beta Was this translation helpful? Give feedback.
-
Hi!
I'm working on a project where I would like being able to record the audio and video streams received from a web client.
Using the media-sfu example with a small modification, I'm able to receive both video and audio from a web client and forward it to multiple web clients.
As far as I know, If I save the messages received at the onMessage callbacks of the audio and video tracks, I should end with two files containing the raw h264 and opus files. However, that is not the case, as the files are not recognized nor playable by ffmpeg.
As the messages received on those callbacks are RTP messages, I have also tried extracting the payload of those messages, therefore getting the raw files, by using the following code:
I have also discovered the function IsRtcp which, from my understanding, should be used to discard the Rtcp messaged from being saved to file too.
By checking the received and stored messages I have checked that the RTP headers are correctly removed, however, it seems strange to me that the received h264 file does not contains any NAL Unit separators, for example. I supose this is due to RTP being used to distinguish between the NALUs, so I tried ading the 0x000001 separator before each RTP payload, but it made no difference.
Anyway, neither of this approximations work, and I don't know why.
Does somebody have any cues? Is it possible that the received samples are encrypted or something similar?
Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions