11# mpd-visualizer
22
3- This is a program for creating videos from MPD, using Lua. It's suitable for using in
4- a never-ending livestream.
3+ This is a program primarily for creating videos from MPD, using Lua. It's suitable for using in
4+ a never-ending livestream. However, you can use it without MPD and
5+ create videos offline.
56
6- It reads audio data from an MPD FIFO, and runs one or more Lua scripts
7+ It reads audio data from a file, pipe, or FIFO, and runs one or more Lua scripts
78to create a video.
89
9- Video is output to a FIFO as an AVI stream with raw audio and video. This
10- AVI FIFO can be read by ffmpeg and encoded to an appropriate format.
10+ Video is output to a FIFO or pipe as an AVI stream with raw audio and video. This
11+ AVI FIFO can be read by ffmpeg and encoded to an appropriate format. It will refuse
12+ to write the video to a regular file, as its a very, very high bitrate (though
13+ you could always just output to stdout and redirect to a file if you really want
14+ to).
1115
1216# Usage
1317
@@ -22,14 +26,15 @@ mpd-visualizer \
2226 -b (number of visualizer bars to calculate) \
2327 -i /path/to/audio.fifo (or - for stdin) \
2428 -o /path/to/video.fifo (or - for stdout) \
25- -l /path/to/Lua /folder \
29+ -l /path/to/your/lua/scripts /folder \
2630 -m (1| 0) enable/disable mpd polling (default enabled) \
27- Following options only valid when -m=0
28- -t title
29- -a artist
30- -A album
31- -F filename
32- -T totaltime (in seconds)
31+ # Following options only valid when -m=0 \
32+ -t title \
33+ -a artist \
34+ -A album \
35+ -F filename \
36+ -T totaltime (in seconds) \
37+ -- optional process to launch
3338
3439```
3540
@@ -55,6 +60,61 @@ will show up in Lua's `song` object.
5560* ` -F filename `
5661* ` -T totaltime (in seconds) `
5762
63+ Additionally, anything given on the command line after your options
64+ will be launched as a child process, and video data will be input to
65+ its standard input. In this mode, whatever you gave for ` -o ` is ignored.
66+
67+ This allows you do things like:
68+
69+ ``` bash
70+ mpd-visualizer \
71+ -w 1280 \
72+ -h 720 \
73+ -f 30 \
74+ -r 48000 \
75+ -c 2 \
76+ -s 2 \
77+ -b 20 \
78+ -i /some-fifo \
79+ -l some-folder \
80+ -- \
81+ ffmpeg \
82+ -re \
83+ -i pipe:0 \
84+ -c:v libx264 \
85+ -c:a aac \
86+ -strict -2 \
87+ -f flv rtmp://some-host/whatever
88+ ```
89+
90+ This way, you can use MPD's "pipe" output type with mpd-visualizer. So MPD
91+ will launch mpd-visualizer, and mpd-visualizer will launch ffmpeg.
92+
93+ Additional ideas:
94+
95+ ** Turn a single song into a video (without MPD)**
96+
97+ ``` bash
98+ ffmpeg -i some-song.mp3 -f s16le -ac 2 -ar 48000 | \
99+ mpd-visualizer \
100+ -w 1280 \
101+ -h 720 \
102+ -f 30 \
103+ -r 48000 \
104+ -c 2 \
105+ -s 2 \
106+ -b 20 \
107+ -i - \
108+ -o - \
109+ -l some-folder \
110+ -m 0 \
111+ -t " Some Song" \
112+ -a " Some Artist" \
113+ -A " Some Album" \
114+ -- \
115+ ffmpeg -i pipe:0 -c:v libx264 -c:a aac -strict -2 -y some-file.mp4
116+ ```
117+
58118## Requirements
59119
60120* LuaJIT or Lua 5.3.
@@ -77,7 +137,8 @@ soon as it has enough audio to generate frames of video, it will start doing so.
77137video FIFO does not exist, it will create it (and automatically delete it when it exits).
78138If the video FIFO already exists, it uses it, and does NOT delete it when it exits.
79139
80- It also connects to MPD as a client to poll song metadata.
140+ It also connects to MPD as a client to poll song metadata, it only polls when MPD
141+ reports the song has changed in some way. You can also disable MPD polling entirely.
81142
82143At startup, it will iterate through your Lua scripts folder and try loading scripts.
83144Your scripts should return either a Lua function, or a table of functions, like:
@@ -120,7 +181,7 @@ When it receives a `USR1` signal, it will reload all `Lua` scripts.
120181
121182` mpd-visualizer ` will keep running until either:
122183
123- * MPD closes the FIFO because it has quit
184+ * the input audio stream ends
124185* ` mpd-visualizer ` receives a ` INT ` or ` TERM ` signal.
125186
126187# The Lua environment
0 commit comments