some random ffmpeg commands

This commit is contained in:
L3D 2023-02-21 00:49:58 +01:00
parent 0084d3abb0
commit 7453054803
Signed by: l3d
GPG key ID: CD08445BFF4313D1
7 changed files with 84 additions and 0 deletions

View file

@ -5,6 +5,13 @@ Ansible Playbook to Install Audio Meter
## Some useful links:
+ [FFMPEG HLS](https://www.martin-riedl.de/2018/08/24/using-ffmpeg-as-a-hls-streaming-server-part-1/)
```
ACHTUNG
Shitty ansible, sollte man in schön machen.
Soll jetzt aber laufen und ist dringend/keine Zeit und so... ;P
```
## FFMPEG COMMAND
Generate Audiometer for video
```bash

View file

@ -0,0 +1,3 @@
---
stream_input_url: false
stream_name: false

View file

@ -0,0 +1,9 @@
---
- name: Systemctl restart audiometer.service
become: true
ansible.builtin.systemd:
state: restarted
name: audiometer.service
enabled: true
masked: false
daemon_reload: true

View file

@ -0,0 +1,31 @@
---
- name: Make sure stream_input_url is set
ansible.builtin.fail:
msg: "Please define stream_input_url"
when: not stream_input_url | bool
- name: Make sure stream_name is set
ansible.builtin.fail:
msg: "Please define stream_name"
when: not stream_name | bool
- name: Create systemd service
become: true
ansible.builtin.template:
src: 'templates/audiometer.service.j2'
dest: '/lib/systemd/system/audiometer.service.j2'
mode: 0640
owner: root
group: root
notify: Systemctl restart audiometer.service
# todo: make sure user exist
- name: Create ffmpeg command
become: true
ansible.builtin.template:
src: templates/audiometer.sh.j2
dest: /opt/audiometer.sh
mode: 0655
owner: video
group: video

View file

@ -32,4 +32,6 @@
- {role: do1jlr.webhost, tags: [web, webhost], become: true}
- {role: do1jlr.acmetool, tags: [web, acmetool], become: true}
- {role: do1jlr.nginx, tags: [web, nginx]}
- {role: streaming_website, tags: web}
- {role: ffmpeg_command, tags: ffmpeg}

View file

@ -0,0 +1,15 @@
{{ ansible_managed | comment }}
[Unit]
Description=create audiometer for {{ inventory_hstname }}
After=network.target
[Service]
Type=simple
Restart=always
User=video
ExecStart=/opt/audiometer.sh
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,17 @@
#!/bin/sh
ffmpeg -listen 1 -i {{ stream_input_url }} \
-nostats \
-loglevel repeat+level+info \
-filter_complex \
"[0:v:0]scale=640x360[orig_scaled];\
[full_mix]framerate=fps=25[out]; \
[orig_scaled]drawtext=fontfile=/srv/www/{{ inventory_hostname }}/opensans.ttf:text={{ stream_name }}:fontcolor=white:fontsize=100:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/1.5[preview_overlay];\
[0:a:0]ebur128=video=1:size=640x480:meter=9:target=-16:gauge=shortterm[native][native_a]; [native_a]anullsink; \
[native]drawtext=fontfile=/srv/www/{{ inventory_hostname }}/opensans.ttf:text=native:fontcolor=white:fontsize=60:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/1.5[native_overlay];\
[0:a:0]showvolume=r=50:w=640:h=60:b=0:ds=log:dm=1.0[native_vu]; \
[preview_overlay][native_vu][native_overlay]vstack=inputs=3[full_mix] " \
-map "[out]" \
-g 30 \
-c:v libx264 -bufsize 16M -maxrate 8M -crf 24 -pix_fmt yuv420p -preset ultrafast \
-f hls -hls_time 4 -hls_playlist_type event /srv/www/{{ inventory_hostname }}/stream.m3u8