summaryrefslogblamecommitdiffstats
path: root/roles/stream/tasks/main.yml
blob: 7cabb6bf2304331ecf4546a3373592ea36ac3c3b (plain) (tree)








































                                                            



                                                                                                                                                                                                                                                                                                                                                                                         


                                            

                                                                                                                        
                                        
                           
                                                                                                                                                                                                                                                    
                                             





                                     
- name: Install Icecast
  become: true
  package:
    name: icecast2
    state: present
- name: Set up config
  become: true
  template:
    src: icecast.xml
    dest: /etc/icecast2/icecast-emacsconf.xml
- name: Set up init file
  become: true
  template:
    src: icecast-emacsconf.init.d
    dest: /etc/init.d/emacsconf
    mode: 0755
- name: Set up nginx config
  become: true
  template:
    src: emacsconf.nginx.conf
    dest: /etc/nginx/emacsconf.nginx.conf
    mode: 0644
- name: Enable icecast
  become: true
  sysvinit:
    name: emacsconf
    enabled: yes
    state: started
- name: Check if icecast is listening
  wait_for:
    port: "{{ icecast_port }}"
    delay: 5
    timeout: 10
    msg: "Timeout waiting for {{ icecast_port }} to respond"
  register: port_check
  ignore_errors: yes
- name: Try to restart icecast if not started
  service: name=emacsconf state=started enabled=yes
  when: port_check.failed == true
- name: Test by streaming from a file
  tags: test-stream-file, never
  block:
  - debug:
      msg: ffmpeg -loglevel 32 -re -i {{ icecast_test }} -loop 1 -f webm -r 30 -ac 2 -cluster_size_limit 2M -cluster_time_limit 5100 -content_type video/webm -c:v libvpx -b:v 1M -crf 30 -g 125 -threads 4 -deadline realtime  icecast://emacsconf:{{ icecast_emacsconf_password }}@live0.emacsconf.org:{{ icecast_port }}/emacsconf/{{ icecast_test_track|d("gen") }}.webm
  - local_action: shell ffmpeg -re -loglevel 32 -i {{ icecast_test }} -loop 1 -f webm -r 30 -ac 2 -cluster_size_limit 2M -cluster_time_limit 5100 -content_type video/webm -c:v libvpx -b:v 1M -crf 30 -g 125 -threads 4 -deadline realtime  icecast://emacsconf:{{ icecast_emacsconf_password }}@live0.emacsconf.org:{{ icecast_port }}/emacsconf/{{ icecast_test_track|d("gen") }}.webm
  when: icecast_test is defined
- name: Test by displaying the stream in mpv
  tags: test-stream-mpv, never
  local_action: shell mpv http://live0.emacsconf.org:{{ icecast_port }}/emacsconf/{{ icecast_test_track|d("gen") }}.webm
  when: test is defined and test == 'mpv'
- name: Test by streaming a test pattern
  tags: test-stream-pattern
  local_action: shell ffmpeg -loglevel 32 -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -f webm icecast://emacsconf:{{ icecast_emacsconf_password }}@live0.emacsconf.org:{{ icecast_port }}/emacsconf/{{ icecast_test_track|d("gen") }}.webm
  when: test is defined and test == 'pattern'
# - name: Set up restream script
#   template:
#     src: restream-yt.sh
#     dest: /home/orga/restream-yt.sh
#     owner: orga
#     mode: 0755