anacrolix / dms

A UPnP DLNA Digital Media Server that includes basic video transcoding. Tested on a Panasonic Viera television, several Android UPnP apps, and Chromecast.
BSD 3-Clause "New" or "Revised" License
646 stars 96 forks source link

new feature: serving streams generated on the fly #111

Closed irsl closed 1 year ago

irsl commented 1 year ago

This change allows serving streams generated on the fly, e.g. exporting the live stream of an rtsp camera over DLNA.

Consider the following script (/mkv-hd.mkv) in the DMS path (/dms-data-dir):

#!/bin/sh

exec ffmpeg -i rtsp://10.6.8.161:554/Streaming/Channels/501/ -c:v copy -c:a copy -movflags +faststart+frag_keyframe+empty_moov -f matroska -

Would make the camera stream available over DLNA when dms is started with the -allowDynamicStreams command line option:

./dms -friendlyName live-streams -allowDynamicStreams -path /dms-data-dir/

Tested on an LG WebOS 2021 TV.

anacrolix commented 1 year ago

There's a lot of special casing, what if you instead created a pattern that identified dynamic streams (like a special extension, and a check that they are executable) and then execute them? They could take a parameter to flag what kind of output to produce, such as producing metadata to output in a content listing, or the actual content. Then you might have a directory with regular items and the special items side by side:

somevideo.mkv
livestream.sh.dms-dynamic-stream
irsl commented 1 year ago

Executing them with special flag to produce metadata could be expensive at directory browsing.

Instead, but driven by your idea, what if DMS supported special metadata files with dms.json suffix (e.g. anything.dms.json), and it contained the title, DLNA profile, mimetype and the command to be executed?

anacrolix commented 1 year ago

That seems fair!

irsl commented 1 year ago

Thanks. I'll open a new PR when I'm ready.