diff --git a/issue-report.sh b/issue-report.sh index d3c5202..4b2fb42 100644 --- a/issue-report.sh +++ b/issue-report.sh @@ -9,16 +9,6 @@ ffmpeg_version=ffmpeg # shellcheck source=/.github/workflows/mock/VERSION source "/etc/VERSION" -# shellcheck source=/utils/patch_config.sh -source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null || -source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null || -echo "No patch_config.sh" - -# shellcheck source=/utils/patch_config.sh -source "/var/packages/VideoStation/patch/patch_config.sh" 2> /dev/null || -source "/var/packages/CodecPack/patch/patch_config.sh" 2> /dev/null || -echo "No patch_utils.sh" - dsm_version="$productversion $buildnumber-$smallfixnumber" vs_path=/var/packages/VideoStation cp_path=/var/packages/CodecPack diff --git a/patcher.sh b/patcher.sh index f87c73e..b1ac9a8 100755 --- a/patcher.sh +++ b/patcher.sh @@ -207,6 +207,7 @@ patch() { chmod u+s "$vs_path/bin/$filename" sed -i -e "s/@package_name@/VideoStation/" "$vs_path/bin/$filename" + sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$vs_path/bin/$filename" fi done @@ -224,6 +225,7 @@ patch() { chmod u+s "$cp_bin_path/$filename" sed -i -e "s/@package_name@/CodecPack/" "$cp_bin_path/$filename" + sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$cp_bin_path/$filename" fi done @@ -247,13 +249,6 @@ patch() { download "Gstreamer library: $lib" "$repo_base_url/$branch/libs/$lib" "$gst_lib_path/$lib" done fi - - mkdir "$cp_base_path/patch" - download "CodecPack's patch_config.sh" "$repo_base_url/$branch/utils/patch_config.sh" "$cp_base_path/patch/patch_config.sh" - download "CodecPack's patch_utils.sh" "$repo_base_url/$branch/utils/patch_utils.sh" "$cp_base_path/patch/patch_utils.sh" - - info "Setting CodecPack's ffmpeg version to: ffmpeg$ffmpegversion" - sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$cp_base_path/patch/patch_config.sh" fi if [[ -f "$vs_path/bin/gst-launch-1.0" ]]; then @@ -283,13 +278,6 @@ patch() { cp -n "$cp_path/etc/gstomx.conf" "$vs_path/etc/gstomx.conf" fi - mkdir "$vs_base_path/patch" - download "VideoStation's patch_config.sh" "$repo_base_url/$branch/utils/patch_config.sh" "$vs_base_path/patch/patch_config.sh" - download "VideoStation's patch_utils.sh" "$repo_base_url/$branch/utils/patch_utils.sh" "$vs_base_path/patch/patch_utils.sh" - - info "Setting ffmpeg version to: ffmpeg$ffmpegversion" - sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$vs_base_path/patch/patch_config.sh" - info "Saving current libsynovte.so as libsynovte.so.orig" cp -n "$libsynovte_path" "$libsynovte_path.orig" chown VideoStation:VideoStation "$libsynovte_path.orig" @@ -336,9 +324,6 @@ unpatch() { rm -rf "$cp_path/lib/gstreamer/patch" rm -rf "$cp_path/lib/gstreamer/gstreamer-1.0/patch" fi - - info "Remove CodecPack's patch directory" - rm -rf "$cp_base_path/patch" fi if [[ -f "$vs_path/bin/gst-launch-1.0" ]]; then @@ -354,9 +339,6 @@ unpatch() { fi fi - info "Remove VideoStation's patch directory." - rm -rf "$vs_base_path/patch" - restart_packages clean diff --git a/utils/patch_config.sh b/utils/patch_config.sh deleted file mode 100644 index e231af9..0000000 --- a/utils/patch_config.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# shellcheck disable=SC2034 -ffmpeg_version=@ffmpeg_version@ \ No newline at end of file diff --git a/utils/patch_utils.sh b/utils/patch_utils.sh deleted file mode 100644 index 6245528..0000000 --- a/utils/patch_utils.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -stderrfile=/dev/null -child="" -pid=$$ - -log() { - local now - now=$(date '+%Y-%m-%d %H:%M:%S') - echo "[$now] [$1] $2" >> "$stderrfile" -} - -newline() { - echo "" >> "$stderrfile" -} - -info() { - log "INFO" "$1" -} - -kill_child() { - if [[ "$child" != "" ]]; then - kill "$child" > /dev/null 2> /dev/null || : - fi -} - -endprocess() { - info "========================================[end $0 $pid]" - newline - - if [[ $errcode -eq 1 ]]; then - cp "$stderrfile" "$stderrfile.prev" - fi - - kill_child - rm -f "$stderrfile" - - exit "$errcode" -} - -handle_error() { - log "ERROR" "An error occurred" - newline - errcode=1 - kill_child -} - -fix_args() { - while [[ $# -gt 0 ]]; do - case "$1" in - -acodec) - shift - if [[ "$1" = "libfaac" ]]; then - args+=("-acodec" "aac") - else - args+=("-acodec" "libfdk_aac") - fi - ;; - - -vf) - shift - arg="$1" - - if [[ "$arg" =~ "scale_vaapi" ]]; then - scale_w=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\1/p') - scale_h=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\2/p') - - if (( scale_w && scale_h )); then - arg="scale_vaapi=w=$scale_w:h=$scale_h:format=nv12,hwupload,setsar=sar=1" - else - arg="scale_vaapi=format=nv12,hwupload,setsar=sar=1" - fi - fi - - args+=("-vf" "$arg") - ;; - - -r) - shift - ;; - - *) args+=("$1") ;; - esac - - shift - done -} diff --git a/wrappers/ffmpeg.sh b/wrappers/ffmpeg.sh index 0694fe3..34ab2ce 100644 --- a/wrappers/ffmpeg.sh +++ b/wrappers/ffmpeg.sh @@ -1,15 +1,10 @@ #!/bin/bash -# shellcheck source=/utils/patch_utils.sh -source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null || -source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null || -{ echo "Cannot load patch_utils.sh" >> "/tmp/ffmpeg-0.stderr.prev" && echo "Cannot load patch_utils.sh" && exit 1; } - ######################### # VARS ######################### -ffmpeg_version=ffmpeg +ffmpeg_version=@ffmpeg_version@ pid=$$ child="" stderrfile="/tmp/ffmpeg-$pid.stderr" @@ -18,13 +13,90 @@ path=$(realpath "$0") args=() ######################### -# LOAD CONFIG +# UTILS ######################### -# shellcheck source=/utils/patch_config.sh -source "/var/packages/VideoStation/patch/patch_config.sh" 2> /dev/null || -source "/var/packages/CodecPack/patch/patch_config.sh" 2> /dev/null || -{ echo "Cannot load patch_config.sh" >> "/tmp/ffmpeg-0.stderr.prev" && echo "Cannot load patch_config.sh" && exit 1; } +log() { + local now + now=$(date '+%Y-%m-%d %H:%M:%S') + echo "[$now] [$1] $2" >> "$stderrfile" +} + +newline() { + echo "" >> "$stderrfile" +} + +info() { + log "INFO" "$1" +} + +kill_child() { + if [[ "$child" != "" ]]; then + kill "$child" > /dev/null 2> /dev/null || : + fi +} + +endprocess() { + info "========================================[end $0 $pid]" + newline + + if [[ $errcode -eq 1 ]]; then + cp "$stderrfile" "$stderrfile.prev" + fi + + kill_child + rm -f "$stderrfile" + + exit "$errcode" +} + +handle_error() { + log "ERROR" "An error occurred" + newline + errcode=1 + kill_child +} + +fix_args() { + while [[ $# -gt 0 ]]; do + case "$1" in + -acodec) + shift + if [[ "$1" = "libfaac" ]]; then + args+=("-acodec" "aac") + else + args+=("-acodec" "libfdk_aac") + fi + ;; + + -vf) + shift + arg="$1" + + if [[ "$arg" =~ "scale_vaapi" ]]; then + scale_w=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\1/p') + scale_h=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\2/p') + + if (( scale_w && scale_h )); then + arg="scale_vaapi=w=$scale_w:h=$scale_h:format=nv12,hwupload,setsar=sar=1" + else + arg="scale_vaapi=format=nv12,hwupload,setsar=sar=1" + fi + fi + + args+=("-vf" "$arg") + ;; + + -r) + shift + ;; + + *) args+=("$1") ;; + esac + + shift + done +} ######################### # ENTRYPOINT diff --git a/wrappers/gst-inspect-1.0.sh b/wrappers/gst-inspect-1.0.sh index 5702c76..f9a3c17 100644 --- a/wrappers/gst-inspect-1.0.sh +++ b/wrappers/gst-inspect-1.0.sh @@ -2,11 +2,6 @@ export GST_DEBUG=1 #1: ERROR (Log fatal errors only). -# shellcheck source=/utils/patch_utils.sh -source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null || -source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null || -{ echo "Cannot load patch_utils.sh" >> "/tmp/gstinspect-0.stderr.prev" && echo "Cannot load patch_utils.sh" && exit 1; } - ######################### # VARS ######################### @@ -17,6 +12,51 @@ stderrfile="/tmp/gstinspect-$pid.stderr" path=$(realpath "$0") errcode=0 +######################### +# UTILS +######################### + +log() { + local now + now=$(date '+%Y-%m-%d %H:%M:%S') + echo "[$now] [$1] $2" >> "$stderrfile" +} + +newline() { + echo "" >> "$stderrfile" +} + +info() { + log "INFO" "$1" +} + +kill_child() { + if [[ "$child" != "" ]]; then + kill "$child" > /dev/null 2> /dev/null || : + fi +} + +endprocess() { + info "========================================[end $0 $pid]" + newline + + if [[ $errcode -eq 1 ]]; then + cp "$stderrfile" "$stderrfile.prev" + fi + + kill_child + rm -f "$stderrfile" + + exit "$errcode" +} + +handle_error() { + log "ERROR" "An error occurred" + newline + errcode=1 + kill_child +} + ######################### # ENTRYPOINT ######################### diff --git a/wrappers/gst-launch-1.0.sh b/wrappers/gst-launch-1.0.sh index 269f279..e2b69de 100644 --- a/wrappers/gst-launch-1.0.sh +++ b/wrappers/gst-launch-1.0.sh @@ -4,11 +4,6 @@ export GST_DEBUG=1 #1: ERROR (Log fatal errors only). export LD_LIBRARY_PATH=/var/packages/@package_name@/target/lib/gstreamer/patch export GST_PLUGIN_PATH=/var/packages/@package_name@/target/lib/gstreamer/gstreamer-1.0/patch -# shellcheck source=/utils/patch_utils.sh -source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null || -source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null || -{ echo "Cannot load patch_utils.sh" >> "/tmp/gstlaunch-0.stderr.prev" && echo "Cannot load patch_utils.sh" && exit 1; } - ######################### # VARS ######################### @@ -19,6 +14,51 @@ stderrfile="/tmp/gstlaunch-$pid.stderr" path=$(realpath "$0") errcode=0 +######################### +# UTILS +######################### + +log() { + local now + now=$(date '+%Y-%m-%d %H:%M:%S') + echo "[$now] [$1] $2" >> "$stderrfile" +} + +newline() { + echo "" >> "$stderrfile" +} + +info() { + log "INFO" "$1" +} + +kill_child() { + if [[ "$child" != "" ]]; then + kill "$child" > /dev/null 2> /dev/null || : + fi +} + +endprocess() { + info "========================================[end $0 $pid]" + newline + + if [[ $errcode -eq 1 ]]; then + cp "$stderrfile" "$stderrfile.prev" + fi + + kill_child + rm -f "$stderrfile" + + exit "$errcode" +} + +handle_error() { + log "ERROR" "An error occurred" + newline + errcode=1 + kill_child +} + ######################### # ENTRYPOINT #########################