Introducing… *drum rollz*


The One Script to rule them all… 😆

Updated today Nov. 17, 2011

This post will be the natural successor to this one.

## Source of inspiration.
/etc/init.d/SCRIPT -> /lib/init/upstart-job

I took the liberty to recombine my three most used scripts into one. 😉
Its usage is simple:

## The scale and quote scripts take additional parameter(s).
## For 'scale': 4cif, pal or hd are the only options at the moment.
## But feel free to add your own.
## All others: script.name file.name
you@somewhere:~$ ./scale.avi name-of-your-movie.avi (4cif, pal, hd)
e.g.: ./scale.avi name-of-your-movie.avi hd # Upscale file to "$HD" i.e. 1280x720
you@somewhere:~$ ./quote.avi name-of-your-movie.avi (Start End (Either in whole seconds or HH:MM:SS.MSS))
e.g.: ./quote.avi name-of-your-movie.avi 30 60 # Starts at 30s and has a duration of 60s.
e.g.: ./quote.avi name-of-your-movie.avi 60 # Starts at 0s and has a duration of 60s.
you@somewhere:~$ ./xtract.z.avi name-of-your-movie.avi
## Or: (if the script is within your "$PATH"?
scale.avi name-of-your-movie.avi hd # Upscale file to "$HD" i.e. 1280x720
quote.avi name-of-your-movie.avi 30 60 # Starts at 30s and has a duration of 60s.
quote.avi name-of-your-movie.avi 59,04 # Starts at 0s and has a duration of 59.040s.
xtract.z.avi name-of-your-movie.avi
xtract.z.flv name-of-your-movie.flv # I.e. Youtube or equiv. ; - )
## 'z'? equals 'from' ; - )

As for one’s “$PATH”.

# http://linuxcommand.org/wss0010.php
## His Pah is very strong. : - )
## Insert the following in your ~/.bashrc
## Preferably at the end!
## What I use.
# PATH=$PATH:$HOME/.usr/bin
PATH=$PATH:$HOME/your/folder/of/choice
export PATH
## Then all scripts you create and which are placed in "$PATH"
## Can be executed from anywhere you have permission to execute those.
#
## Otherwise you'll have to 'cd' to the folder where your script lives and
## do: ./your-script with-whatever-options-you-have-concocted with-file.ext
## Oh, don't forget to do: chmod u+x on your script first.

In my enthusiasm to post this asap I forgot to mention that for one this script allows you to copy and paste directly from e.g. nautilus. 🙂

But (what I as well forgot to mention):
Your folders and files will be RENAMED if either of those contains space(s)!!! If you don’t want that to happen then simply renaming your file(s), and if applicable your folder(s), before running this script should do the trick. 😉

## When copied from nautilus:
## From:
file:///your/file/at%20some%20where/with%20nasty%20spaces.ext
## To:
/your/file/at.some.where/with.nasty.spaces.ext
## When using tab completion in your shell.
## Type and, if exist, tab until completion.
## From:
/your/file/at\ some\ where/with\ nasty\ spaces.ext
## To:
/your/file/at.some.where/with.nasty.spaces.ext

You might just want to save the following few lines just below for posterity’s sake!? 😉 Why? Well… In order for the script posted on this page to work you’ll have to embrace the concept of linking!

## You might just want to save the following few lines just below for posterity's sake. ; - )
SCRIPT="$(basename "$0")"
for FILE in quote.o{ga,gg,gm} quote.flac quote.avi quote.m{p2,p3,p4,pe,peg,pg,kv} quote.w{mv,av};do ln -s -T "${SCRIPT}" "$(echo "${FILE}")";done
for FILE in scale.o{gg,gm} scale.flac scale.avi scale.m{p4,pe,peg,pg,kv} scale.wmv;do ln -s -T "${SCRIPT}" "$(echo "${FILE}")";done
for FILE in xtract.z.o{gg,gm} xtract.z.avi xtract.z.flv xtract.z.m{p4,pe,peg,pg,kv} xtract.z.wmv;do ln -s -T "${SCRIPT}" "$(echo "${FILE}")";done

Part 1. Its head.

#!/bin/bash
# Modified: Today by E.L.F.
#
## Licensed as:
## http://www.opensource.org/licenses/mit-license.php
#
## Script-name - skel.sh
#
set -e
if [ "$USER" = root ];then
  echo -e ${RED}"Are you Insane!"${NC}
  echo -e ${RED}"Error: In order to use this script, one must NOT be "$USER""${NC}
  echo -e ${YELLOW}"Exiting..."${NC}
  exit 0
else
  echo ""
  echo -e ${BLUE}"    "$USER" may proceed."${NC}
  echo -e ${CYAN}"    May peace be with you."${NC}
fi
clear
for COMMAND in mencoder ffmpeg oggenc cat
do COMMAND=$(which "$COMMAND")
if [ ! -x "$COMMAND" ];then RESULT=NO
echo -e ${YELLOW}"    Please install "${COMMAND}" first before continuing.${NC}
${CYAN}sudo apt-get install "$(basename "${COMMAND}")""${NC};fi
done
if [ "$RESULT" = NO ]; then echo -e ${BLUE}"See (for example):${NC}${YELLOW} http://ubuntuforums.org/showthread.php?t=766683${NC}${BLUE} for more info on the matter."${NC};exit 0;fi
## Variables for the 'scale' command.
date="$(date +"%A, %B %-d, %Y")"
copy=$(echo "Up to you.")
publisher=$(echo "Up to you.")
UPS_EXT=.mkv
HD=1280x720
PAL=720x576
_4CIF=704x576
## Variables for the 'quote' command.
## If 'START' is 'empty' then.
ZERO=00:00:00.000
## If 'END' is 'empty' then.
HALF=00:00:30.000
## Variables for the 'xtract.z' command.
## Print working directory.
PWD=$(pwd)
## Scriptname.
SCRIPT="$(basename "$0")"
## 'basename' of the script.
BASE="$(basename ${SCRIPT%.*})"
## Its 'extension'.
EXT="${SCRIPT/${BASE}/}"
## End variables!
## What would you have your 'arbiter' do.
for OPTION in "${BASE}";do OPTION="${OPTION}";done
for CHOICE in "${EXT}";do CHOICE="${CHOICE}";done
#  ## When no argument is given, print its usage.
  if [ "$BASE" = scale ];then USAGE=$(echo "Usage: "${SCRIPT}" yourfile"${EXT}" 4cif, pal, hd")
  elif [ "$BASE" = quote ];then USAGE=$(echo "Usage: "${SCRIPT}" yourfile"${EXT}" Start End (Either in whole seconds or HH:MM:SS.MSS)")
  else USAGE="Usage: "${SCRIPT}" yourfile"${EXT}"";fi
  if [ "$#" == "0" ];then echo -e ${YELLOW}"$USAGE"${NC};exit 0;fi

Part 2. Its body part 1.

case "$OPTION" in
"cat" | "create")
  if [ "$#" == 1 ];then OUTPUT="$1";OUTPUT+="${EXT}";else echo -n "Enter filename: ";read OUTPUT;OUTPUT+="${EXT}";fi
  echo "$OUTPUT"
  case "$OPTION" in
  "cat")
    case "$CHOICE" in
    ".avi" | ".vob" | ".wmv")
    # LS=$(ls *.{avi,mp{e,eg,g},wmv} 2>/dev/null)
    LS=$(ls *"${EXT}" 2>/dev/null)
    echo "$LS"
    mencoder -forceidx -oac copy -ovc copy $(ls *.avi | sort -n) -o "$OUTPUT"
    mv "$OUTPUT" ../"$OUTPUT"
    \rm *"${EXT}" 2>/dev/null
    mv ../"$OUTPUT" .
    ;;
    ".mpg")
    VAR="mpg-files.txt"
    ls *.mp{e,eg,g} 2>/dev/null | sort > $VAR
    cat $VAR | while read line; do
    INPUT=$(echo ${line})
    cat "$INPUT" >> "$OUTPUT"
    done
    \rm $VAR
    mv "$OUTPUT" ../"$OUTPUT"
    \rm *.mp{e,eg,g} 2>/dev/null
    mv ../"$OUTPUT" .
    ;;
    esac
  ;;
  "create")
    echo "#EXTM3U" > "$OUTPUT"
    find -iname '*.ogg' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mp2' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mp3' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mp4' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mpg' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.wma' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.flv' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.f4v' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.avi' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mkv' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.wmv' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    ;;
  esac
;;

Part 3. Its body part 2 (Ah, IT has no tail :lol:).

"scale" | "quote" | "xtract.z")
  ## Does the filename contain spaces.
  URLENC=$(echo "$1" | sed -e "s_%20_\\ _g")
  if [ -n "${URLENC}" ];then DIR=${URLENC/file:\/\//};else DIR="${DIR}";fi
  ## If so, then move the file into a more 'workable' state.
  MOVED=$(echo "${DIR}" | sed -e "s_\\ _._g")
  if [ -f "${MOVED}" ];then DIR="${DIR}";else mv "${DIR}" "${MOVED}";DIR=${MOVED};fi
  ## Filename. <-- Everything is a 'file' or should I say 'object'.
  FILE=$(basename "${DIR}")
  ## Its 'basename'.
  BASEF=$(basename ${FILE%.*})
  ## Its 'extension'.
  EXTF="${FILE/${BASEF}/}"
  ## Name of out-file.
  OUTPUT=$(basename ${DIR%.*})
  ## Uh oh! 'Error' time.
  if [ ! -f "$DIR" ];then echo -e ${YELLOW}"    The file: "$DIR" doesn't exist!${NC}\n${RED}    Exiting...!!!"${NC}; exit 0;fi
  if [ ! "$EXT" = "$EXTF" ];then
  echo -e ${YELLOW}"  You made a typo!?${NC} ${CYAN}*auto-correcting*${NC}\n
  ${BLUE}From:${NC} ${YELLOW}"$SCRIPT" "${DIR}"${NC}\n
  ${BLUE}To:${NC} ${YELLOW}  "$BASE""$EXTF" "${DIR}""${NC}
  echo
  SCRIPT="$BASE""$EXTF"
  unset EXT
  EXT="${SCRIPT/${BASE}/}"
  sleep 1
  fi
  case "$OPTION" in
  "scale")
    if [ -f "$DIR" ];then
    if [ "$#" == "1" ];then DIR="$DIR";RES=pal;else
    for RES in "$2";do RES=${RES};done
    case "${RES}" in
      "4cif" )
      RES="$HD"
      ;;
      "pal" )
      RES="$PAL"
      ;;
      "pal" )
      RES="$_4CIF"
      ;;
      *)
      echo -e ${YELLOW}"    Please choose a valid option!"${NC}
      echo -e ${BLUE}"    "Usage:"${NC} ${CYAN}"$SCRIPT" "$DIR"${NC} |${CYAN}"4cif"${NC}|${CYAN}"pal"${NC}|${CYAN}"hd"${NC}|"
      exit 0
      ;;
    esac
    fi
    OUTPUT+="$UPS_EXT"
    ffmpeg -y -i "$DIR" \
    -acodec copy \
    -alang eng \
    -vlang eng \
    -metadata title=""$(basename "$OUTPUT" "$UPS_EXT")". ®" \
    -metadata artist=""$USER"" \
    -metadata date="$date" \
    -metadata publisher="$publisher" \
    -metadata copyright="$copy" \
    -vcodec libx264 -vpre lossless_ultrafast -crf 18 \
    -s "$RES" \
    "$OUTPUT"
    fi
  ;;
  "quote")
    if [ -f "$1" ];then
      if [ "$#" == "3" ];then START="$2" && DUR="$3"
      elif [ "$#" == "2" ];then START="${ZERO}" && DUR="$2"
      else [ "$#" == "1" ]
        echo -e ${BLUE}"\tEither in seconds or...,"${NC}
        echo -e ${BLUE}"\tHH:MM:SS.MSS or...,"${NC}
        echo -e ${BLUE}"\tPress enter for starts at 0."${NC}
        echo -en "\tEnter Start Position : "
        read START
        echo -e ${BLUE}"\tEither in seconds or...,"${NC}
        echo -e ${BLUE}"\tHH:MM:SS.MSS"${NC}
        echo -e ${BLUE}"\tPress enter for lasts 30 seconds."${NC}        
        echo -en "\tEnter Duration : "
        read DUR
      fi
      if [ -z "$START" ];then START="${ZERO}";fi
      if [ -z "$DUR" ];then DUR="${HALF}";fi
      for DIGITS in "$START" "$DUR";do
      if [[ "$DIGITS" =~ [^\ 0-9.,:]+ ]];then exit 0;fi
      done
      ## Arg "$2" NEEDS TO BE "QUOTED", e.g. "00 01 30.200"! But at least it works now. ; - )
      SPACE=$(echo "$START" | sed -e "s_\\ _:_g")
      if [ -n "$SPACE" ];then START="$SPACE"
      else start=${START%[ .,_-]*};end=${START/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        START="$start"."$end"
      fi
      ## My num pad doesn't have a dot but uses comma instead.
      COMMA=$(echo "$START" | sed -e "s_,_._g")      
      if [ "$COMMA" = . ];then COMMA="${ZERO}";fi
      if [ -n "$COMMA" ];then START="$COMMA"
      else start=${START%[ .,_-]*};end=${START/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        START="$start"."$end"
      fi
      SPACE=$(echo "$DUR" | sed -e "s_\\ _:_g")
      if [ -n "$SPACE" ];then DUR="$SPACE"
      else start=${DUR%[ .,_-]*};end=${DUR/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        DUR="$start"."$end"
      fi
      COMMA=$(echo "$DUR" | sed -e "s_,_._g")
      if [ "$COMMA" = . ];then COMMA="${HALF}";fi      
      if [ -n "$COMMA" ];then DUR="$COMMA"
      else start=${DUR%[ .,_-]*};end=${DUR/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        DUR="$start"."$end"
      fi
      echo -e ${YELLOW}""${START}""${NC}
      echo -e ${YELLOW}""${DUR}""${NC}      
    OUTPUT+=.quote"$EXT"
    if [ "$EXT" = .oga ] || [ "$EXT" = .ogg ] || [ "$EXT" = .flac ] || [ "$EXT" = .wav ] || [ "$EXT" = .mp3 ];then Choice=AUDIO;else Choice=VIDEO;fi
      case "$Choice" in
      "AUDIO")
      echo -e ${BLUE}"\tffmpeg -y -i "$1" -ss "${START}" -t "${DUR}" -acodec copy -vn "${OUTPUT}""${NC}
      ;;
      "VIDEO")
      echo -e ${BLUE}"\tmencoder -ss "${START}" -endpos "${DUR}" -oac copy -ovc copy "$1" -o "${OUTPUT}""${NC}
      ;;
      esac
    fi
  ;;
  "xtract.z")
    if [ -f "$DIR" ];then WD=ripped/"${BASEF}";OUTPUT=${PWD}"/"${WD}"/"${BASEF};[ ! -d "${WD}" ] && mkdir -p "${WD}"
    ffmpeg -y -threads 2 -i "${DIR}" -vn -acodec pcm_s16le -ac 2 "${WD}"/${BASEF}.wav
    ffmpeg -y -threads 2 -i "${WD}"/${BASEF}.wav -f mp3 -acodec libmp3lame -ac 2 -ab 320k "${WD}"/${BASEF}.mp3
    oggenc "${WD}"/${BASEF}.wav -q 9
    ffmpeg -y -threads 2 -i "${DIR}" -an -vcodec copy "${WD}"/${BASEF}.rip.avi
    fi
  ;;
  esac
;;
esac
exit 0

Part 4. Its “tail” (Well sort of. :lol:).

Questions, suggestions, bugs found!? Feel free to let me know at this address: http://wp.me/PNJrg-p. Will I answer? That depends entirely upon you. ; - ) If you found a flaw/bug and you want me to point you out for that on here, then just say so. Otherwise all other email will be processed confidentially.

The actual script live and for the taking.

#!/bin/bash
# Modified: Today by E.L.F.
#
## Licensed as:
## http://www.opensource.org/licenses/mit-license.php
#
## Script-name - skel.sh
#
set -e
if [ "$USER" = root ];then
  echo -e ${RED}"\tError:${CYAN} \""$USER"\"${YELLOW} isn't allowed to use this script!"${NC};exit 0
else
  echo -e ${BLUE}"\t"$USER" may proceed.\n\t${CYAN}May peace be with you."${NC}
  echo
fi
clear
if [ "$(basename "$0")" = skel.sh ];then
  echo -e "${YELLOW}\tIf the${CYAN} \"Van\"${YELLOW} is${CYAN} Rockin'
  ${YELLOW}\tThen Don't Come a${CYAN} Knockin'"${NC};exit 0
fi
for COMMAND in mencoder ffmpeg oggenc cat
do COMMAND=$(which "$COMMAND")
if [ ! -x "$COMMAND" ];then RESULT=NO
echo -e ${YELLOW}"\tPlease install "${COMMAND}" first before continuing.${NC}
${CYAN}\tsudo apt-get install "$(basename "${COMMAND}")""${NC};fi
done
if [ "$RESULT" = NO ]; then echo -e ${BLUE}"\tSee (for example):${YELLOW} http://ubuntuforums.org/showthread.php?t=766683${BLUE} for more info on the matter."${NC};exit 0;fi
## Variables for the 'scale' command.
date="$(date +"%A, %B %-d, %Y")"
copy=$(echo "Up to you.")
publisher=$(echo "Up to you.")
UPS_EXT=.mkv
HD=1280x720
PAL=720x576
_4CIF=704x576
## Variables for the 'quote' command.
## If 'START' is 'empty' then.
ZERO=00:00:00.000
## If 'END' is 'empty' then.
HALF=00:00:30.000
## Variables for the 'xtract.z' command.
## Print working directory.
PWD=$(pwd)
## Scriptname.
SCRIPT="$(basename "$0")"
## 'basename' of the script.
BASE="$(basename ${SCRIPT%.*})"
## Its 'extension'.
EXT="${SCRIPT/${BASE}/}"
## End variables!
## What would you have your 'arbiter' do.
for OPTION in "${BASE}";do OPTION="${OPTION}";done
for CHOICE in "${EXT}";do CHOICE="${CHOICE}";done
#  ## When no argument is given, print its usage.
  if [ "$BASE" = scale ];then USAGE=$(echo "Usage: "${SCRIPT}" yourfile"${EXT}" 4cif, pal, hd")
  elif [ "$BASE" = quote ];then USAGE=$(echo "Usage: "${SCRIPT}" yourfile"${EXT}" Start End (Either in whole seconds or HH:MM:SS.MSS)")
  elif [ "$BASE" = clean.up ];then USAGE=$(echo "Usage: "${SCRIPT}" yourfile"${EXT}" norm, clean, rev, flash")
  else USAGE="Usage: "${SCRIPT}" yourfile"${EXT}"";fi
  if [ "$#" == "0" ];then echo -e ${YELLOW}"$USAGE"${NC};exit 0;fi
case "$OPTION" in
"cat" | "create")
  if [ "$#" == 1 ];then OUTPUT="$1";OUTPUT+="${EXT}";else echo -en "Enter filename: ";read OUTPUT;OUTPUT+="${EXT}";fi
  echo "$OUTPUT"
  case "$OPTION" in
  "cat")
    case "$CHOICE" in
    ".avi" | ".vob" | ".wmv")
    # LS=$(ls *.{avi,mp{e,eg,g},wmv} 2>/dev/null)
    LS=$(ls *"${EXT}" 2>/dev/null)
    echo "$LS"
    mencoder -forceidx -oac copy -ovc copy $(ls *"$EXT" | sort -n) -o "$OUTPUT"
    mv "$OUTPUT" ../"$OUTPUT"
    \rm *"${EXT}" 2>/dev/null
    mv ../"$OUTPUT" .
    ;;
    ".mpg")
    VAR="mpg-files.txt"
    ls *.mp{e,eg,g} 2>/dev/null | sort > $VAR
    cat $VAR | while read line; do
    INPUT=$(echo ${line})
    cat "$INPUT" >> "$OUTPUT"
    done
    \rm $VAR
    mv "$OUTPUT" ../"$OUTPUT"
    \rm *.mp{e,eg,g} 2>/dev/null
    mv ../"$OUTPUT" .
    ;;
    esac
  ;;
  "create")
    echo "#EXTM3U" > "$OUTPUT"
    find -iname '*.ogg' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mp2' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mp3' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mp4' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mpg' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.wma' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.flv' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.f4v' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.avi' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.mkv' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    find -iname '*.wmv' -exec ls "{}" \; | sort -n >> "$OUTPUT"
    ;;
  esac
;;
"scale" | "quote" | "xtract.z")
  ## Does the filename contain spaces.
  URLENC=$(echo "$1" | sed -e "s_%20_\\ _g")
  if [ -n "${URLENC}" ];then DIR=${URLENC/file:\/\//};else DIR="${DIR}";fi
  ## If so, then move the file into a more 'workable' state.
  MOVED=$(echo "${DIR}" | sed -e "s_\\ _._g")
  if [ -f "${MOVED}" ];then DIR="${DIR}";else mv "${DIR}" "${MOVED}";DIR=${MOVED};fi
  ## Filename. <-- Everything is a 'file' or should I say 'object'.
  FILE=$(basename "${DIR}")
  ## Its 'basename'.
  BASEF=$(basename ${FILE%.*})
  ## Its 'extension'.
  EXTF="${FILE/${BASEF}/}"
  ## Name of out-file.
  OUTPUT=$(basename ${DIR%.*})
  ## Uh oh! 'Error' time.
  if [ ! -f "$DIR" ];then echo -e ${YELLOW}"\tThe file: "$DIR" doesn't exist!\n${RED}    Exiting...!!!"${NC}; exit 0;fi
  if [ ! "$EXT" = "$EXTF" ];then
  echo -e ${YELLOW}"\tYou made a typo!? ${CYAN}*auto-correcting*\n
  ${BLUE}\tFrom: ${YELLOW}"$SCRIPT" "${DIR}"\n
  ${BLUE}\tTo: ${YELLOW}  "$BASE""$EXTF" "${DIR}""${NC}
  echo
  SCRIPT="$BASE""$EXTF"
  unset EXT
  EXT="${SCRIPT/${BASE}/}"
  sleep 1
  fi
  case "$OPTION" in
  "scale")
    if [ -f "$DIR" ];then
    if [ "$#" == "1" ];then DIR="$DIR";RES=pal;else
    for RES in "$2";do RES=${RES};done
    case "${RES}" in
      "4cif" )
      RES="$HD"
      ;;
      "pal" )
      RES="$PAL"
      ;;
      "pal" )
      RES="$_4CIF"
      ;;
      *)
      echo -e ${YELLOW}"\tPlease choose a valid option!"${NC}
      echo -e ${BLUE}"\t"Usage:" ${CYAN}"$SCRIPT" "$DIR" |${CYAN}"4cif"|${CYAN}"pal"|${CYAN}"hd"${NC}|"
      exit 0
      ;;
    esac
    fi
    OUTPUT+="$UPS_EXT"
    ffmpeg -y -i "$DIR" \
    -acodec copy \
    -alang eng \
    -vlang eng \
    -metadata title=""$(basename "$OUTPUT" "$UPS_EXT")". ®" \
    -metadata artist=""$USER"" \
    -metadata date="$date" \
    -metadata publisher="$publisher" \
    -metadata copyright="$copy" \
    -vcodec libx264 -vpre lossless_ultrafast -crf 18 \
    -s "$RES" \
    "$OUTPUT"
    fi
  ;;
  "quote")
    if [ -f "$DIR" ];then
      if [ "$#" == "3" ];then START="$2" && DUR="$3"
      elif [ "$#" == "2" ];then START="${ZERO}" && DUR="$2"
      else [ "$#" == "1" ]
        echo -e ${BLUE}"\tEither in seconds or...,"${NC}
        echo -e ${BLUE}"\tHH:MM:SS.MSS or...,"${NC}
        echo -e ${BLUE}"\tPress enter for starts at 0."${NC}
        echo -en "\tEnter Start Position : "
        read START
        echo -e ${BLUE}"\tEither in seconds or...,"${NC}
        echo -e ${BLUE}"\tHH:MM:SS.MSS"${NC}
        echo -e ${BLUE}"\tPress enter for lasts 30 seconds."${NC}
        echo -en "\tEnter Duration : "
        read DUR
      fi
      if [ -z "$START" ];then START="${ZERO}";fi
      if [ -z "$DUR" ];then DUR="${HALF}";fi
      for DIGITS in "$START" "$DUR";do
      if [[ "$DIGITS" =~ [^\ 0-9.,:]+ ]];then exit 0;fi
      done
      ## Arg "$2" NEEDS TO BE "QUOTED", e.g. "00 01 30.200"! But at least it works now. ; - )
      SPACE=$(echo "$START" | sed -e "s_\\ _:_g")
      if [ -n "$SPACE" ];then START="$SPACE"
      else start=${START%[ .,_-]*};end=${START/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        START="$start"."$end"
      fi
      ## My num pad doesn't have a dot but uses comma instead.
      COMMA=$(echo "$START" | sed -e "s_,_._g")
      if [ "$COMMA" = . ];then COMMA="${ZERO}";fi
      if [ -n "$COMMA" ];then START="$COMMA"
      else start=${START%[ .,_-]*};end=${START/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        START="$start"."$end"
      fi
      SPACE=$(echo "$DUR" | sed -e "s_\\ _:_g")
      if [ -n "$SPACE" ];then DUR="$SPACE"
      else start=${DUR%[ .,_-]*};end=${DUR/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        DUR="$start"."$end"
      fi
      COMMA=$(echo "$DUR" | sed -e "s_,_._g")
      if [ "$COMMA" = . ];then COMMA="${HALF}";fi
      if [ -n "$COMMA" ];then DUR="$COMMA"
      else start=${DUR%[ .,_-]*};end=${DUR/${start}[ .,_-]/}
        if [ "${start}" = "${end}" ];then end=000;else end="$end";fi
        DUR="$start"."$end"
      fi
    OUTPUT+=.quote"$EXT"
    if [ "$EXT" = .oga ] || [ "$EXT" = .ogg ] || [ "$EXT" = .flac ] || [ "$EXT" = .wav ] || [ "$EXT" = .mp3 ];then Choice=AUDIO;else Choice=VIDEO;fi
      case "$Choice" in
      "AUDIO")
      ffmpeg -y -i "${DIR}" -ss "${START}" -t "${DUR}" -acodec copy -vn "${OUTPUT}"
      ;;
      "VIDEO")
      mencoder -ss "${START}" -endpos "${DUR}" -oac copy -ovc copy "${DIR}" -o "${OUTPUT}"
      ;;
      esac
    fi
  "xtract.z")
    if [ -f "$DIR" ];then WD=ripped/"${BASEF}";OUTPUT=${PWD}"/"${WD}"/"${BASEF};[ ! -d "${WD}" ] && mkdir -p "${WD}"
    ffmpeg -y -threads 2 -i "${DIR}" -vn -acodec pcm_s16le -ac 2 "${WD}"/${BASEF}.wav
    ffmpeg -y -threads 2 -i "${WD}"/${BASEF}.wav -f mp3 -acodec libmp3lame -ac 2 -ab 320k "${WD}"/${BASEF}.mp3
    oggenc "${WD}"/${BASEF}.wav -q 9
    ffmpeg -y -threads 2 -i "${DIR}" -an -vcodec copy "${WD}"/${BASEF}.rip.avi
    fi
  ;;
  esac
;;
esac
exit 0

One thought on “Introducing… *drum rollz*

  1. Pingback: E-bike

Comments are closed.