JThree
JThree

Reputation: 2496

Streaming media files via DLNA/UPnP

I'm currently running Raspbmc on my Raspberry Pi and activated UPnP streaming an rendering.

My goal is to write a simple Python to stream a video or music playlist.

I've tried Coherence, but I it's throwing a bunch exceptions and I don't really get the point as the documentation is pretty chaotic. So I'm looking for an easier way/library.

What's the easiest way to stream media files to my TV using Python?

Upvotes: 18

Views: 12097

Answers (4)

Nickolay
Nickolay

Reputation: 32063

I've had success with nano-dlna, and its source code is rather straightforward too: it serves the file you want to play over HTTP, then issues SetAVTransportURI / Play calls on the specified DMR (DLNA renderer) endpoint.

Upvotes: 0

Pivert
Pivert

Reputation: 785

For audio only, I got good results with rygel. The tricky part is to configure the GstLaunch pulseaudio connector in the .config/rygel.conf. Here is my section, but you can get the right pulseaudio source with the following command:

pactl list | egrep -A2 '^(\*\*\* )?Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1

Here is my GstLaunch Section:

[GstLaunch]
enabled=true
launch-items=myaudiowav;myaudiompeg

myaudiowav-title=WAV audio on @HOSTNAME@
myaudiowav-mime=audio/x-wav
myaudiowav-launch=pulsesrc device=alsa_output.pci-0000_00_14.2.analog-stereo.monitor ! audio/x-raw,channels=2 ! wavpackenc

myaudiompeg-title=MPEG audio on @HOSTNAME@
myaudiompeg-mime=audio/mpeg
myaudiompeg-launch=pulsesrc device=alsa_output.pci-0000_00_14.2.analog-stereo.monitor ! audio/x-raw,channels=2 ! lamemp3enc target=quality q
uality=6

Upvotes: 1

Pavel Cherezov
Pavel Cherezov

Reputation: 51

There is a lightweight pure python library dlnap which allows playing media on DLNA/UPnP devices in the same local network

Upvotes: 5

Narcisse Doudieu Siewe
Narcisse Doudieu Siewe

Reputation: 649

You can use GUPnP binding for python through the gi.repository. Search the documentation for GUPnP and GSSDP, GUPnP AV.

You can couple them with something like a mini webserver running django+SQLite database to define a kind of content directory service (CDS) also you can use Gstreamer (a python binding exist called Gst). With those elements you can build a custom server using SSDP for the discovered stuff; from gstreamer you can get metadata about each media item, and can also use "rtspsrc" of gstreamer for streaming.

Upvotes: 1

Related Questions