Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ ffmpeg_executable_path: "/usr/bin/ffmpeg"

# The final path of ffprobe executable
ffprobe_executable_path: "/usr/bin/ffprobe"

# Whether to uninstall ffmpeg and ffprobe
uninstall_ffmpeg: 'false'

# Whether to reinstall ffmpeg and ffprobe when they exist
reinstall_ffmpeg: 'false'
```

Dependencies
Expand All @@ -47,4 +53,4 @@ MIT
Author Information
------------------

[Hedi Chaibi](https://hedichaibi.com)
[Hedi Chaibi](https://hedichaibi.com)
8 changes: 7 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ ffmpeg_temp_path: /tmp/ffmpeg
ffmpeg_executable_path: /usr/bin/ffmpeg

# The final path of ffprobe executable
ffprobe_executable_path: /usr/bin/ffprobe
ffprobe_executable_path: /usr/bin/ffprobe

# Whether to uninstall ffmpeg and ffprobe
uninstall_ffmpeg: 'false'

# Whether to reinstall ffmpeg and ffprobe when they exist
reinstall_ffmpeg: 'false'
56 changes: 56 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
- name: Check if ffmpeg is already installed
stat:
path: "{{ ffmpeg_executable_path }}"
register: ffmpeg_bin

- name: Check if ffprobe is already installed
stat:
path: "{{ ffprobe_executable_path }}"
register: ffprobe_bin

- name: Create a temp directory
file:
path: "{{ ffmpeg_temp_path }}"
state: directory
when: (not ffmpeg_bin.stat.exists) or
(not ffprobe_bin.stat.exists)

- name: Download from custom source
get_url:
url: https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
dest: "{{ ffmpeg_temp_path }}/ffmpeg-git-amd64-static.tar.xz"
when: (not ffmpeg_bin.stat.exists) or
(not ffprobe_bin.stat.exists)

- name: Unarchive to temp directory
shell: tar xf {{ ffmpeg_temp_path }}/ffmpeg-git-amd64-static.tar.xz --strip-components=1 -C {{ ffmpeg_temp_path }}/
when: (not ffmpeg_bin.stat.exists) or
(not ffprobe_bin.stat.exists)

- name: Move ffmpeg to executables directory
command: mv {{ ffmpeg_temp_path }}/ffmpeg {{ ffmpeg_executable_path }}
args:
creates: "{{ ffmpeg_executable_path }}"

- name: Move ffprobe to executables directory
command: mv {{ ffmpeg_temp_path }}/ffprobe {{ ffprobe_executable_path }}
args:
creates: "{{ ffprobe_executable_path }}"

- name: Make ffmpeg executable by all users
file:
path: "{{ ffmpeg_executable_path }}"
mode: 0755
when: not ffmpeg_bin.stat.exists

- name: Make ffprobe executable by all users
file:
path: "{{ ffprobe_executable_path }}"
mode: 0755
when: not ffprobe_bin.stat.exists

- name: Delete temp directory
file:
path: "{{ ffmpeg_temp_path }}"
state: absent
58 changes: 4 additions & 54 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,6 @@
---
- name: Check if ffmpeg is already installed
stat:
path: "{{ ffmpeg_executable_path }}"
register: ffmpeg_bin
- include: uninstall.yml
when: uninstall_ffmpeg == 'true' or reinstall_ffmpeg == 'true'

- name: Check if ffprobe is already installed
stat:
path: "{{ ffprobe_executable_path }}"
register: ffprobe_bin
- include: install.yml
when: uninstall_ffmpeg != 'true'

- name: Create a temp directory
file:
path: "{{ ffmpeg_temp_path }}"
state: directory
when: (not ffmpeg_bin.stat.exists) or
(not ffprobe_bin.stat.exists)

- name: Download from custom source
get_url:
url: https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
dest: "{{ ffmpeg_temp_path }}/ffmpeg-git-amd64-static.tar.xz"
when: (not ffmpeg_bin.stat.exists) or
(not ffprobe_bin.stat.exists)

- name: Unarchive to temp directory
shell: tar xf {{ ffmpeg_temp_path }}/ffmpeg-git-amd64-static.tar.xz --strip-components=1 -C {{ ffmpeg_temp_path }}/
when: (not ffmpeg_bin.stat.exists) or
(not ffprobe_bin.stat.exists)

- name: Move ffmpeg to executables directory
command: mv {{ ffmpeg_temp_path }}/ffmpeg {{ ffmpeg_executable_path }}
args:
creates: "{{ ffmpeg_executable_path }}"

- name: Move ffprobe to executables directory
command: mv {{ ffmpeg_temp_path }}/ffprobe {{ ffprobe_executable_path }}
args:
creates: "{{ ffprobe_executable_path }}"

- name: Make ffmpeg executable by all users
file:
path: "{{ ffmpeg_executable_path }}"
mode: 0755
when: not ffmpeg_bin.stat.exists

- name: Make ffprobe executable by all users
file:
path: "{{ ffprobe_executable_path }}"
mode: 0755
when: not ffprobe_bin.stat.exists

- name: Delete temp directory
file:
path: "{{ ffmpeg_temp_path }}"
state: absent
7 changes: 7 additions & 0 deletions tasks/uninstall.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- name: Uninstall old ffmpeg and ffprobe
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ ffmpeg_executable_path }}"
- "{{ ffprobe_executable_path }}"