Batch processing by means of using any script of your choosing.


This script will probably always be a work in progress! Meaning that I want to give the user the choice to run the script of his her choosing. (Is it really required for me to point out that this script was specifically written for the previous posts I wrote.) Think case>select. http://tldp.org/LDP/abs/html/testbranch.html

Small update. Now=11/2/2010 23:51u

Getting closer!  Next step:  if and fi file checks, when?  Tomorrow when I’ve had my beauty sleep.  😀
Finished (for now)! File checks aren’t required, because the script will simply exit with an “command not found” error. No harm done.

Yet another update. Now=11/14/2010 14:40u
I’ve made my script more ‘bulletproof’. Though the script has become somewhat more interactive, I felt it was required due to the following: A script is completely ‘agnostic‘ about what the $USER wants? And because I want to prevent frustration (namely my own :lol:) this script requires you to answer a few more questions and also tries to inform the $USER of what it is exactly, that’s going to happen. In this case to the $USER’s media files but potentially could also be applied to any other alternative usage of this script. I.e. The Sky is the Limit (and then some)! 😉

#!/bin/bash
# Modified: Today by E.l.f.
#
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 2 of the License, or (at your option) any later
## version.
#
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
#
## You should have received a copy of the GNU General Public License along with
## this program; if not, write to the Free Software Foundation, Inc., 51
## Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## http://www.gnu.org/copyleft/gpl.html
#
## Script-name - convert.sh
## vob2ogm.sh avi2mkv.sh mpg2mkv.sh wmvloop.sh must be in your PATH
# mkdir -p $HOME/.usr/bin
## e.g. at the end of your $HOME/.bashrc put in these two lines
## (without the #'s of course >-).
# Alt+F2 > in the popup type in "gedit .bashrc" (without the quotes)
# PATH=$PATH:$HOME/.usr/bin
# export PATH
#
## Source (inspired on): http://ffmpeg.org/ffmpeg-doc.html
## And: http://ubuntuforums.org/showthread.php?t=1037517
RED="\033[0;31m"
BLUE="\033[1;34m"
CYAN="\033[1;36m"
YELLOW="\033[1;33m"
NC="\033[0m"
if [ $USER = root ]; then
  echo -e $RED"   Are you Insane!"
  echo -e $CYAN"    Error: In order to use this script, one must NOT be $USER"
  echo -e $YELLOW"    Exiting..."$NC
  exit 0
else
  echo ""
  echo -e $BLUE"    $USER may proceed."
  echo -e $CYAN"    May peace be with you."$NC
fi
clear # Clear the screen.

echo "-------------------Conversion Options List-------------------"
echo
echo "    Please choose one of the following options:              "
echo "                              Or                             "
echo "    Hit Ctrl+c (^c) to stop now."
echo "    \"UPPER\", \"lower\" and \"Capitalized\" spelling "
echo "    are valid forms of input."
echo
echo "    [quo]te from movies or audio"
echo "    [Rep]air mpg files."
echo "    Convert from [wmv]2avi"
echo "    Con[cat]enate mp(e)g files."
echo "    Convert from [flv]2avi"
echo "    Convert from [vob]2ogm"
echo "    Convert from [avi]2mkv"
echo "    Convert from [mpg]2mkv"
echo
echo "-------------------------------------------------------------"
echo ""

read Choice

case "$Choice" in
    "Wmv" | "WMV" | "wmv")
    echo "    This one WILL change the audio and video properties"
    echo "    of the file(s) it processes."
    echo "    Please adjust the parameters"
    echo "    of the script used in this example"
    echo "    to suit your needs."
    echo "    Do you wish to continue?"
    echo
    echo -n "Enter either yes or no: "
    read answer
    case "$answer" in
        "YES" | "Yes" | "yes")
        wmv2aviloop.sh
          ;;
        "NO" | "No" | "no")
        exit 1
          ;;
        *)
         echo "   Wrong answer!!!"
         echo "   Please rerun the script again?"
         echo "   Then: Either enter yes or no."
         echo "   \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
         echo "   Usage: Yes|No"
         echo
         exit 1
        ;;
    esac
      ;;

    "Flv" | "FLV" | "flv")
    echo "    This one WILL change the audio and video properties"
    echo "    of the file(s) it processes."
    echo "    Please adjust the parameters"
    echo "    of the script used in this example"
    echo "    to suit your needs."
    echo "    Do you wish to continue?"
    echo
    echo -n "Enter either yes or no: "
    read answer
    case "$answer" in
        "YES" | "Yes" | "yes")
        for i in *.flv; do echo "$i" | flv2avi.sh; done
          ;;
        "NO" | "No" | "no")
        exit 1
          ;;
        *)
         echo "   Wrong answer!!!"
         echo "   Please rerun the script again?"
         echo "   Then: Either enter yes or no."
         echo "   \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
         echo "   Usage: Yes|No"
         echo
         exit 1
        ;;
    esac
    ;;

    "Vob" | "VOB" | "vob")
    echo "    This will process your vob files and "
    echo "    leave you with a ogm file (without sound),"
    echo "    for you to process further."
    echo "    See this ubuntuforum thread for more on that:"
    echo "    http://ubuntuforums.org/showthread.php?t=1037517"
    echo "    Source (inspired on): http://ffmpeg.org/ffmpeg-doc.html"
    echo "    Do you wish to continue?"
    echo
    echo -n "Enter either yes or no: "
    read answer
    case "$answer" in
        "YES" | "Yes" | "yes")
        for i in *.vob; do echo "$i" | vob2ogm.sh; done
          ;;
        "NO" | "No" | "no")
        exit 1
          ;;
        *)
         echo "   Wrong answer!!!"
         echo "   Please rerun the script again?"
         echo "   Then: Either enter yes or no."
         echo "   \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
         echo "   Usage: Yes|No"
         echo
         exit 1
        ;;
    esac
    ;;

    "Avi" | "AVI" | "avi")
    echo "    Swap avi container for the free mkv one."
    echo "    Please note that:"
    echo "    This doesn't play well with file%20names%20with%20spaces.avi"
    echo "    Do you wish to continue?"
    echo
    echo -n "Enter either yes or no: "
    read answer
    case "$answer" in
        "YES" | "Yes" | "yes")
        for i in *.avi; do echo "$i" | avi2mkv.sh; done
          ;;
        "NO" | "No" | "no")
        exit 1
          ;;
        *)
         echo "   Wrong answer!!!"
         echo "   Please rerun the script again?"
         echo "   Then: Either enter yes or no."
         echo "   \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
         echo "   Usage: Yes|No"
         echo
         exit 1
        ;;
    esac
    ;;

    "Mpg" | "MPG" | "mpg")
    echo "    Swap mpg container for the free mkv one."
    echo "    If unsure?"
    echo "    Then depending on your needs? "
    echo "    Either run [cat] or [rep] first. "
    echo "    Hint: [Rep] comes after [cat]."
    echo "    Do you wish to continue?"
    echo
    echo -n "Enter either yes or no: "
    read answer
    case "$answer" in
        "YES" | "Yes" | "yes")
        for i in *.mp*; do echo "$i" | mpg2mkv.sh; done
          ;;
        "NO" | "No" | "no")
        exit 1
          ;;
        *)
         echo "   Wrong answer!!!"
         echo "   Please rerun the script again?"
         echo "   Then: Either enter yes or no."
         echo "   \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
         echo "   Usage: Yes|No"
         echo
         exit 1
        ;;
    esac
    ;;

    "Cat" | "CAT" | "cat")
    echo "    The following only applies to mp*g files."
    echo "    Just make sure your mp*g files are, "
    echo "    either in alpabetical or, "
    echo "    in a numerical order!!!"
    echo "    Don't forget to run [rep] hereafter."
    echo "    Available from within this script."
    echo "    Do you wish to continue?"
    echo
    echo -n "Enter either yes or no: "
    read answer
    case "$answer" in
        "YES" | "Yes" | "yes")
        cat.files.sh
          ;;
        "NO" | "No" | "no")
        exit 1
          ;;
        *)
         echo "   Wrong answer!!!"
         echo "   Please rerun the script again?"
         echo "   Then: Either enter yes or no."
         echo "   \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
         echo "   Usage: Yes|No"
         echo
         exit 1
        ;;
    esac
    ;;
    "Quo" | "quo" | "quote")
    quote.sh
    ;;
# cd ~/.usr/bin
# ln -s -T mp42aviloop.sh mpg2aviloop.sh
## So calling either one of the two accomplishes the same goal.
    "Rep" | "REP" | "rep")
    echo "    Only useful when you've cat large amounts of mp(e)g files only to find "
    echo "    their index to be a bit off.  "
    echo "    Also useful to 'rename' mp4 files into avi files"
    echo
    echo "    Did your run [cat] before?"
    echo "    Hint: [Rep] comes after [cat]."
    echo "    Do you wish to continue?"
    echo
    echo -n "Enter either yes or no: "
    read answer
    case "$answer" in
        "YES" | "Yes" | "yes" | "Y" | "y")
        mp42aviloop.sh
          ;;
        "NO" | "No" | "no")
        exit 1
          ;;
        *)
         echo "   Wrong answer!!!"
         echo "   Please rerun the script again?"
         echo "   Then: Either enter yes or no."
         echo "   \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
         echo "   Usage: Yes|No"
         echo
         exit 1
        ;;
    esac
    ;;

    *)
     # Default option.
     # Empty input (hitting RETURN) fits here, too.
     echo
     echo "Please choose a valid option."
     echo "\"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
     echo "Usage: wmv|flv|vob|avi|mpg"
     echo
    ;;
esac

exit 0
## One might figure out to do full recursion with the use of this beauty\!
## Be careful though\!
# find -iname '*.ext' -exec someScript "{}" \;
## This script depends on:
# sudo apt-get install libdvdcss2 k9copy \
# ffmpeg2theora mkvtoolnix-gui avidemux mencoder ffmpeg
## amongst things to work properly

Which will largely be based on the one below. 😉

#!/bin/bash
# Modified: Today by E.l.f.
## # Source: http://tldp.org/LDP/abs/html/testbranch.html
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 2 of the License, or (at your option) any later
## version.
#
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
#
## You should have received a copy of the GNU General Public License along with
## this program; if not, write to the Free Software Foundation, Inc., 51
## Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## http://www.gnu.org/copyleft/gpl.html
#
## Script-name - select_stream.sh
## Can be executed by user (no need for sudo/root access)
## Sanity check.
## The following 8 lines of code have been kindly
## ripped from 71529-ubucleaner.sh  : - )
YELLOW="\033[1;33m"
RED="\033[0;31m"
ENDCOLOR="\033[0m"
if [ $USER = root ]; then
echo -e $RED"Error: In order to use this script, one must NOT be $USER"
echo -e $YELLOW"Exiting..."$ENDCOLOR
exit 0
else
echo ""
echo "The user $USER may proceed."
fi
## These are valid streams but feel free, 
## better yet I (have to) encourage you,
## to change these values!  
## To something jazzy or classical instead, perhaps?  ; - )
BassDrive=$(echo "http://shouthostdirect13.streams.bassdrive.com:8202/")
export BassDrive
Free=$(echo "http://88.191.69.69:80/")
export Free
Folder=$(echo "$HOME/Music/Streams")
export Folder
[ ! -d "$Folder" ] && mkdir $Folder
clear # Clear the screen.
echo "          Stream List"
echo "          ------- ----"
echo "Choose one of the following streams:"
echo
echo "Hit Ctrl+c (^c) to stop recording"
echo
echo "[B]assdrive, Bassdrive.com"
echo "[F]ree hardcore, happyhardcore.com"
echo "[I]nsert something else here, uptoyou.com"
echo
read Stream
NOW="$Stream"-$(date +%F_%k-%M)
OUTFILE=$(echo "$Folder/$NOW.mp3")
export OUTFILE
case "$Stream" in
## Note variables are quoted.
## Basic syntax
# "Selection 1" | "Selection 2" )
# echo "Something to inform the user"
# echo "and then some more.  : - )"
# /usr/bin/<command> to be run with predefined selections.
# ;;
## Note the double semicolon to terminate each option.
# * )
## Default option.
## Empty input (hitting RETURN) fits here, too.
# echo
# echo "Please choose a valid <object>."
# ;;
# esac
# echo
"B" | "b" )
# Accept upper or lowercase input.
echo
echo "Bassdrive - Music Beyond (Free stream)"
echo "http://shouthostdirect13.streams.bassdrive.com:8202/"
echo "Your stream will be saved in $Folder, "
echo "with the name: $NOW.mp3. "
/usr/bin/cvlc -v "$BassDrive" \
':sout=#transcode{acodec=mp3,channels=2}\
:duplicate{dst=display,dst=std{access=file,mux=raw,dst="'$OUTFILE'"}}'
;;
# Note double semicolon to terminate each option.
"F" | "f" )
# Accept upper or lowercase input.
echo
echo "Hardcore 24/7 happyhardcore.com (Free Stream)"
echo "http://88.191.69.69:80/"
echo "Your stream will be saved in $Folder, "
echo "with the name: $NOW.mp3. "
/usr/bin/cvlc -v "$Hardcore" \
':sout=#transcode{acodec=mp3,channels=2,ab=128}\
:duplicate{dst=display,dst=std{access=file,mux=raw,dst="'$OUTFILE'"}}'
;;
# Note double semicolon to terminate each option.
# Add info here for later.
* )
# Default option.
# Empty input (hitting RETURN) fits here, too.
echo
echo "Please choose a valid stream."
;;
esac
echo
exit 0

——————————————————————————–
PS: I am currently thinking about making an ‘easy’ script to ease the installation of packages referred to by the “Comprehensive Multimedia & Video How to“. Though I must say that the last time I did this for my 64bit install, I got apt complaining about missing packages and such. But I’ll keep you posted of my progress anyway! 😆

Yes of course there are always legal matters to attend to, especially when you live in a ‘restricted area’ (take that as you like!?) But for what it is worth: http://monomaxos.com/eng.htm could offer you a possible way around this problem!? 😉

See their terms of use for what I mean.

TERMS OF USE FOR MONOMAXOS 2 ENGLISH EDITION LIVE DVD

MONOMAXOS Linux Operating System is only provided for ‘’demonstration’’ of the capabilities of Linux and Free Software for amateur PC users that haven’t the knowledge to build such a complicated Linux Operating System in their Home Computer and you cannot use it for commercial purposes. MONOMAXOS ISO in this current edition contains ‘’ free ‘’ (read more about the conditions of using free software in the links below) software packages (hardware drivers & software) that are not supposed to be provided functional, in a ‘’ready to use’’ Linux distribution (especially in the U.S.).

http://www.gnu.org/licenses/licenses.html

http://www.ubuntu.com/community/ubuntustory/licensing

For this reason you have to accept that user emcpn made this DVD ISO ‘’only’’ for you, after your request and because you didn’t have any idea how you could come up with something like this , only for educational reasons in order to test the capabilities of Linux Operating Systems.

If you are happy with all these you can proceed to the download of the DVD ISO. If you don’t like the idea of using such a piece of software you can still create your own ‘’MONOMAXOS like’’ , Live DVD using the source packages that were used for MONOMAXOS which are available for download from fast Rapishare.com servers 24 hours per day. The size of the original source packages is about 7 GB and includes everything you need up to the last byte !!! You can find all the software packages and their dependencies plus lists containing all the information of people that created them , their emails and web page address to download newest editions of them.

MONOMAXOS SOURCE PACKAGES DOWNLOAD LINKS

If you are still NOT happy with all this situation and you think that I spend your time for no reason , I have to apologize for this and ask you to leave this web page.

Any questions? I am always just a few clicks away. 😉

Cheers,

Alex

Hmm… Garbled formatting? *Cough cough* How about those smilies in the code you posted?


It might be useful to post the links to the accompanying scripts. 😆

8 thoughts on “Batch processing by means of using any script of your choosing.

  1. I have (re)discovered k9copy: http://k9copy.sourceforge.net/ The article below explains how to convert your dvd(s) into an iso file. After that is done, one could obviously burn another disc.

    http://antler.co.za/article/29/inside-every-dvd-is-a-small-movie-trying-to-get-out-part-1-a-quick-guide-to-k9copy

    To me the important factors are: size (as small as possible) 700 MB preferably but 1400 MB IS better, quality (as high as possible), not too many extra doodles.

    In practice this means that I rip the main feature, choose ac3 (the 6 channels one (or dts if available)) English (most of my dvds are in English), I choose English subtitles (optional) and off I go encoding on the fly (Amd Turion x86-64)

    The cli for this would go something like this.

    # Pass 1 I believe?
    /usr/bin/mencoder /dev/stdin -passlogfile \
    /path/to/dvdrip-data/k9/dvd/k9v98764792.temp \
    -ovc xvid -xvidencopts bitrate=1525:turbo:pass=1:aspect=16/9 \
    -vf crop=720:576:0:0,scale=720:576,dsize=16/9 \
    -af volume=7 -oac copy -sid 1 -ffactor 1 \
    -spualign 2 -sub-bg-alpha 1 -o /dev/null -of avi
    

    Like

    • And again:

      ps aux | grep mencoder
      

      Yields.

      # Pass 2 I believe.
      /usr/bin/mencoder /dev/stdin -passlogfile /path/to/dvdrip-data/k9/dvd/k9v98764792.temp \
      -ovc xvid -xvidencopts bitrate=1525:turbo:pass=2:aspect=16/9 \
      -vf crop=720:576:0:0,scale=720:576,dsize=16/9 -af volume=7 -oac copy \
      -sid 1 -ffactor 1 -spualign 2 -sub-bg-alpha 1 \
      -o /path/to/dvdrip-data/k9/mp4/Some.avi -of avi
      

      Like

  2. Pingback: Now go repair them « Bohemian Wildebeest's Blog

  3. Pingback: Cat 1.mpg 2.mpg 3.mpg et al… > New.mpg « Bohemian Wildebeest's Blog

  4. Pingback: From wmv to avi loop script « Bohemian Wildebeest's Blog

  5. Pingback: Odd, sweet and still elegant. « Bohemian Wildebeest's Blog

Comments are closed.