Skip to content
Merged
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
38 changes: 38 additions & 0 deletions docs/lib/ffmpeg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ffmpeg

Wrapper for the `ffmpeg` tool.

---

## fffmpeg-cut

Cut a shot from a video file. The wrapper passes any ffmpeg timing/options you provide.

**Usage**

```
fffmpeg-cut INPUT_FILE OUTPUT_FILE TIMING_POSITIONS

Params:
INPUT_FILE Path to input video file
OUTPUT_FILE Path to output video file
TIMING_POSITIONS Time positions to specify the start and end of cutted segment
Example to extract 10s from 1min: -ss 60 -t 10
or: -ss 00:01:00 -t 00:00:10
```

---

## fffmpeg-join

Join multiple video files using `ffmpeg` concat demuxer.

**Usage**

```
fffmpeg-join OUTPUT_FILE INPUT_FILE...

Params:
OUTPUT_FILE Path to resulting joined file
INPUT_FILE One or more input files to concatenate
```
1 change: 1 addition & 0 deletions docs/nav.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [Database](lib/db.md)
- [Dev Tools](lib/dev.md)
- [Error Handling](lib/error.md)
- [FFmpeg](lib/ffmpeg.md)
- [Files](lib/files.md)
- [Git](lib/git.md)
- [GitHub CLI](lib/github.md)
Expand Down
1 change: 1 addition & 0 deletions lib/_loader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ base_dir=$(cd "$(dirname "${path_self}")" >/dev/null 2>&1 && pwd)
. "${base_dir}/db.sh"
. "${base_dir}/dev.sh"
. "${base_dir}/error.sh"
. "${base_dir}/ffmpeg.sh"
. "${base_dir}/files.sh"
. "${base_dir}/git.sh"
. "${base_dir}/github.sh"
Expand Down
39 changes: 39 additions & 0 deletions lib/ffmpeg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# shellcheck shell=bash
##########################
## Audio/Video Library ##
## ##
## Wrapper for 'ffmpeg' ##
##########################

## Cut a video file
##
## @param $1 Input file
## @param $2 Output file
## @param $@ Positions
## -ss START_TIME [-t DURATION]
#############################################
fffmpeg-cut() {
local input_file="${1:?Input file missing}"
local output_file="${2:?Output file missing}"
shift 2
ffmpeg -i "${input_file}" "${@}" -preset veryfast "${output_file}"
}

## Join multiple video files
##
## @param $1 Output file
## @param $@ Input files
############################
fffmpeg-join() {
local output_file="${1:?Output file missing}"
local temp_file input_file
temp_file=$(mktemp)
shift

for input_file in "${@}"; do
input_file=$(realpath "${input_file}")
echo "file '${input_file}'" >> "${temp_file}"
done

ffmpeg -f concat -safe 0 -i "${temp_file}" -c copy "${output_file}"
}