rtpdump files can be converted to mp4 using rtpplay
and FFmpeg
.
For example, let's consider these files:
Analyze them:
$ rtpdump -Fascii -f narwhals-audio.rtpdump | head -n 1
0.000000 RTP len=15 from=0.0.0.0:0 v=2 p=0 x=0 cc=0 m=1 pt=97 (????,0,0) seq=1679 ts=249986024 ssrc=0xf944ac63
$ rtpdump -Fascii -f narwhals-audio.rtpdump | tail -n 1
65.570000 RTP len=15 from=0.0.0.0:0 v=2 p=0 x=0 cc=0 m=1 pt=97 (????,0,0) seq=4959 ts=253134824 ssrc=0xf944ac63
Analyis results:
Audio sample rate = (253134824 - 249986024) / (65.57 - 0) ~= 48000
Audio codec: probably opus
Audio payload type: 97
Video sample rate: 90000
Video codec : probably VP8
Video payload type: 96
Codec names may require some guesswork/investination/just trying all of them.
Let's assign port 4646 for video and 4848 for audio and create some SDP file:
v=0
c=IN IP4 127.0.0.1
m=video 4646 RTP/AVP 96
a=rtpmap:96 VP8/90000
m=audio 4848 RTP/AVP 97
a=rtpmap:97 opus/48000
Let's then prepare a command line to start FFmpeg that will listen those ports according to SDP save to MP4 file:
ffmpeg -v warning -protocol_whitelist file,udp,rtp -f sdp -i narwhals.sdp -copyts -c copy -y narwhals.mkv
FFmpeg exits after 10 seconds of failing to receive any packet, so don't start that command line just yet.
Then, in another console tab, prepare rtpplay command lines:
rtpplay -T -f narwhals-video.rtpdump 127.0.0.1/4646 & rtpplay -T -f narwhals-audio.rtpdump 127.0.0.1/4848
Also don't start it yet. Note that there are two rtpplay
s which should be started simultaneously.
Now, in quick succession, start the prepared FFmpeg command line, then the rtpplay
s. Wait until rtpplays finish (about a minute). FFmpeg should then time out and your file is done.
The mkv file may be converted to MP4, but it requires transcoding because of VP8 is not supported in MP4. The transcoding may also be done with FFmpeg.
Unfortunately, audio/video synchronisation may be an issue, which may also be addressed using FFmpeg trickery; or by adjusting the sample rate in SDP like VP8/95000
.