WIP GStreamer Wrapper
This commit is contained in:
@@ -5,53 +5,49 @@
|
||||
#########################
|
||||
|
||||
pid=$$
|
||||
childpid=""
|
||||
defaultargs=(${@:3})
|
||||
defaultargs=($@)
|
||||
hlsslice=${@: -1}
|
||||
hlsroot=${hlsslice::-14}
|
||||
stderrfile="/tmp/ffmpeg-$pid.stderr"
|
||||
logfile="/tmp/ffmpeg.log"
|
||||
|
||||
#########################
|
||||
# UTILS
|
||||
#########################
|
||||
|
||||
function log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$1] $2" >> /tmp/ffmpeg.log
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$1] $2" >> $logfile
|
||||
}
|
||||
function newline() {
|
||||
echo "" >> $logfile
|
||||
}
|
||||
function info() {
|
||||
log "INFO" "$1"
|
||||
}
|
||||
|
||||
function killchild() {
|
||||
function endprocess() {
|
||||
info "========================================[end ffmpeg $pid]"
|
||||
newline
|
||||
rm $stderrfile
|
||||
|
||||
if [[ "$childpid" -ne "" ]]; then
|
||||
info "Killed child ($childpid)"
|
||||
kill -TERM "$childpid" 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
#########################
|
||||
# ENTRYPOINT
|
||||
#########################
|
||||
|
||||
trap killchild SIGTERM
|
||||
trap endprocess SIGTERM
|
||||
|
||||
movie=$(cat "$hlsroot/video_metadata" | jq -r ".path")
|
||||
|
||||
info "========================================[$pid]"
|
||||
newline
|
||||
info "========================================[start ffmpeg $pid]"
|
||||
info "MOVIE: $movie"
|
||||
info "HLS_ROOT: $hlsroot"
|
||||
info "DEFAULT_ARGS: ${defaultargs[*]}"
|
||||
|
||||
declare -a args=(
|
||||
"-i" "$movie"
|
||||
"${defaultargs[@]}"
|
||||
)
|
||||
|
||||
info "ARGS: ${args[*]}"
|
||||
/var/packages/ffmpeg/target/bin/ffmpeg "${args[@]}" 2> $stderrfile &
|
||||
|
||||
childpid=$!
|
||||
wait $childpid
|
||||
|
||||
/var/packages/ffmpeg/target/bin/ffmpeg "${args[@]}" 2> $stderrfile
|
||||
|
||||
44
gst-wrapper.sh
Normal file
44
gst-wrapper.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
#########################
|
||||
# VARS
|
||||
#########################
|
||||
|
||||
pid=$$
|
||||
defaultargs=($@)
|
||||
hlsslice=${@: -1}
|
||||
hlsroot=${hlsslice::-14}
|
||||
stderrfile="/tmp/gstlaunch-$pid.stderr"
|
||||
logfile="/tmp/ffmpeg.log"
|
||||
|
||||
#########################
|
||||
# UTILS
|
||||
#########################
|
||||
|
||||
function log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$1] $2" >> $logfile
|
||||
}
|
||||
function newline() {
|
||||
echo "" >> $logfile
|
||||
}
|
||||
function info() {
|
||||
log "INFO" "$1"
|
||||
}
|
||||
|
||||
function endprocess() {
|
||||
info "========================================[end gst $pid]"
|
||||
newline
|
||||
rm $stderrfile
|
||||
}
|
||||
|
||||
#########################
|
||||
# ENTRYPOINT
|
||||
#########################
|
||||
|
||||
trap endprocess SIGTERM
|
||||
|
||||
newline
|
||||
info "========================================[start gst $pid]"
|
||||
info "GST_ARGS: ${defaultargs[*]}"
|
||||
|
||||
/var/packages/CodecPack/target/pack/bin/gst-launch-1.0.orig "${defaultargs[@]}" 2> $stderrfile
|
||||
Reference in New Issue
Block a user