Extending our WebRTC streaming POC with MPEG-TS support

MPEG-TS to WHIP

To address this my colleague Marcus Spangenberg developed a small application that can consume an MPEG-TS stream and ingest over WebRTC using the WHIP protocol. A tool that we now also have made available as open source.

./mpeg-ts-client -a 127.0.0.1 -p 9998 -u https://whip.dev.eyevinn.technology/api/v1/whip/broadcaster
docker run --rm -v $PWD:/mnt eyevinntechnology/toolbox-loopts \
--withtc \
--withaudio \
VINN.mp4 \
udp://host.docker.internal:9998?pkt_size=1316
[2022-04-27 21:06:06.335] Creating pipeline mpegTsAddress 127.0.0.1, mpegTsPort 9998, mpegTsBufferSize 1000000000 ns
[2022-04-27 21:06:06.612] New pipeline clock
[2022-04-27 21:06:07.613] Dynamic pad created, type video/x-h264
[2022-04-27 21:06:07.616] Dynamic pad created, type audio/mpeg
[2022-04-27 21:06:07.722] onNegotiationNeeded
[2022-04-27 21:06:08.020] onOfferCreated
[2022-04-27 21:06:10.448] Server responded with resource https://whip.dev.eyevinn.technology:443/api/v1/whip/broadcaster/9368aeb1-1ba8-42b2-b322-f5dcf02b6e5e
[2022-04-27 21:06:10.448] Setting local SDP
[2022-04-27 21:06:10.448] Setting remote SDP

RTSP to WHIP

If you would want to take the feed from an RTSP camera instead we could use ffmpeg to consume the RTSP feed and remux to an MPEG-TS stream first.

ffmpeg -i rtsp://<username>:<password>@<ip>/stream1 \
-vcodec copy \
-acodec aac \
-f mpegts \
udp://127.0.0.1:9998?pkt_size=1316

SRT to WHIP

And in a similar way we could take an MPEG-TS that is transmitted using SRT (Secure Reliable Transport).

ffmpeg -i srt://127.0.0.1:1234?mode=listener \
-vcodec copy \
-acodec copy \
-f mpegts \
udp://127.0.0.1:9998?pkt_size=1316

Open Source

As mentioned before, all the source code for this is open source so we welcome you to contribute and give feedback. This WHIP-client has mainly been developed by Marcus Spangenberg from Eyevinn Technology.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eyevinn Technology

Eyevinn Technology

We are consultants sharing the passion for the technology for a media consumer of the future.