Last active
February 17, 2026 20:47
-
-
Save AfroThundr3007730/551d2d741959bb7d41dc402e31ba28f2 to your computer and use it in GitHub Desktop.
Splice VOD list via ffmpeg (in remote container)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Splice VOD list via ffmpeg (in remote container) | |
| set -euo pipefail | |
| shopt -s extdebug | |
| export REMOTE=debsrv01.dm4productions.com | |
| export VOD_DIR=/mnt/pool0/media/archive/twitch | |
| export OHNO=twitch_disconnect_4s.m2t | |
| remote_splice() { | |
| (($# > 1)) || { echo 'Requires a list of VOD streams to merge.'; exit 1; } | |
| [[ $1 == -i ]] && local int=1 && shift | |
| local files=("$@") | |
| [[ ${files[0]} != "${files[0]%/*}" ]] && | |
| local subdir="${files[0]%/*}" && files=("${files[@]##*/}") | |
| local files2=("${files[@]/m2t/json}") | |
| local cat="concat:${files[*]}" && cat="${cat// /${int:+|..\/$OHNO}|}" | |
| # shellcheck disable=SC2087 | |
| ssh -qt $REMOTE <<EOF | |
| podman start ffmpeg | |
| podman exec -it ffmpeg bash -c ' | |
| pushd $VOD_DIR && pushd "${subdir:-.}" | |
| nice -n 19 ionice -c 3 ffmpeg -hide_banner -i "$cat" -c copy ".${files[0]}" & | |
| disown -h %1 && wait | |
| touch -r "${files[-1]}" ".${files[0]}" | |
| rm -f ${files[@]} && mv ".${files[0]}" "${files[0]}" | |
| rm -f ${files2[@]:1} | |
| exit | |
| ' | |
| podman stop ffmpeg | |
| EOF | |
| } | |
| [[ ${BASH_SOURCE[0]} == "$0" ]] && remote_splice "$@" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basically merge the fragments with
vod-splice /mnt/pool0/media/archive/twitch/foo/foo_XXXX-YY-ZZ_*.m2t