Skip to content

Commit 54c481c

Browse files
authored
Docker script (#9)
* Docker script to convert audio to video * Defaults, readme * rm idea * demo video link
1 parent 2e0156a commit 54c481c

File tree

5 files changed

+583
-0
lines changed

5 files changed

+583
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ docs/TODO.md
77
test/output
88
cmake-build-*
99
out/
10+
.cache/

Dockerfile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Start from the official Ubuntu 24.04 image
2+
FROM ubuntu:24.04
3+
4+
# Install required packages
5+
RUN apt-get update && \
6+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
7+
build-essential \
8+
llvm \
9+
git \
10+
cmake \
11+
ca-certificates \
12+
libssl-dev \
13+
curl \
14+
xvfb \
15+
libgstreamer-plugins-base1.0-dev \
16+
libgstreamer-plugins-bad1.0-dev \
17+
gstreamer1.0-plugins-base \
18+
gstreamer1.0-plugins-good \
19+
gstreamer1.0-plugins-bad \
20+
gstreamer1.0-plugins-ugly \
21+
gstreamer1.0-x \
22+
gstreamer1.0-tools \
23+
libgles2-mesa-dev \
24+
mesa-utils \
25+
sudo
26+
27+
# Clone the projectM repository and build it
28+
RUN git clone --depth 1 https://github.com/projectM-visualizer/projectm.git /tmp/projectm
29+
WORKDIR /tmp/projectm
30+
RUN git submodule update --init --depth 1
31+
RUN mkdir build
32+
WORKDIR /tmp/projectm/build
33+
RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
34+
RUN make -j$(nproc)
35+
RUN make install
36+
WORKDIR /tmp
37+
RUN rm -rf /tmp/projectm
38+
39+
# Get the projectM preset pack
40+
RUN git clone --depth 1 https://github.com/projectM-visualizer/presets-cream-of-the-crop.git /usr/local/share/projectM/presets
41+
42+
# Get the projectM texture pack
43+
RUN git clone --depth 1 https://github.com/projectM-visualizer/presets-milkdrop-texture-pack.git /usr/local/share/projectM/textures
44+
45+
# Clone the gst-projectm repository and build the GStreamer plugin
46+
RUN git clone https://github.com/projectM-visualizer/gst-projectm.git /tmp/gst-projectm
47+
WORKDIR /tmp/gst-projectm
48+
RUN ./setup.sh --auto
49+
RUN mkdir build && \
50+
cd build && \
51+
cmake -DCMAKE_BUILD_TYPE=Release .. && \
52+
make
53+
RUN mkdir -p /usr/lib/x86_64-linux-gnu/gstreamer-1.0/ && \
54+
cp build/libgstprojectm.so /usr/lib/x86_64-linux-gnu/gstreamer-1.0/ && \
55+
rm -rf /tmp/gst-projectm
56+
57+
# Clean up unnecessary packages to reduce image size
58+
RUN apt-get remove -y \
59+
build-essential \
60+
git \
61+
cmake && \
62+
apt-get autoremove -y && \
63+
apt-get clean && \
64+
rm -rf /var/lib/apt/lists/*
65+
66+
# Create a working directory for conversion tasks
67+
WORKDIR /app
68+
69+
# Copy the conversion script
70+
COPY convert.sh /app/
71+
RUN chmod +x /app/convert.sh
72+
73+
# Set environment variables
74+
ENV GST_DEBUG=3
75+
ENV PRESETS_DIR=/usr/local/share/projectM/presets
76+
ENV TEXTURES_DIR=/usr/local/share/projectM/textures
77+
ENV XDG_RUNTIME_DIR=/tmp
78+
79+
# Setup for GPU access
80+
ENV LIBGL_ALWAYS_INDIRECT=0
81+
ENV NVIDIA_DRIVER_CAPABILITIES=all
82+
ENV NVIDIA_VISIBLE_DEVICES=all
83+
84+
# Default command
85+
ENTRYPOINT ["/app/convert.sh"]

README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
<summary>Table of Contents</summary>
3030
<ol>
3131
<li><a href="#getting-started">Getting Started</a></li>
32+
<li>
33+
<a href="#easy-audio-to-video-conversion">Easy Audio to Video Conversion</a>
34+
<ul>
35+
<li><a href="#docker-container">Using Docker Container</a></li>
36+
<li><a href="#conversion-examples">Conversion Examples</a></li>
37+
<li><a href="#customizing-visualizations">Customizing Visualizations</a></li>
38+
</ul>
39+
</li>
40+
<li><a href="#manual-usage">Manual Usage</a></li>
3241
<li><a href="#contributing">Contributing</a></li>
3342
<li><a href="#license">License</a></li>
3443
<li><a href="#support">Support</a></li>
@@ -75,6 +84,142 @@ gst-inspect projectm
7584

7685
<p align="right">(<a href="#readme-top">back to top</a>)</p>
7786

87+
## [Demo Videos (4K)](https://www.youtube.com/watch?v=fI3BMiVDQgU&list=PLFLkbObX4o6TK1jGL6pm1wMwvq2FXnpYJ&index=7)
88+
89+
https://www.youtube.com/watch?v=fI3BMiVDQgU&list=PLFLkbObX4o6TK1jGL6pm1wMwvq2FXnpYJ&index=7
90+
91+
<!-- EASY AUDIO TO VIDEO CONVERSION -->
92+
93+
## Easy Audio to Video Conversion
94+
95+
We provide a simple way to convert audio files to video with ProjectM visualizations using Docker. This method requires no manual installation of dependencies, as everything is packaged in a Docker container.
96+
97+
### Docker Container
98+
99+
The included Docker container has:
100+
101+
- ProjectM library and presets
102+
- GStreamer with all necessary plugins
103+
- The gst-projectm plugin compiled and ready to use
104+
- GPU acceleration support (NVIDIA, AMD, or Intel)
105+
106+
#### Prerequisites
107+
108+
- [Docker](https://docs.docker.com/get-docker/) installed on your system
109+
- For GPU acceleration:
110+
- NVIDIA GPUs: [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html)
111+
- AMD/Intel GPUs: No additional installation required
112+
113+
#### Quick Start
114+
115+
1. Clone this repository:
116+
117+
```bash
118+
git clone https://github.com/projectM-visualizer/gst-projectm.git
119+
cd gst-projectm
120+
```
121+
122+
2. Convert an audio file to video:
123+
```bash
124+
./projectm-convert -i your-audio-file.mp3 -o output-video.mp4
125+
```
126+
127+
The first run will build the Docker container automatically. It will take a good while, so be patient. Once built, it will be cached for future runs.
128+
129+
Note that running the conversion can take hours depending on the length of the audio file and the selected settings.
130+
131+
### Conversion Examples
132+
133+
#### Basic Conversion
134+
135+
Convert an MP3 to a 1080p MP4 with default settings:
136+
137+
```bash
138+
./projectm-convert -i my-song.mp3 -o my-visualization.mp4
139+
```
140+
141+
#### 4K Resolution
142+
143+
Create a 4K video with higher bitrate:
144+
145+
```bash
146+
./projectm-convert -i my-song.mp3 -o my-visualization-4k.mp4 --video-size 3840x2160 -b 16000
147+
```
148+
149+
#### High Quality Render
150+
151+
For creating high quality videos (slower encoding):
152+
153+
```bash
154+
./projectm-convert -i my-song.mp3 -o my-visualization-hq.mp4 --speed veryslow --mesh 2048x1152
155+
```
156+
157+
#### Quick Test Run
158+
159+
For quick testing (lower quality but faster encoding):
160+
161+
```bash
162+
./projectm-convert -i my-song.mp3 -o my-visualization-test.mp4 --speed ultrafast --video-size 1280x720
163+
```
164+
165+
### Customizing Visualizations
166+
167+
The conversion script supports customizing various aspects of the visualization:
168+
169+
| Option | Description | Default |
170+
| --------------------- | -------------------------------------------------- | --------------- |
171+
| `-d, --duration SEC` | Time in seconds between preset transitions | 6 |
172+
| `--mesh WxH` | Mesh size for visualization calculations | 1024x576 |
173+
| `--video-size WxH` | Output video resolution | 1920x1080 |
174+
| `-r, --framerate FPS` | Output video frame rate | 60 |
175+
| `-b, --bitrate KBPS` | Output video bitrate in kbps | 8000 |
176+
| `--speed PRESET` | x264 encoding speed preset (ultrafast to veryslow) | medium |
177+
| `-p, --preset DIR` | Path to custom presets directory | Default presets |
178+
179+
#### Using Custom Presets
180+
181+
If you have your own ProjectM preset files:
182+
183+
```bash
184+
./projectm-convert -i my-song.mp3 -o my-visualization.mp4 -p /path/to/your/presets
185+
```
186+
187+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
188+
189+
<!-- MANUAL USAGE -->
190+
191+
## Manual Usage
192+
193+
Once the plugin has been installed, you can use it something like this:
194+
195+
```shell
196+
gst-launch pipewiresrc ! queue ! audioconvert ! projectm preset=/usr/local/share/projectM/presets preset-duration=5 ! video/x-raw,width=2048,height=1440,framerate=60/1 ! videoconvert ! xvimagesink sync=false
197+
```
198+
199+
Or to convert an audio file to video:
200+
201+
```shell
202+
gst-launch-1.0 -e \
203+
filesrc location=input.mp3 ! \
204+
decodebin ! tee name=t \
205+
t. ! queue ! audioconvert ! audioresample ! \
206+
capsfilter caps="audio/x-raw, format=F32LE, channels=2, rate=44100" ! avenc_aac bitrate=320000 ! queue ! mux. \
207+
t. ! queue ! audioconvert ! projectm preset=/usr/local/share/projectM/presets texture-dir=/usr/local/share/projectM/textures preset-duration=6 mesh-size=1024,576 ! \
208+
identity sync=false ! videoconvert ! videorate ! video/x-raw,framerate=60/1,width=3840,height=2160 ! \
209+
x264enc bitrate=50000 key-int-max=200 speed-preset=veryslow ! video/x-h264,stream-format=avc,alignment=au ! queue ! mux. \
210+
mp4mux name=mux ! filesink location=output.mp4
211+
```
212+
213+
You may need to adjust some elements which may or may not be present in your GStreamer installation, such as x264enc, avenc_aac, etc.
214+
215+
Available options:
216+
217+
```shell
218+
gst-inspect projectm
219+
```
220+
221+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
222+
78223
<!-- CONTRIBUTING -->
79224

80225
## Contributing
@@ -114,6 +259,8 @@ Distributed under the LGPL-2.1 license. See `LICENSE` for more information.
114259

115260
Blaquewithaq (Discord: SoFloppy#1289) - [@anomievision](https://twitter.com/anomievision) - [email protected]
116261

262+
Mischa (Discord: mish) - [@revmischa](https://github.com/revmischa)
263+
117264
<p align="right">(<a href="#readme-top">back to top</a>)</p>
118265

119266
<!----------------------------------------------------------------------->

0 commit comments

Comments
 (0)