Page 1 of 1

Processing Video with the quickness.

PostPosted: Thu Jan 10, 2019 1:30 pm
by TheeMahn
I have began writing software to process video. I have seen almost 1,000 frames a second. I have Roku Smart TV's and want video native. I will be straight with you. I added an extra step in the process and that is ripping out subtitles. I may eventually make it a switch. I will share the code with you, very shoddy at this time:
Code: Select all
#!/bin/bash
# On the even of crash or exit - probably the most powerful advanced bash trigger IMHO is trap.  Second to none, minus utilizing arrays.

function finish {
    if [[ -f "TEMP.MKV" ]]; then
        rm "TEMP.MKV"
    fi
}

trap finish EXIT

if [[ -f "TEMP.MKV" ]]; then
    rm "TEMP.MKV"
fi

shopt -s nullglob
declare -a MOVIES=();
MOVIES=(*.mkv)
if ! [[ "$1" ]]; then
    for EACH in "${MOVIES[@]}"
    do
        echo "Stripping Subtitles from $EACH to TEMP.MKV"
        mkvmerge --no-subtitles "$EACH" -o TEMP.MKV
        if [[ -s "TEMP.MKV" ]]; then
            rm "$EACH"
            echo "Processing ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 $EACH"
            ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 "$EACH"
        fi
        if [[ -s "TEMP.MKV" ]]; then
            echo "Removing TEMP.MKV"
            rm TEMP.MKV
        fi
    done
else
        if [[ -f "$1" ]]; then
            EACH="$1"
            echo "Stripping Subtitles from $EACH to TEMP.MKV"
            mkvmerge --no-subtitles "$EACH" -o TEMP.MKV
            if [[ -s "TEMP.MKV" ]]; then
                rm "$EACH"
                echo "Processing ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 $EACH"
                ffmpeg -i TEMP.MKV -c:s copy -c:v copy -c:a ac3 "$EACH"
                if [[ -f "$EACH" ]]; then
                    rm "TEMP.MKV"
                fi
            fi
            if [[ -s "TEMP.MKV" ]]; then
                echo "Removing TEMP.MKV"
                rm TEMP.MKV "$EACH"
            fi
        else
            echo "$1 does not exist. Exiting."
        fi
fi


No help system yet, feel free to test it out and enjoy. Remove the subtitle destruction and it straight up rocks.

TheeMahn,