1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
A tiny DLNA sender & receiver.
```
$ cargo install -f tiny-dlna
```
This installs two binaries: `tiny-render` and `tiny-cli`.
Just to support subtitles.
```
$ tiny-render
```
This will activate a DLNA receiver named "Tiny Render", which can stream videos
from apps like 虎牙直播, Bilibili, and other video platforms. Additionally, you
can also use `tiny-cli play` (see below) to play local videos (like in your
RaspberryPi) on it.
Options:
```
--name <NAME> Specify render name
--port <PORT> Server port (default: 59876, or 59877 when recording)
--dump-to <FILE> Save the stream into a file (see below)
--headless Record with ffmpeg, without a window (see below)
--http-logs Enable HTTP and SSDP server logs
-v, --verbose Enable debug logs
```
```
$ tiny-render --dump-to ~/Movie/lol-msi-2024.mp4
```
The recorder shows up as "Tiny Recorder". It records one stream: once the
sender stops (or plays something else), the recorder quits and leaves mpv
running so the recording can finish.
When there is no display (`DISPLAY`/`WAYLAND_DISPLAY` unset), mpv isn't
installed, or `--headless` is given, the recorder uses
[ffmpeg](https://ffmpeg.org/) instead of mpv. ffmpeg copies the stream into
the file without decoding it, so no window is needed and CPU use stays low.
```
$ tiny-render --name TinyRecorder --dump-to foobar.mp4
```
ffmpeg keeps recording after the sender stops, so a video still downloading
gets finished. The recorder exits when ffmpeg does: when the stream ends, or
on `Ctrl-C` (or `SIGTERM`), which tells ffmpeg to finish the file first. For a
live stream, use `Ctrl-C` to end the recording. `.mp4`/`.mov` files are
written in fragments, so they stay playable even if the process gets killed.
List the names of available DLNA devices:
```
$ tiny-cli list
```
List devices with all their attributes (location, control URL, USN, ...) as
JSON:
```
$ tiny-cli list -v
```
Play a local video file on a DLNA device having "TV" in its name:
```
$ tiny-cli play ~/Movies/foo/bar.mp4 -q TV
```
If there is a `bar.srt` in the same directory, it will be served as long as
the DLNA render supports subtitles. Use `--title` to override the title shown
on the device. Press `Ctrl-C` to stop playing.
An `http://` or `https://` URL can be played the same way:
```
$ tiny-cli play 'https://example.com/live.m3u8' -q TV
```
Stop the streaming on a device:
```
$ tiny-cli stop -q TV
```
When a video is playing, you can issue a `seek` command to adjust its position:
```
$ tiny-cli seek '00:17:25' -q TV
```
For running the render, [mpv](https://mpv.io/) needs to be installed
(headless recording needs [ffmpeg](https://ffmpeg.org/) instead). On Mac,
you may do following:
```
$ ln -sf /Applications/mpv.app/Contents/MacOS/mpv /usr/local/bin/
```
For Windows, after installed mpv, add `mpv.exe`'s directory [into
PATH](https://stackoverflow.com/a/2571200/665869).
Devices find each other with SSDP (UDP multicast on port 1900), so the firewall
should allow it. `tiny-cli play` serves the video from a random TCP port in the
50000–58999 range; `tiny-render` listens on 59876 (59877 when recording) unless
`--port` is given.
Both tools keep their state in `~/.config/tiny-dlna/`:
- -
```
$ cargo run --bin tiny-cli -- -h
$ cargo run --bin tiny-render -- -h
$ cargo test
```