Bash Script: Video Contact Sheet Generator & ImgChili Uploader | 16:9 Aspect Ratio

Status
Not open for further replies.

Peter South

Active Member
607
2013
360
1,690
This is a Bash script I wrote some months back that does the following:

  1. Uses the Dhyana.pl PERL script to generate contact sheets of videos.
  2. Uploads the contact sheets using cURL to an imgChili account.
  3. Retrieves the URLs for each contact sheet.
  4. Formats the links into [BBCode] which can be then copied and pasted into DDL sites.
Please Note:

Code:
[FONT=courier new]#! /bin/bash[/FONT]
[FONT=courier new]# Script: /usr/local/bin/thumberHD.sh[/FONT]
[FONT=courier new]# Version 13.1001[/FONT]
[FONT=courier new]# Written by SpecialEd @ irc.fileguide.org[/FONT]
[FONT=courier new]# Generates a contact sheet for all videos in a directory that the script is run from.[/FONT]
[FONT=courier new]# This script intended only for videos with a 16:9 wide aspect ratio (HD).[/FONT]
[FONT=courier new]# Once all images are generated they are then uploaded into an authenticated imgChili account,[/FONT]
[FONT=courier new]# retrieves the images' links and formats the URLs into [BBCode] for forums & blogs.[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]# System Requirements #[/FONT]
[FONT=courier new]#######################[/FONT]
[FONT=courier new]# * Web server with accessible sub-folder named "jpg" placed in "/var/www/" [/FONT]
[FONT=courier new]#   - Public access to URLs in this format: [URL]http://www.192.168.0.1/jpg/someFile.jpg[/URL][/FONT]
[FONT=courier new]# * imagemagick, perl modules, & mplayer.[/FONT]
[FONT=courier new]#   - For Ubuntu 12.04LTS+ users simply run:[/FONT]
[FONT=courier new]#     apt-get install imagemagick libgetopt-argvfile-perl libfile-chdir-perl mplayer -y;[/FONT]
[FONT=courier new]# * Dhyana.pl, midentify, VeraSeBd.ttf, & Vera.ttf files - All available in one package:[/FONT]
[FONT=courier new]#    1. wget [URL]http://downloads.fileguide.org/ubuntuVideoThumbnailScript.zip;[/URL][/FONT]
[FONT=courier new]#    2. unzip thumberTools.zip; cd thumberTools/;[/FONT]
[FONT=courier new]#    3. mv dhyana.pl /usr/local/bin/ && chmod +x /usr/local/bin/dhyana.pl[/FONT]
[FONT=courier new]#    4. mv midentify /usr/bin/midentify && chmod +x /usr/bin/midentify[/FONT]
[FONT=courier new]#    5. mkdir /usr/share/fonts/TTF -f 2> /dev/null; mv *.ttf /usr/share/fonts/TTF/[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]# imgChili.com Credentials:[/FONT]
[FONT=courier new]# * Place applicable information between the "" marks. [/FONT]
[FONT=courier new]#   - Example:  userName="someDude";[/FONT]
[FONT=courier new]# * cookieString is the 120 character value of your mmh_user_session Cookie for imgChili[/FONT]
[FONT=courier new]#   - Log into imgChili, view your Firefox/Chrome Cookies for imgChili, its there.[/FONT]
[FONT=courier new]userName='';[/FONT]
[FONT=courier new]passWord='';[/FONT]
[FONT=courier new]cookieString="";[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]echo "*************************************************************"[/FONT]
[FONT=courier new]echo "* Video Contact Sheet Creator & imgChili Uploader v.13.10.1 *"[/FONT]
[FONT=courier new]echo "*         Written by SpecialEd on irc.fileguide.org         *"[/FONT]
[FONT=courier new]echo "*************************************************************"[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]# Generates the sequential video thumbnail preview image[/FONT]
[FONT=courier new]dir=*; for file in $dir; do[/FONT]
[FONT=courier new]  if [[ ${file: -4} == ".txt" ]]; then[/FONT]
[FONT=courier new]    echo `date | sed 's/^/Thumbnails\ Generated\ On\:\ /'` >> imgChiliLinks.txt;[/FONT]
[FONT=courier new]  else[/FONT]
[FONT=courier new]    dhyana.pl $file --cols=4 --rows=4 --geometry 360x203+5+5 --background=#FFFFFF --colour=#054AA3 \[/FONT]
[FONT=courier new]    --heading-colour=#054AA3 --heading-font-size=14 --capture-mode=matt --title=$file 2> /dev/null[/FONT]
[FONT=courier new]  fi[/FONT]
[FONT=courier new]done;[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]# Optional Logo # [/FONT]
[FONT=courier new]#################[/FONT]
[FONT=courier new]# Add a custom logo sized 450x105 pixels to the top right corner of all the images.[/FONT]
[FONT=courier new]# Uncomment next two lines & edit path to desired logo image.[/FONT]
[FONT=courier new]#imageLogo=~/logos/MyLogo.450x105.jpg;[/FONT]
[FONT=courier new]#ls ./* | grep jpeg | xargs -n1 -i composite -geometry +5+5 -gravity northeast $imageLogo {} {};[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]# Uploads the the contact sheets to imgChili using cURL.[/FONT]
[FONT=courier new]publicIP=`curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`;[/FONT]
[FONT=courier new]svtpai=`find ./ -type f -name \*.jpeg | cut -c3-`;[/FONT]
[FONT=courier new]if [[ $svtpai == *.jpeg ]]; then[/FONT]
[FONT=courier new]  mv -f *.jpeg /var/www/jpg/ 2> /dev/null && chmod 777 -R /var/www/jpg/ \[/FONT]
[FONT=courier new]  && chown -R www-data:www-data /var/www/jpg/;[/FONT]
[FONT=courier new]  curl -sd "username=$userName&password=$passWord" -H "Cookie: mmh_user_session=$cookieString" \ [/FONT]
[FONT=courier new]  "http://imgchili.com/remote/http://$publicIP/jpg/$svtpai" | grep 'URL=' | grep -v '<td>' >> \ [/FONT]
[FONT=courier new]  ./imgChiliLinks.txt;[/FONT]
[FONT=courier new]fi[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]# Retrieves the contact sheets' imgChili links & prints their [BBCode] to terminal shell.[/FONT]
[FONT=courier new]cat ./imgChiliLinks.txt | tr -d '\n' | tr -d '\ '[/FONT]
[FONT=courier new]echo " ";[/FONT]
[FONT=courier new]####################################################################################################[/FONT]
[FONT=courier new]# Displays number of files in directory & links generated to help detect if any videos were skipped.[/FONT]
[FONT=courier new]numFiles=`ls ./* | grep -v ".txt" | wc -l`[/FONT]
[FONT=courier new]numLinks=`cat ./imgChiliLinks.txt | wc -l`[/FONT]
[FONT=courier new]echo "Number of files in this directory: "$numFiles;[/FONT]
[FONT=courier new]echo "Total count image links generated: "$numLinks;[/FONT]


For more of my scripts see: Index of various Bash Script Threads contributed by Eddie Johnson.
 
Last edited:
Status
Not open for further replies.
Back
Top