This gallery contains 50 photos.
« Truth resides in every human heart, and one has to search for it there, and to be guided by truth as one sees it. But no one has a right to coerce others to act according to … Continue reading
This gallery contains 50 photos.
« Truth resides in every human heart, and one has to search for it there, and to be guided by truth as one sees it. But no one has a right to coerce others to act according to … Continue reading
It’s your first impression: &laqou; When you put your unedited work out there, that’s what they see as your business-model, basically. And when you have your work edited and perfected, it will be better for you. »
^ So basically, never let your client see your unedited work. Good Advice.
I invite you to have a look and see at The decency debate. Although this aired in 1991, I’m afraid many items still persist to this day.
Part 1:
Part 2:
Part 3:
Part 4:
^ I’m sure you can make up your own minds here!? Other then me pointing out Mr. Stern’s desire to keep interrupting his debate partners.
So now I assume you’ve watched all of them, I did say “assume”, didn’t I?
I can continue to broadcast my message to you. Well for one I pointed out in the group I referred to earlier about a certain someone who has reached the age of 27 recently.
What happens next, is another valued commentator pointing out the bad critics given under the article, about her person.
My response:
I’d say: Reading comments is always at one’s own risk.
![]()
Have you ever seen the movie “Private Parts”? If not… Well there is this scene where they talk about the “average listener”. As in, how much time does a Howard Stern fan listen to his show, if memory serves, that would be around 45 mins. How much time does a “hater” listen? 1hr and 45 minutes (not entirely sure though, but you get the picture). The reason for both was: “I want to hear what he has to say next”
Therefore why would I want to spend my time and attention on haters, it seems to me they are pretty engaged elsewhere in a lesser than useful place then where I’m at. Thus all the free time I now have. I can use to my advantage.
![]()
^ I rest my case.
This brings me back to the part where decency comes into play. What is decency and when do we start to offend. Apparently offending people, in whichever way they respond or not, is quite easy. But what if your desire isn’t to hurt or to offend. But simply the way you used to word things, automatically gets interpreted in the wrong way (both good and bad that is). Now this is pretty tricky. Because it implies that I’d have to watch my mouth, in effect I’d be censoring myself, as Mr. Stern so aptly puts and repeats again and again.
This can’t be! Because if everybody would shut up and be afraid to think out loud (which is what I usually do most) or to speak up. Then this world would become an awfully boring place.
So while the peoples of this world go wonder quietly into the night…. *fade to black goes here* I’m going to leave you with this rather witty remark.
All you need is love, John Lennon, smart man, shot in the back very sad.
^ Speaking of good humor, his character just cracks me up every time I look.
That’s all folks!
Kindest regards,
PS: My words are my own, my actions are my own. Everything I wrote and did in this post are my own responsibility. All I’m offering is: YAP!
«Everything we do (in life) is meaningless, without the appropriate conviction.»
This gallery contains 17 photos.
Short but sweet (again)! Here have a random collection of pictures I shot the other day with my rather aging mobile phone. <- Enhanced and edited for your (but mostly mine! ) viewing pleasure. Gallery here: Slideshow goes here: Always … Continue reading
As the big fan of wordplay that I am. Today I am going to point out the ambiguousness of the English language. A feat. both loved and hated by myself.
Thus this link is for Your amusement and entertainment only:
http://uncyclopedia.wikia.com/wiki/Innuendo
^ Note: Not for the serious or the weak!
Since I believe it is always best to talk through images instead of text only. Because text only, sincerely leaves to much room for other interpretations.
Then again: What’s it like.
Time for a break, no!?
Speaking of WOKs and my sincere dislike for having to type to much. Especially when this concerns me to have to churn out several tidbits or chunks of pure html in my posts.
This ‘global.xml’ snippet will only work in Gedit though.
(But I felt like sharing anyway.
)
<?xml version='1.0' encoding='utf-8'?>
<snippets>
<snippet>
<text><![CDATA[<abbr title="$1">$2</abbr>$0]]></text>
<tag>abbr</tag>
<description>abbr</description>
</snippet>
<snippet>
<text><![CDATA[<a target="_blank" title="$1" href="$2">$3</a>$0]]></text>
<tag>ablank</tag>
<description>ablank</description>
</snippet>
<snippet>
<text><![CDATA[<acronym title="$1">$2</acronym>$0]]></text>
<tag>acro</tag>
<description>acro</description>
</snippet>
<snippet>
<text><![CDATA[<a title="$1" href="$2">$3</a>$0]]></text>
<tag>ahref</tag>
<description>ahref</description>
</snippet>
<snippet>
<text><![CDATA[<a title="$1">$2</a>$0]]></text>
<tag>atitle</tag>
<description>atitle</description>
</snippet>
<snippet>
<text><![CDATA[<blockquote>
$1
</blockquote>
$0]]></text>
<tag>bq</tag>
<description>blockquote</description>
</snippet>
<snippet>
<text><![CDATA[<h4>$1</h4>
$0
]]></text>
<tag>chap</tag>
<description>chap</description>
</snippet>
<snippet>
<text><![CDATA[<em>$1</em>$0]]></text>
<tag>em</tag>
<description>em</description>
</snippet>
<snippet>
<text><![CDATA[#!/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 - $GEDIT_FILENAME
#
]]></text>
<tag>gpl</tag>
<description>gpl</description>
</snippet>
<snippet>
<text><![CDATA[<li>$1</li>
$0
]]></text>
<tag>li</tag>
<description>li</description>
</snippet>
<snippet>
<text><![CDATA[<ol>
$1
</ol>
$0]]></text>
<tag>ol</tag>
<description>ol</description>
</snippet>
<snippet>
<text><![CDATA[<p>$1</p>
$0]]></text>
<tag>p</tag>
<description>p</description>
</snippet>
<snippet>
<text><![CDATA[“$1”$0]]></text>
<tag>q</tag>
<description>q</description>
</snippet>
<!-- The spacing in between source and code is deliberate! -->
<snippet>
<text><![CDATA[1
$1
$0
[/source code]]]></text>
<tag>wp</tag>
<description>source</description>
</snippet>
<snippet>
<text><![CDATA[<strong>$1</strong>$0]]></text>
<tag>strong</tag>
<description>strong</description>
</snippet>
<snippet>
<text><![CDATA[<sub>$1</sub>$0]]></text>
<tag>sub</tag>
<description>sub</description>
</snippet>
<snippet>
<text><![CDATA[<sup>$1</sup>$0]]></text>
<tag>sup</tag>
<description>sup</description>
</snippet>
<snippet>
<text><![CDATA[<ul>
$1
</ul>
$0]]></text>
<tag>ul</tag>
<description>ul</description>
</snippet>
</snippets>
That’s all folks!
Kindest regards,
PS: My words are my own, my actions are my own. Everything I wrote and did in this post are my own responsibility. All I’m offering is: YAP!
«Everything we do (in life) is meaningless, without the appropriate conviction.»
Updated today: Thursday, November 17, 2011
Reason: Script should be near perfect, i.e. bulletproof and foolproof. If not? Then I’m only an email away.![]()
Republished again today: Wednesday, November 09, 2011 <– Thus qualifies as a *bump*
The MAIN reason.
The simplest and best solution I can think of is: For you to visit their website https://www.torproject.org/ and read up on what Tor can and can not do for you!
When you’re convinced of the benefits of anonymous browsing, then…
Click on the Download Tor link, select your platform and be off on your merry way!
Yes folks that is all there is to it.
While the info above is useful for the above average tor user. I however felt the need to write out a script for those of us who wish to make an ‘advanced’ use of Tor’s capabilities while at the same time making sure that our Relay actually can be reached by those who need it the most!
‘Advanced‘ refers to being able to change your sources.list: in either Debian or Ubuntu and thus being able to either configure a relay in a graphical fashion or the manual “hard” way on your own.
I got my info from here and I wanted to simplify matters.
HowcanImakemyrelayaccessibletopeoplestuckbehindrestrictivefirewalls
Based on my platform of preference, this will only work for G.Linux but feel free to add your own (ask nicely and I’ll add it in.) This script can be used in conjunction with the iptables howto I wrote earlier. If NOT, then be sure to replace the ‘tobesortedout’ chain with ‘INPUT’ (default) or your own (if defined?).
Modified: Today (20 Nov. 2011) by E.L.F.
Reason: Completely rewritten and should proof to be satisfactory. If not!?
The Port forwarding Script goes here:
Available as a Demo only, on this page.
#!/bin/bash
# Modified: Today by E.L.F.
#
## Licensed as:
## http://www.opensource.org/licenses/mit-license.php
#
## Script-name - Pf.Tor.sh
#
## Define some colors first:
RED="\033[0;31m"
BLUE="\033[1;34m"
CYAN="\033[1;36m"
YELLOW="\033[1;33m"
NC="\033[0m" # No Color
## --> Nice. Has the same effect as using "ansi.sys" in DOS.
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
SCRIPT=$(basename "$0")
## Trying to be "standard compliant here".
if [ ! -f /etc/iptables.rules ]
then
echo -e ${YELLOW}"\tYou haven't created a firewall as per the author's instructions."${NC}
echo -e ${YELLOW}"\tPlease create the file mentioned or point this script to the right one."${NC}
echo -e ${YELLOW}"\tOr point this script to the one you use instead."${NC}
exit 0
else
echo
echo -e ${BLUE}"\tEverything's OK."${NC}
fi
clear
## It is always useful to know one's internal ipaddress.
echo -e "*-------------------------------${CYAN}${SCRIPT}${NC}----------------------------------*"
WAN=$(netstat -r -n | sed -e "s/^0\.0\.0\.0 *\([0-9.]*\).*/\1/p" -e d )
echo -e ${BLUE}"\tYour router's IP address is: "${NC}
echo -e ${CYAN}"\t$WAN"${NC}
LAN=$(ifconfig $(netstat -r -n | sed -e "s/^0\.0\.0\.0 *.* \([^ ]*\)/\1/p" -e d ) | sed -e 's/ *inet addr:\([0-9.]*\).*/\1/p' -e d )
echo -e ${BLUE}"\tYour IP address is: "${NC}
echo -e ${CYAN}"\t$LAN"${NC}
echo "*--------------------------------------------------------------------------*"
echo
MIN=2
MAX=4
if [ "$#" -eq "0" -o "$#" -eq "1" -o "$#" -eq "3" -o "$#" -gt "$MAX" ]
then echo -e ${YELLOW}"\tThe ${CYAN}"$SCRIPT"${YELLOW} script needs at least 2 and at most 4 options."${NC}
echo -e ${YELLOW}"\tUsage:${CYAN} "$SCRIPT" 443 9001${YELLOW} or ${CYAN}"$(basename "$0")" 443 9001 80 9030"${NC}
echo -e ${RED}"\tWARNING${YELLOW}: For any port chosen under 20 this script will${CYAN} EXIT${YELLOW}!"${NC}
exit 0
## Assume BOTH.
elif [ "$#" -eq "$MAX" ];then
if [[ "$1" =~ [^0-9]+ ]] || [[ "$2" =~ [^0-9]+ ]] || [[ "$3" =~ [^0-9]+ ]] || [[ "$4" =~ [^0-9]+ ]]
then echo -e ${YELLOW}"\tOnly numerical input is allowed.\n\tE.g.:${CYAN} 443 9001 80 9030"${NC};exit 0;fi
if [ "$1" -le 20 -o "$3" -le 20 ];then echo -e ${YELLOW}"\tPorts can't be less than 20!"${NC};exit 0;fi
if [ "$1" -ge 1025 -o "$2" -le 1024 -o "$3" -ge 1025 -o "$4" -le 1024 ];then exit 0
else [ "$1" -le 1024 -a "$2" -ge 1025 -a "$3" -le 1024 -a "$4" -ge 1025 ];fi
RELAY="$1";ORPORT="$2";DIR="$3";DIRPORT="$4";NODIR=NO
## Assume ORPORT only.
elif [ "$#" -eq "$MIN" ];then
if [[ "$1" =~ [^0-9]+ ]] || [[ "$2" =~ [^0-9]+ ]];then echo -e ${YELLOW}"\tOnly numerical input is allowed.\n\tE.g.:${CYAN} 443 9001"${NC};exit 0;fi
if [ "$1" -le 20 ];then echo -e ${YELLOW}"\tPorts can't be less than 20!"${NC};exit 0;fi
if [ "$1" -ge 1025 -o "$2" -le 1024 ];then exit 0;else [ "$1" -le 1024 -a "$2" -ge 1025 ];fi
RELAY="$1";ORPORT="$2";NODIR=YES
else
exit 0
fi
if [ "$NODIR" = YES ];then
echo -e ${CYAN}"iptables -I tobesortedout 3 -i eth0 -p tcp -m tcp --dport "$ORPORT" --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT --reject-with tcp-reset"${NC}
echo -e ${CYAN}"iptables -I tobesortedout 4 -i eth0 -p tcp -m tcp --dport "$ORPORT" -m state --state NEW -m limit --limit 20/sec --limit-burst 40 -j ACCEPT"${NC}
echo -e ${CYAN}"iptables -t nat -A PREROUTING -p tcp -d "$LAN" --dport "$RELAY" -j DNAT --to-destination "$LAN":"$ORPORT""${NC}
echo -e ${CYAN}"iptables -t nat -A OUTPUT -p tcp -d "$WAN" --dport "$RELAY" -j DNAT --to-destination "$LAN":"$ORPORT""${NC}
else [ "$NODIR" = NO ]
echo -e ${CYAN}"iptables -I tobesortedout 3 -i eth0 -p tcp -m tcp --dport "$ORPORT" --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT --reject-with tcp-reset"${NC}
echo -e ${CYAN}"iptables -I tobesortedout 4 -i eth0 -p tcp -m tcp --dport "$ORPORT" -m state --state NEW -m limit --limit 20/sec --limit-burst 40 -j ACCEPT"${NC}
echo -e ${CYAN}"iptables -t nat -A PREROUTING -p tcp -d "$LAN" --dport "$RELAY" -j DNAT --to-destination "$LAN":"$ORPORT""${NC}
echo -e ${CYAN}"iptables -t nat -A OUTPUT -p tcp -d "$WAN" --dport "$RELAY" -j DNAT --to-destination "$LAN":"$ORPORT""${NC}
echo -e ${CYAN}"iptables -I tobesortedout 5 -i eth0 -p tcp -m tcp --dport "$DIRPORT" --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT --reject-with tcp-reset"${NC}
echo -e ${CYAN}"iptables -I tobesortedout 6 -i eth0 -p tcp -m tcp --dport "$DIRPORT" -m state --state NEW -m limit --limit 20/sec --limit-burst 40 -j ACCEPT"${NC}
echo -e ${CYAN}"iptables -t nat -A PREROUTING -p tcp -d "$LAN" --dport "$DIR" -j DNAT --to-destination "$LAN":"$DIRPORT""${NC}
fi
exit 0
Usage: Only numerical input is allowed!
(Don’t choose a port under 20 it will make this script exit.)
## Usage: Only numerical input is allowed! ## Don't choose a port under 20 it will make this script exit. # Pf.tor.sh "relay" "orport" "dir" "dirport" # Standalone to see its usage. ./Pf.tor.sh # Or-port only. # Therefore only two arguments. ./Pf.tor.sh 443 9001 # Both Or and Dir-port # Therefore only four arguments. ./Pf.tor.sh 443 9001 80 9030 #
Now about those color definitions used in the script above:
(These start around line 10)
## For these colors to work either keep the next 5 lines. RED="\033[0;31m" BLUE="\033[1;34m" CYAN="\033[1;36m" YELLOW="\033[1;33m" NC="\033[0m" # No Color # ## OR... # ## Paste the following lines in your ~/.bashrc file for a more 'global feel'. ; - ) ## (At the bottom is recommended.) ## Do uncomment those first before resourcing your ~/.bashrc file. ; - ) ## http://tldp.org/LDP/abs/html/sample-bashrc.html ## Define some colors first: RED="\033[0;31m" export RED BLUE="\033[1;34m" export BLUE CYAN="\033[1;36m" export CYAN YELLOW="\033[1;33m" export YELLOW NC="\033[0m" # No Color export NC # --> Nice. Has the same effect as using "ansi.sys" in DOS. ## Don't forget to resource your bashrc file!
This script can easily be edited for other “port-forwarding” purposes of course (Which for now is to set up your iptables to function properly as a Tor Relay only.). And yes, you have to uncomment all featured commands for them to work.
Why? Because scripts that have to be run as root equals writing demos only to me! Or... you can take a look here for a live version.
Please also note the “Pf.tor.sh.txt.asc” file. It means that you can verify that I made this script:
How?
gpg --verify Pf.tor.sh.txt.asc Pf.tor.sh.txt
But remember!
Despite my efforts to code properly!
(When in doubt always shout...)
## What I've written: ## IS PROVIDED "AS IS", ## WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, ## INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ## IN NO EVENT SHALL THE AUTHOR(S) OR COPYRIGHT HOLDER(S) ## BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ## WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ## OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## For more: http://www.opensource.org/licenses/mit-license.php
See the gallery for a visual representation of the above mentioned script.
(Hiding my internal ip as I did NOT in these pictures, would merely constitute "a security through obscurity" trick.)
For a working example of what one could accomplish with this script, can be seen here.
Also I might or might not enhance my script even further by automatically adding/editing the appropriate stanzas in the 'torrc' file. So one only has to run this script once, restart Tor and then be off with a good start. <-- Maybe!?
Just a friendly notice: This post will frequently be updated and at the discretion of the user ‘republished’.
“…under the premise that the only way to really learn scripting is to write scripts.”
This post is yet another follow up on:
Conversions.
Updated today: Sunday, November 6, 2011
The main reason: I’ve combined both scripts, who were once mentioned on this page.
BUT… In order for it all to work, one has to do the following:
alias link='ln -s -T' ## Assuming here ~/bin to be the user's personal script folder. ## As it usually is on Ubuntu ## (that would be ~/.usr/bin in my case. ; - ) ## And assuming here that you saved the script, ## provided on this page as: 'scale.sh' ## Otherwise change 'scale.sh' to whatever has your fancy. cd ~/bin ## This will give you the scaling abilities of the previous 'upscale.sh' script. link scale.sh scale.avi link scale.sh scale.mkv link scale.sh scale.mp4 link scale.sh scale.mpg link scale.sh scale.ogg link scale.sh scale.ogm link scale.sh scale.ogv link scale.sh scale.wmv ## And this will provide you with the quoting abilities of the previous 'quote.sh' script. link scale.sh quote.avi link scale.sh quote.flac link scale.sh quote.mkv link scale.sh quote.mp3 link scale.sh quote.mp4 link scale.sh quote.mpg link scale.sh quote.oga link scale.sh quote.ogg link scale.sh quote.ogm link scale.sh quote.ogv link scale.sh quote.wav link scale.sh quote.wmv ## And now you have one script that you can invoke in many ways. ; - ) ## But at the moment only as a demo. ## It's up to you to remove those few remaining echo statements, ## Those who do the actual work, see it as an exercise.
Also before we dive into the script, this post originally referred to, I wanted to point out a Very Nice Tool that I’ve recently discovered!
Here is a slightly altered ‘plist’ (xml based) I frequently use to for example convert my personal DVD collection. The ‘preference list’ I obtained from here: http://ubuntuforums.org/showthread.php?t=1350522
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>AudioList</key> <array> <dict> <key>AudioBitrate</key> <string>160</string> <key>AudioEncoder</key> <string>AAC (faac)</string> <key>AudioMixdown</key> <string>Dolby Pro Logic II</string> <key>AudioSamplerate</key> <string>48</string> <key>AudioTrack</key> <integer>1</integer> <key>AudioTrackDRCSlider</key> <real>0</real> <key>AudioTrackDescription</key> <string>English (AC3) (5.1 ch)</string> </dict> </array> <key>ChapterMarkers</key> <false /> <key>Default</key> <false /> <key>FileFormat</key> <string>MP4 file</string> <key>Folder</key> <false /> <key>Mp4HttpOptimize</key> <false /> <key>Mp4LargeFile</key> <false /> <key>Mp4iPodCompatible</key> <false /> <key>PictureAutoCrop</key> <true /> <key>PictureBottomCrop</key> <integer>0</integer> <key>PictureDeblock</key> <integer>4</integer> <key>PictureDecomb</key> <integer>2</integer> <key>PictureDecombCustom</key> <string></string> <key>PictureDecombDeinterlace</key> <true /> <key>PictureDeinterlace</key> <integer>0</integer> <key>PictureDeinterlaceCustom</key> <string></string> <key>PictureDenoise</key> <integer>0</integer> <key>PictureDenoiseCustom</key> <string></string> <key>PictureDetelecine</key> <integer>2</integer> <key>PictureDetelecineCustom</key> <string></string> <key>PictureHeight</key> <integer>0</integer> <key>PictureKeepRatio</key> <true /> <key>PictureLeftCrop</key> <integer>8</integer> <key>PictureLooseCrop</key> <true /> <key>PictureModulus</key> <integer>1</integer> <key>PicturePAR</key> <string>1</string> <key>PicturePARHeight</key> <integer>15</integer> <key>PicturePARWidth</key> <integer>16</integer> <key>PictureRightCrop</key> <integer>6</integer> <key>PictureTopCrop</key> <integer>0</integer> <key>PictureWidth</key> <integer>0</integer> <key>PresetBuildNumber</key> <integer>2009112300</integer> <key>PresetDescription</key> <string>HandBrake's general-purpose preset for High Profile H.264 video, with all the bells and whistles.</string> <key>PresetName</key> <string>PS3</string> <key>SubtitleList</key> <array> </array> <key>Type</key> <integer>1</integer> <key>UsesPictureFilters</key> <integer>1</integer> <key>UsesPictureSettings</key> <integer>2</integer> <key>VideoAvgBitrate</key> <integer>2500</integer> <key>VideoEncoder</key> <string>H.264 (x264)</string> <key>VideoFramerate</key> <string>Same as source</string> <key>VideoGrayScale</key> <false /> <key>VideoQualitySlider</key> <real>20</real> <key>VideoQualityType</key> <integer>1</integer> <key>VideoTargetSize</key> <integer>700</integer> <key>VideoTurboTwoPass</key> <false /> <key>VideoTwoPass</key> <false /> <key>anamorphic</key> <true /> <key>par_height</key> <integer>0</integer> <key>par_width</key> <integer>0</integer> <key>x264Option</key> <string>rc-lookahead=50:ref=1:bframes=0:subme=6:trellis=0:analyse=none</string> </dict> </array> </plist>
^^ I hope this helps!?
The following applies to the following script!
## Either invoke as: you@somewhere:~$ ./scale.avi name-of-your-movie.avi you@somewhere:~$ ./quote.avi name-of-your-movie.avi ## Or: (if the script is within your "$PATH"? you@somewhere:~$ scale.avi name-of-your-movie.avi you@somewhere:~$ quote.avi name-of-your-movie.avi
The newly combined script goes here:
[It's only 185 lines long now, this includes comments.
]
What does it do? It either “quotes from” or “(up)scales” the media it is presented with by the user. By passing the filename (w/- or w/o (assumes pwd = wd)) its full path to the script (and yes the script does strip off the “file:///” thingy when copied from within nautilus or eq.)
Scriptname: scale.sh:
#!/bin/bash
# Modified: Today by E.L.F.
#
## http://www.gnu.org/copyleft/gpl.html
#
## Script-name - scale.sh
#
UPS_EXT=.mkv
HD=1280x720
PAL=720x576
_4CIF=704x576
PWD=$(pwd)
export PWD
NOPARAMS=0
MINPARAMS=1
MAXPARAMS=2
date="$(date +"%A, %B %-d, %Y")"
copy=$(echo "Whatever you like!?")
SCRIPT=$(basename "$0")
BASE=$(basename ${SCRIPT%.*})
if [ "$BASE" = scale ]; then REPLACE=scale;OPTION=_1;else [ "$BASE" = quote ]; REPLACE=quote;OPTION=_2;fi
EXT=${SCRIPT#${REPLACE}}
export EXT
export OPTION
FILE=$(basename "$1")
BASEF=$(basename ${FILE%.*})
EXTF=${FILE#${BASEF}}
export EXTF
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
## http://tor-relay.thruhere.net/abs-guide/
## ^^ Always learning! ; - )
echo
if [ "$#" -eq "$MAXPARAMS" ];then DIR="$1" && RES="$2";fi
if [ "$#" -eq "$MINPARAMS" ];then DIR="$1";RES=pal;fi
if [ -n "$1" ]; then DIR=${DIR/file:\/\//};else DIR="$DIR";fi
if [ -n "$2" ];then RES="$RES"; else RES="$RES";fi
if [ "$RES" = hd ];then RES="$HD";else RES="$RES";fi
if [ "$RES" = pal ];then RES="$PAL";else RES="$RES";fi
if [ "$RES" = 4cif ];then RES="$_4CIF";else RES="$RES";fi
if [ ! -f "$DIR" ]; then echo -e ${YELLOW}" The file: "$DIR" doesn't exist! Or you didn't provide one?${NC}\n${RED} Exiting...!!!"${NC}; exit 0;fi
if [ ! "$EXT" = "$EXTF" ]; then
echo -e ${YELLOW}" You probably invoked this script the wrong way:\n
E.g.:${NC} ${BLUE}"$BASE""$EXTF" "$FILE"${NC} ${YELLOW}is correct.\n\
${YELLOW}However:${NC} ${BLUE}"$SCRIPT" "$FILE"${NC} ${YELLOW}is NOT."${NC}
exit 0
fi
if [ "$OPTION" = _1 ]; then CHOICE=SCALE;else CHOICE=QUOTE;fi
case "$CHOICE" in
"SCALE")
if [ -f "$DIR" ]; then
echo -e ${CYAN}" Extension: "$EXT""${NC}
echo -e ${CYAN}" In file: "$DIR""${NC}
OUTPUT=$(basename ${DIR%.*})
OUTPUT+="$UPS_EXT"
echo -e ${CYAN}" Out file: "$PWD"/"$OUTPUT""${NC}
echo -e ${CYAN}"Resolution: "$RES""${NC}
ffmpeg -y -i "$DIR" \
-acodec copy \
-alang eng \
-vlang eng \
-metadata title=""$(basename "$OUTPUT" "$UPS_EXT")". ®" \
-metadata artist=""$USER"" \
-metadata date="$date" \
-metadata publisher="Whatever you like!?" \
-metadata copyright="$copy" \
-vcodec libx264 -vpre lossless_ultrafast -crf 18 \
-s "$RES" \
"$OUTPUT"
fi
;;
"QUOTE")
if [ -f "$DIR" ]; then
echo -e ${CYAN}" Extension: "$EXT""${NC}
echo -e ${CYAN}" In file: "$DIR""${NC}
OUTPUT=$(basename ${DIR%.*})
OUTPUT+=.quoted"$EXT"
echo -e ${CYAN}" Out file: "$PWD"/"$OUTPUT""${NC}
if [ "$EXT" = .oga ] || [ "$EXT" = .ogg ] || [ "$EXT" = .flac ] || [ "$EXT" = .wav ] || [ "$EXT" = .mp3 ]; then Choice=AUDIO;else Choice=VIDEO;fi
echo -e ${BLUE}" Either in seconds or...,"${NC}
echo -e ${BLUE}" HH:MM:SS.MSS or...,"${NC}
echo -e ${BLUE}" Press enter for starts at 0"${NC}
echo -n "Enter Start Position : "
read START
if [ -z "$START" ]; then START=00:00:00.000;fi
if [[ "$START" =~ [A-Za-z]+ ]];then echo -e ${RED}" Input MUST be numerical."${NC};echo -e ${YELLOW}" Exiting..."${NC};exit 0;fi
start=${START%[ .,_-]*}
end=${START/${start}[ .,_-]/}
if [ "${start}" = "${end}" ]; then end=000;else end="$end";fi
START="$start"."$end"
echo -e ${BLUE}" Either in seconds or...,"${NC}
echo -e ${BLUE}" HH:MM:SS.MSS"${NC}
echo -n "Enter Duration : "
read DUR
if [ -z "$DUR" ]; then echo -e ${RED}" Duration can't be zero!."${NC};echo -e ${YELLOW}"Exiting..."${NC};exit 0;fi
if [[ "$DUR" =~ [A-Za-z]+ ]];then echo -e ${RED}" Input MUST be numerical."${NC};echo -e ${YELLOW}" Exiting..."${NC};exit 0;fi
start=${DUR%[ .,_-]*}
end=${DUR/${start}[ .,_-]/}
if [ "${start}" = "${end}" ]; then end=000;else end="$end";fi
DUR="$start"."$end"
case "$Choice" in
"AUDIO")
echo -e ${CYAN}"ffmpeg -y -i "${DIR}" -ss "${START}" -t "${DUR}" -acodec copy -vn "${OUTPUT}""${NC}
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}"
;;
*)
echo
echo -e ${YELLOW}" Please try again?"${NC} ${BLUE}"Possible reason: unsupported filetype?"${NC}
echo -e ${CYAN}" The file used was: "$DIR"."${NC}
;;
esac
fi
;;
*)
echo
echo -e ${YELLOW}" Please try again?"${NC} ${BLUE}"Possible reason: unsupported filetype?"${NC}
echo -e ${CYAN}" The file used was: "$DIR"."${NC}
;;
esac
exit 0
Now about those color definitions used in the script above:
(Oh noes they’re not there anymore! Did I do that on purpose!?
)
## For these colors to work either insert the next 5 lines in the script above. RED="\033[0;31m" BLUE="\033[1;34m" CYAN="\033[1;36m" YELLOW="\033[1;33m" NC="\033[0m" # No Color # ## OR... # ## Paste the following lines in your ~/.bashrc file for a more 'global feel'. ; - ) ## (At the bottom is recommended.) ## http://tldp.org/LDP/abs/html/sample-bashrc.html ## Define some colors first: RED="\033[0;31m" export RED BLUE="\033[1;34m" export BLUE CYAN="\033[1;36m" export CYAN YELLOW="\033[1;33m" export YELLOW NC="\033[0m" # No Color export NC # --> Nice. Has the same effect as using "ansi.sys" in DOS. ## Don't forget to resource your ~/.bashrc file!
Still code efficiency is everything. . <-- So while I managed to greatly reduce the amount of lines used and inserted a check for numeric input only. It still doesn't meet my standards for “Elegance”.
To do: It would be nice if I could specify my input:
e.g. HH:MM:SS.MSS as HH MM SS MSS instead.
The astute reader will for instance see that the script already allows for this format:
SEC MSS to specify either the start or end of a quote.
That would be:
[ .,_-]
To be exact (for a change
)!
To do as well: To make it possible to copy and paste in URLs with spaces in both the filename as well as the folder path(s)! I might want to have a look at:
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
Which is a string I found here!
Next assignment: Write a nautilus script to make it easier for a user to just select his/her files and do the “conversion” (if any) from there.

^^ Or: Simply make your terminal transparent, so you can see what you’re affecting.
Samples:
More free goodies? – Yes!!!
## This is from my $HOME/.bash_functions
## The mandatory: "Hello World" ; - )
hello()
{
echo "Hello, "$1""
}
## Tidy up any html file with 'tidy'
mtidy()
{
config=$(echo "$HOME/.usr/bin/etc/config.txt")
tidy -config $config $1
}
## Extract all media from flash.
## I do all possible outcomes, just in case. ; - )
xtract.z.flv()
{
WD=./ripped
FOLDER="$WD"/$(basename "$1" .flv)
[ ! -d "$FOLDER" ] && mkdir -p "$FOLDER"
ffmpeg -y -threads 2 -i "$1" -vn -acodec pcm_s16le -ac 2 "$FOLDER"/$(basename "$1" .flv).wav # <-- Rip audio from flv to wav.
ffmpeg -y -threads 2 -i "$FOLDER"/$(basename "$1" .flv).wav -f mp3 -acodec libmp3lame -ac 2 -ab 320k "$FOLDER"/$(basename "$1" .flv).mp3 # <-- Rip to mp3.
oggenc "$FOLDER"/$(basename "$1" .flv).wav -q 9 # <-- Rip to ogg.
ffmpeg -y -threads 2 -i "$1" -an -vcodec copy "$FOLDER"/$(basename "$1" .flv).rip.avi # <-- Rip the video only.
\rm "$FOLDER"/$(basename "$1" .flv).wav
}
## Extract all media from avi.
xtract.z.avi()
{
WD=./ripped
FOLDER="$WD"/$(basename "$1" .avi)
[ ! -d "$FOLDER" ] && mkdir -p "$FOLDER"
ffmpeg -y -threads 2 -i "$1" -vn -acodec pcm_s16le -ac 2 "$FOLDER"/$(basename "$1" .avi).wav # <-- Rip audio from flv to wav.
ffmpeg -y -threads 2 -i "$FOLDER"/$(basename "$1" .avi).wav -f mp3 -acodec libmp3lame -ac 2 -ab 320k "$FOLDER"/$(basename "$1" .avi).mp3 # <-- Rip to mp3.
oggenc "$FOLDER"/$(basename "$1" .avi).wav -q 9 # <-- Rip to ogg.
ffmpeg -y -threads 2 -i "$1" -an -vcodec copy "$FOLDER"/$(basename "$1" .avi).rip.avi # <-- Rip the video only.
\rm "$FOLDER"/$(basename "$1" .avi).wav
}
## Extract all media from mpg.
xtract.z.mpg()
{
WD=./ripped
FOLDER="$WD"/$(basename "$1" .mpg)
[ ! -d "$FOLDER" ] && mkdir -p "$FOLDER"
ffmpeg -y -threads 2 -i "$1" -vn -acodec pcm_s16le -ac 2 "$FOLDER"/$(basename "$1" .mpg).wav # <-- Rip audio from flv to wav.
ffmpeg -y -threads 2 -i "$FOLDER"/$(basename "$1" .mpg).wav -f mp3 -acodec libmp3lame -ac 2 -ab 320k "$FOLDER"/$(basename "$1" .mpg).mp3 # <-- Rip to mp3.
oggenc "$FOLDER"/$(basename "$1" .mpg).wav -q 9 # <-- Rip to ogg.
ffmpeg -y -threads 2 -i "$1" -an -vcodec copy "$FOLDER"/$(basename "$1" .mpg).rip.avi # <-- Rip the video only.
\rm "$FOLDER"/$(basename "$1" .mpg).wav
}
## Extract all media from mp4.
xtract.z.mp4()
{
WD=./ripped
FOLDER="$WD"/$(basename "$1" .mp4)
[ ! -d "$FOLDER" ] && mkdir -p "$FOLDER"
ffmpeg -y -threads 2 -i "$1" -vn -acodec pcm_s16le -ac 2 "$FOLDER"/$(basename "$1" .mp4).wav # <-- Rip audio from flv to wav.
ffmpeg -y -threads 2 -i "$FOLDER"/$(basename "$1" .mp4).wav -f mp3 -acodec libmp3lame -ac 2 -ab 320k "$FOLDER"/$(basename "$1" .mp4).mp3 # <-- Rip to mp3.
oggenc "$FOLDER"/$(basename "$1" .mp4).wav -q 9 # <-- Rip to ogg.
ffmpeg -y -threads 2 -i "$1" -an -vcodec copy "$FOLDER"/$(basename "$1" .mp4).rip.avi # <-- Rip the video only.
\rm "$FOLDER"/$(basename "$1" .mp4).wav
}
## Extract all media from wmv.
xtract.z.wmv()
{
WD=./ripped
FOLDER="$WD"/$(basename "$1" .wmv)
[ ! -d "$FOLDER" ] && mkdir -p "$FOLDER"
ffmpeg -y -threads 2 -i "$1" -vn -acodec pcm_s16le -ac 2 "$FOLDER"/$(basename "$1" .wmv).wav # <-- Rip audio from flv to wav.
ffmpeg -y -threads 2 -i "$FOLDER"/$(basename "$1" .wmv).wav -f mp3 -acodec libmp3lame -ac 2 -ab 320k "$FOLDER"/$(basename "$1" .wmv).mp3 # <-- Rip to mp3.
oggenc "$FOLDER"/$(basename "$1" .wmv).wav -q 9 # <-- Rip to ogg.
ffmpeg -y -threads 2 -i "$1" -an -vcodec copy "$FOLDER"/$(basename "$1" .wmv).rip.avi # <-- Rip the video only.
\rm "$FOLDER"/$(basename "$1" .wmv).wav
}
## Rip from wmv to xvid in avi container directly.
## Please note amongst things the -s switch here!
## I.e.: Please, do a...
# ffmpeg -i "$YOUR.INPUT" to show you the resolution, rate, aspect ratio and other useful telltale signs. ; - )
wmv2xvid.hd720()
{
WD=./ripped
FOLDER="$WD"/$(basename "$1" .wmv)
[ ! -d "$FOLDER" ] && mkdir -p "$FOLDER"
ffmpeg -y -threads 2 -i "$1" -f avi -r 25 -vcodec libxvid -vtag XVID -s hd720 -aspect 16:9 -maxrate 1800k -b 1400kb -qmin 3 -qmax 5 -bufsize 4096 -mbd 2 -bf 2 -flags +4mv -trellis -aic -cmp 2 -subcmp 2 -g 300 -an $(basename "$1" .wmv).xvid.avi
}
## Rip from wav to mp3.
wav2mp3()
{
ffmpeg -y -threads 2 -i "$1" -f mp3 -acodec libmp3lame -ac 2 -ab 320k $(basename "$1" .wav).mp3 # <-- Rip to mp3.
}
## Rip from wav to ogg.
wav2ogg()
{
oggenc "$1" -q 9
}
## "panavision" : - )
upscale()
{
mencoder "$1" -endpos 00:00:20 -oac copy -ovc xvid -xvidencopts \
chroma_opt:vhq=4:bvhq=1:quant_type=mpeg:bitrate=1400 \
-vf scale=1280:544,expand=1280:720 \
-o $(basename "$1" .avi).HD.men.avi
}
## Evolvotron specific.
evolve()
{
evolvotron_render -f 96 -r 8 -j -a -m 4 -s 720 576 -spheremap "$1".ppm < $HOME/Downloads/vid.edit/evolved0.xml
}
evolvehd()
{
ffmpeg -y -b 3000k -r 8 -f image2 -i "$1".f%6d.ppm -qscale 4 -qblur 1.0 -aspect 16:9 -g 300 -s hd720 "$1".avi
}
evolvepal()
{
ffmpeg -y -b 3000k -r 8 -f image2 -i "$1".f%6d.ppm -qscale 4 -qblur 1.0 -aspect 16:9 -g 300 "$1".avi
}
## This function will simulate the effect the "mod_deflate" module for Apache has, for the same named files.
## Only to be used with a server who understands the .gz format out of the box: I.e. thttpd
## Also works in a chroot'ed environment. ; - )
massedit()
{
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.
case "$1" in
"HTML" | "Html" | "html")
if [ ! "$(ls *.html 2>/dev/null)" ]
then
echo -e $YELLOW"$1 does not exist."$NC; echo
else
echo -e $BLUE" You've chosen \"$(ls *.html | wc -l)\" file(s) to work on."$NC
echo -e $RED"Executing..."$NC
for i in *.html; do gzip -c --best $i > $i.gz;done
for i in *.html; do \rm $i;done
for i in *.html.gz; do ln -s -T "$i" $(basename "$i" .gz);done
fi
;;
"TXT" | "Txt" | "txt" | "TEXT" | "Text" | "text")
if [ ! "$(ls *.txt 2>/dev/null)" ]
then
echo -e $YELLOW"$1 does not exist."$NC; echo
else
echo -e $BLUE" You've chosen \"$(ls *.txt | wc -l)\" file(s) to work on."$NC
echo -e $RED"Executing..."$NC
for i in *.txt; do gzip -c --best $i > $i.gz;done
for i in *.txt; do \rm $i;done
for i in *.txt.gz; do ln -s -T "$i" $(basename "$i" .gz);done
fi
;;
"CSS" | "Css" | "css")
if [ ! "$(ls *.css 2>/dev/null)" ]
then
echo -e $YELLOW"$1 does not exist."$NC; echo
else
echo -e $BLUE" You've chosen \"$(ls *.css | wc -l)\" file(s) to work on."$NC
echo -e $RED"Executing..."$NC
for i in *.css; do gzip -c --best $i > $i.gz;done
for i in *.css; do \rm $i;done
for i in *.css.gz; do ln -s -T "$i" $(basename "$i" .gz);done
fi
;;
"XML" | "Xml" | "xml")
if [ ! "$(ls *.xml 2>/dev/null)" ]
then
echo -e $YELLOW"$1 does not exist."$NC; echo
else
echo -e $BLUE" You've chosen \"$(ls *.xml | wc -l)\" file(s) to work on."$NC
echo -e $RED"Executing..."$NC
for i in *.xml; do gzip -c --best $i > $i.gz;done
for i in *.xml; do \rm $i;done
for i in *.xml.gz; do ln -s -T "$i" $(basename "$i" .gz);done
fi
;;
"JS" | "Js" | "js")
if [ ! "$(ls *.js 2>/dev/null)" ]
then
echo -e $YELLOW"$1 does not exist."$NC; echo
else
echo -e $BLUE" You've chosen \"$(ls *.js | wc -l)\" file(s) to work on."$NC
echo -e $RED"Executing..."$NC
for i in *.js; do gzip -c --best $i > $i.gz;done
for i in *.js; do \rm $i;done
for i in *.js.gz; do ln -s -T "$i" $(basename "$i" .gz);done
fi
;;
*)
echo
echo "Please choose a valid option."
echo "\"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"
echo -e $YELLOW" Usage$NC: "
echo -e $CYAN" massedit$NC$BLUE html$NC"
echo -e $CYAN" massedit$NC$BLUE text$NC"
echo -e $CYAN" massedit$NC$BLUE js$NC"
echo -e $CYAN" massedit$NC$BLUE xml$NC"
echo -e $CYAN" massedit$NC$BLUE css$NC"
echo
;;
esac
}
## This one removes the empty lines and unnecessary spaces,
## of the text based type of file,
## you gave it to chew on. ; - )
squeeze()
{
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.
if [ ! -e "$1" ]
then
echo -e $YELLOW"$1 does not exist."$NC; echo
else
## This removes the trailing spaces in your doc.
sed -i 's/[ \t]*$//' "$1"
## Removing those empty lines for you as well.
sed -i '/^$/d' "$1"
fi
}
## The following function might interest some of you?
## With the added bonus to either sign or verify signatures.
#
## As taken from here: https://calomel.org/openssh.html
## At the bottom of the page you can find the related
## openssl commands which will correspond to the ones
## used in the function below.
crypto()
{
if [ -z "$1" ]; then
echo -e $YELLOW" Please choose a valid option!"$NC
echo -e $YELLOW" Usage"$NC": "$CYAN"\"UPPER\""$NC", "$CYAN"\"lower\""$NC" and "$CYAN"\"Capitalized\""$NC" spelling are supported."
echo -e $CYAN" crypto"$NC" {"$CYAN"--ENCRYPT"$NC","$CYAN"--Encrypt"$NC","$CYAN"--encrypt"$NC","$CYAN"-E"$NC","$CYAN"-e"$NC"}: $BLUE Your-file $NC"
echo -e $CYAN" crypto"$NC" {"$CYAN"--DECRYPT"$NC","$CYAN"--Decrypt"$NC","$CYAN"--decrypt"$NC","$CYAN"-D"$NC","$CYAN"-d"$NC"}: $BLUE Your-file.aes $NC"
echo -e $CYAN" crypto"$NC" {"$CYAN"--SIGN"$NC","$CYAN"--Sign"$NC","$CYAN"--sign"$NC","$CYAN"-S"$NC","$CYAN"-s"$NC"}: $BLUE Your-file $NC"
echo -e $CYAN" crypto"$NC" {"$CYAN"--VERIFY"$NC","$CYAN"--Verify"$NC","$CYAN"--verify"$NC","$CYAN"-V"$NC","$CYAN"-v"$NC"}: $BLUE Your-file.asc $NC"
elif [ -z "$2" ]; then
echo -e $YELLOW" Error: Providing a filename is MANDATORY! "$NC
echo -e $RED" Exiting..."$NC
elif [ -d "$2" ]; then
echo -e $YELLOW" Error: File is a directory!"$NC
echo -e $RED" Exiting..."$NC
else
case "$1" in
"--ENCRYPT" | "--Encrypt" | "--encrypt" | "-E" | "-e")
## to encrypt (-e):
openssl aes-256-cbc -a -e -salt -in "$2" -out "$2".aes
;;
"--DECRYPT" | "--Decrypt" | "--decrypt" | "-D" | "-d")
## to decrypt (-d):
openssl aes-256-cbc -a -d -salt -in "$2" -out $(basename "$2" .aes)
;;
"--SIGN" | "--Sign" | "--sign" | "-S" | "-s")
## to sign (-s):
echo -e $CYAN" gpg -a --detach-sign \""$2"\""$NC
gpg -a --detach-sign "$2"
;;
"--VERIFY" | "--Verify" | "--verify" | "-V" | "-v")
## to verify (-v):
echo -e $CYAN" gpg --verify \""$2"\" \"$(basename "$2" .asc)\""$NC
gpg --verify "$2" $(basename "$2" .asc)
;;
*)
echo
echo -e $YELLOW" Nothing done!"$NC
echo
;;
esac
fi
}
The tidy config file as mentioned in one of the many functions above.
// sample config file for HTML tidy doctype: transitional indent: auto indent-spaces: 2 wrap: 76 markup: yes bare: yes clean: yes preserve-entities: yes output-xml: no input-xml: no output-xhtml: yes show-warnings: yes numeric-entities: yes quote-marks: yes quote-nbsp: yes quote-ampersand: no break-before-br: no uppercase-tags: no uppercase-attributes: no char-encoding: utf8 input-encoding: utf8 output-bom: auto output-encoding: utf8 new-inline-tags: cfif, cfelse, math, mroot, mrow, mi, mn, mo, msqrt, mfrac, msubsup, munderover, munder, mover, mmultiscripts, msup, msub, mtext, mprescripts, mtable, mtr, mtd, mth new-blocklevel-tags: cfoutput, cfquery new-empty-tags: cfelse repeated-attributes: keep-last error-file: errs.txt write-back: yes
How?
## Which you can enable just like you'd for a possible .bash_aliases file
## Like so (in your $HOME/.bashrc) in my case around line 91:
## By uncommenting the following, if necessary (i.e.: removing the #'s in front)
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
## And adding this block right thereafter.
## Don't forget to create the file. ; - )
# Functions: check for a separate function file, and if we find one
# source it.
if [[ -f ~/.bash_functions ]]; then
. ~/.bash_functions
fi
Updated today: Sunday, September 4, 2011
Reason: I’ve altered a few tidbits here and there in the script, with the result of providing a better picture/end result but at the cost of a slightly increased filesize. For example: an hour of footage, this depends on the amount of fast moving objects, is equivalent to say: 1GB, not bad when one considers a ‘ripped’ DVD with an approx bitrate of 1400kb/s to be of size: ~ 1.5GB. Fwiw I record my desktop in “HD ready” (1280×720) quality now.
Anyway!
There are times one wants to do a bit more than simply make a screenshot of one’s desktop. This is either to just prove a point or simply for the fun of it. Which can be done like so on afaik both windows and G(nu)/linux, Just press: (alt)+PrtSc and tada a picture of your desktop resides on your clipboard. Now in windows with the lack of a decent photo-editor (I’m not counting ‘paint’ here.
) or while you perhaps use a stripped down version of windows at work? One then simply opens up a word doc or if ‘paint’ is present open that instead. Hit ‘paste (ctrl+v), use the save as to give your ‘screenshot’ a name, that’s all there’s to it.
Use it with ‘alt’ for the current window and on its own for the whole desktop.
But since I am not on windows. I instead work with a rather flexible system that comes with a lot of interesting {features,goodies} in its default state; such as ‘gnome-screenshot‘. Therefore, I can do the following.
For the current window:
gnome-screenshot -b -w -d 2 -e shadow
For a selected region:
gnome-screenshot --area
And probably a whole lot more: man gnome-screenshot
Post production of any shot made this way and if needed!? I do with the ‘Gimp‘
No offense intended towards the following program!!! gtk-recordMyDesktop because in a lot of ways it is far more advanced than what I am about to show ye! Especially when it concerns choosing a region to record. My dislike has more to do with the theora (video) codec than it has to do with the program!
Its alternative and hence the reason for this quick post is simply to grab one’s screen: Howto.
OK, so here is the script:
Scriptname: xgrabber.sh
#!/bin/bash
# Modified: Today by E.L.F.
#
## Licensed as:
## http://www.opensource.org/licenses/mit-license.php
#
## Script-name - xgrabber.sh
#
set -e
#. "$HOME"/.bash_functions
## http://ubuntuforums.org/tags.php?tag=recordmydesktop
## http://ubuntuforums.org/showthread.php?t=1392026 - How to screencast properly.
## https://wiki.ubuntu.com/PulseAudio
if [ "$USER" = root ];then echo -e "\tError: \""$USER"\" isn't allowed to use this script!";exit 0
else echo -e "\t${USER} may proceed.\n\tMay peace be with you.\n";fi
Color_Test=$(grep -i '\\033\[' "$HOME"/.bashrc)
if [ -n "$Color_Test" ];then echo -e ${Magenta}"\tOk, colors are defined."${Nc}
else
Black="\033[0;30m"
Red="\033[0;31m"
Green="\033[0;32m"
Yellow="\033[1;33m"
Blue="\033[1;34m"
Magenta="\033[1;35m"
Cyan="\033[1;36m"
White="\033[1;37m"
Nc="\033[0m" # No Color
echo -e ${White}"\tThey weren't, but now they are."${Nc}
fi
clear
## Monitor operates at 60hz.
echo -n "Enter name for output file: "
read Output
## The following line makes certain you can type a 'normal' sentence as filename.
## All this without 'violating' UNIX' restriction on spaces.
## I.e. 'This is my recording' becomes 'This.is.my.recording'
Output=$(echo "$Output" |sed -e 's_ _._g')
Output+=".mkv"
## Change to a foldername of your convenience.
WD=/my/folder/tmp
[ ! -d "$WD" ] && mkdir "$WD"
## Now you can press either 'minimize' or 'alt+f9' in my case
## To get the terminal out of your way.
## You have 2 seconds to do so.
sleep 2
## Adjust '-s 1366x716' to fit your purposes, same goes for this ':0.0+0,25'
ffmpeg -y -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1366x768 -i :0.0 \
-acodec pcm_s16le -alang eng \
-vcodec libx264 -vpre ultrafast -crf 18 -threads 0 -vlang eng \
-metadata title=$(basename "$Output" .mkv) \
-metadata artist="$USER" \
-metadata date="$(date +"%A, %B %-d, %Y")" \
-metadata publisher="$(echo "What is in a name anyway.")" \ # Change me.
-metadata copyright="$(echo "Attribution 3.0 Unported (CC BY 3.0)")" \ # Change me.
## '-s hd720' change this to suit your purposes.
-s hd720 "$WD"/"$OUTPUT"
exit 0
An example screen-recording (used the previous script that I had posted up here before.) can be seen here [Yes an 720p (HD ready) version is also available.
]:
I have been fine-tuning my screen-recording capabilities, so be ready to get bored, quickly.
But at least now I know how to grab only the portion of the screen I want and provide you with a saner resolution.![]()
An example with mpeg4 encoding. (21.1MB)
^^
Seems OK with me and is the one I used with this script.
An example with x264 encoding. (51.0MB)
^^
Smoother picture, but somewhat troublesome with faster moving pictures and larger than life filesize (approx 3GB for an whole hour!).
Enjoy and profit!?
PS: Time used aside from whatever it is you’re trying to record for pre and post production? No more then a few minutes of your time on a fairly modern computer.
Updated today: Saturday, September 10, 2011
(Dear reader, you might want to take a look at the following post: http://wp.me/pNJrg-dM Why? Well I’ve got plans to add this one and many others to my “one script to rule them all” effort soon.)
Either:
cat 1.mpg 2.mpg 3.mpg et al... > New.mpg
Or:
If one were so inclined to do:
cat 1.vob 2.vob 3.vob et al... > New.vob
Anyway this post belongs to its master:
case-select-video-conversions/
Related post:
odd-sweet-and-still-elegant
By far the easiest way to join multiple *.mp(e)g files together is to merge them with a simple utility called cat. There is only one problem though. While playback of the new file will work (most of the times
) one will notice that the time index is off (Relating to the first file in the catenated series.) To overcome this problem: One uses in the next example an ever handy utility called: avidemux.
#!/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 - cat-mpg.sh
#
## Source (inspired on): http://ffmpeg.org/ffmpeg-doc.html
## And: http://ubuntuforums.org/showthread.php?t=1037517
## If colors are not defined in .bashrc, then uncomment the next three lines.
#YELLOW="\033[1;33m"
#RED="\033[0;31m"
#ENDCOLOR="\033[0m"
## Root check / Sanity check. You decide. >-)
## Just in case someone calls this script with sudo -s,
## or has cd'ed into his/her path.
if [ $USER = root ]; then
echo -e $RED"Are you Insane!"
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 "$USER may proceed."
echo "May peace be with you."
fi
echo -n "Enter filename: "
read OUTPUT
OUTPUT=$OUTPUT
OUTPUT+=".mpg" # Append new extension
VAR="mpg-files.txt"
ls *.mp*g | sort > $VAR # Collect the files in the current directory
cat $VAR | while read line; do # Loop read the filenames from the file
INPUT=$(echo ${line}) # Grab the nxt new filename
cat "$INPUT" >> "$OUTPUT" # Append works.
done
\rm $VAR # Remove the text file with the file names
# \rm *.mp*g # Maybe later!?
exit 0
An updated version of the above mentioned script is available below:
Now it also handles ‘catenation’ of other file types. <– Changed a few bits here and there, enough to merit an “update”.
#!/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 - cat.files.sh
#
## 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
echo "-------------------Catenate 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 " Catenate [avi] files."
echo " Catenate [mpg] files."
echo " Catenate [wmv] files."
echo
echo "-------------------------------------------------------------"
echo ""
MINPARAMS=1
if [ $# -gt "$MINPARAMS" ]; then
echo -e $YELLOW"This script only operates on"$NC" $BLUE"$MINPARAMS""$NC" "$YELLOW"file at a time!"$NC
echo -e $BLUE"(Do)es your filename(s): "$YELLOW""$*""$NC". "$BLUE"Contain space(s)?"$NC
echo -e $BLUE"If so, then you might want to rename {that,those} file(s)."$NC
echo -e $BLUE"By replacing those spaces with {.,-,_}s. ; - )"$NC
exit 0
fi
if [ "$1" = avi ];then Choice=avi;Choice=$Choice;fi
if [ "$1" = mpg ];then Choice=mpg;Choice=$Choice;fi
if [ "$1" = wmv ];then Choice=wmv;Choice=$Choice;fi
#read Choice
case "$Choice" in
"Avi" | "AVI" | "avi")
echo -n "Enter filename: "
read OUTPUT
OUTPUT=$OUTPUT
OUTPUT+=".avi"
## Here have one to rule them all!
# LS=$(ls *.{avi,mp{e,eg,g},wmv} 2>/dev/null)
LS=$(ls *.avi 2>/dev/null)
echo -e $BLUE"The elegance in this case referring only to this one short but sweet line..."$NC
## Why does the echo work as expected\? *Continues on line 54*
echo -e $CYAN" mencoder -forceidx -oac copy -ovc copy "$LS" -o "$OUTPUT""$NC
mencoder -forceidx -oac copy -ovc copy $(ls *.avi | sort -n) -o "$OUTPUT"
## Let's move the new file out of the way.
mv "$OUTPUT" ../"$OUTPUT"
## Then we remove the files we've worked on.
\rm *.avi
## Make it seem nothing happened. ; - )
mv ../"$OUTPUT" .
ls -lh
cd ..
exit 0
;;
"Mpg" | "MPG" | "mpg")
echo -n "Enter filename: "
read OUTPUT
OUTPUT=$OUTPUT
OUTPUT+=".mpg" # Append new extension
VAR="mpg-files.txt"
ls *.mp{e,eg,g} 2>/dev/null | sort > $VAR # Collect the files in the current directory
cat $VAR | while read line; do # Loop read the filenames from the file
INPUT=$(echo ${line}) # Grab the nxt new filename
cat "$INPUT" >> "$OUTPUT"
done
\rm $VAR # Remove the text file with the file names
## Let's move the new file out of the way.
mv "$OUTPUT" ../"$OUTPUT"
## Then we remove the files we've worked on.
\rm *.mp{e,eg,g} 2>/dev/null
## Make it seem nothing happened. ; - )
mv ../"$OUTPUT" .
# sleep 2
# ## Lets run repair right after shall we.
# ls *.mp{e,eg,g,4} 2>/dev/null | sort > $VAR # Collect the files in the current directory
# cat $VAR | while read line; do # Loop read the filenames from the file
# INPUT=$(echo ${line}) # Grab the nxt new filename
# OUTPUT=${INPUT%.mp*} # Remove shortest match of characters between the '. ' and the '*' at end of string
# OUTPUT+=".avi" # Append new extension
# avidemux --nogui --rebuild-index --autoindex --force-alt-h264 --load "$INPUT" --save "$OUTPUT" --output-format AVI --quit
# done
# if [ -f "$VAR" ] ; then \rm $VAR;fi # Remove the text file with the file names
# \rm *.mp{e,eg,g,4} 2>/dev/null
# \rm *.idx 2>/dev/null # We don't need those indexes anymore.
ls -lh
cd ..
exit 0
;;
"Wmv" | "WMV" | "wmv")
echo -n "Enter filename: "
read OUTPUT
OUTPUT=$OUTPUT
OUTPUT+=".wmv"
LS=$(ls *.wmv 2>/dev/null)
echo -e $BLUE"The elegance in this case referring only to this one short but sweet line..."$NC
## Why does the echo work as expected\? *Continues on line 54*
echo -e $CYAN" mencoder -forceidx -oac copy -ovc copy "$LS" -o "$OUTPUT""$NC
mencoder -forceidx -oac copy -ovc copy $(ls *.wmv | sort -n) -o "$OUTPUT"
## Let's move the new file out of the way.
mv "$OUTPUT" ../"$OUTPUT"
## Then we remove the files we've worked on.
\rm *.wmv
## Make it seem nothing happened. ; - )
mv ../"$OUTPUT" .
ls -lh
cd ..
exit 0
;;
*)
# 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
The audio converter Script goes here:
#!/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 - oga2ogg.sh
#
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 $RED"Error: In order to use this script, one must NOT be $USER"
echo -e $YELLOW"Exiting..."$NC
exit 0
else
echo ""
echo " $USER may proceed."
echo " May peace be with you."
fi
clear
echo "-------------------Audio Conversions List--------------------"
echo
echo -e $YELLOW" Please choose one of the following options: "$NC
echo " Or "
echo -e $YELLOW" Hit Ctrl+c (^c) to stop now."$NC
echo -e $BLUE" \"UPPER\", \"lower\" and \"Capitalized\" spelling "$NC
echo " are valid forms of input."
echo
echo " Convert lossless (*.oga/*.flac) audio files in the "
echo " [current] working directory?"
echo " OR."
echo " Convert them in a [recursive] manner."
echo " Starting from within this directory?"
echo
echo "-------------------------------------------------------------"
echo
echo -e $CYAN" [[c]current] or [[r]recursive]"$NC
echo -n "Please make your choice: "
read Choice
## Based on an adjusted k3b setting:
# flac -V -o %f --force-raw-format --best --ogg --endian=little --channels=2 --sample-rate=44100 --sign=signed --bps=16 -T ARTIST=%a -T TITLE=%t -T TRACKNUMBER=%n -T DATE=%y -T ALBUM=%m -
## Though this will compress the audio in a much better fashion and changes the extension from *.flac into *.oga, k3b mysteriously hangs after the last track has been encoded???
## The default gives you:
# flac -V -o %f --force-raw-format --endian=little --channels=2 --sample-rate=44100 --sign=signed --bps=16 -T ARTIST=%a -T TITLE=%t -T TRACKNUMBER=%n -T DATE=%y -T ALBUM=%m -
## And no hangover hickups, i.e. the k3b app doesn't hang on you after it finishes.
case "$Choice" in
"C" | "c" | "Current" | "CURRENT" | "current")
## Quality at 9\! Yeah I know I am an audiophile.
## oggenc's default quality is 3, which is perfectly fine in most cases.
## For 'cd quality' one could consider raising the bar to either 5 or 6\!\?
## Please note that flac IS cd quality as it is a lossless format\!
echo -e $BLUE" Are the files in flac or oga format?"$NC
echo -e $BLUE" I.e. they have an extension either ending in"$NC
echo -e $CYAN" [flac] or [oga]"$NC
echo
echo -n "Enter the extension name: "
read answer
case "$answer" in
"F" | "f" | "FLAC" | "Flac" | "flac")
oggenc -q 9 $(ls *.flac | sort -n) || exit 0
# \rm *.flac
exit 0
;;
"O" | "o" | "OGA" | "Oga" | "oga")
oggenc -q 9 $(ls *.oga | sort -n) || exit 0
# \rm *.oga
exit 0
;;
*)
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 0
;;
esac
;;
"R" | "r" | "Recursive" | "RECURSIVE" | "recursive")
echo -e $BLUE" Are the files in flac or oga format?"$NC
echo -e $BLUE" I.e. they have an extension either ending in"$NC
echo -e $CYAN" [flac] or [oga]"$NC
echo
echo -n "Enter the extension name: "
read answer
case "$answer" in
"F" | "f" | "FLAC" | "Flac" | "flac")
find -iname '*.flac' -exec oggenc -q 9 "{}" \; || exit 0
# find -iname '*.flac' -exec \rm "{}" \;
exit 0
;;
"O" | "o" | "OGA" | "Oga" | "oga")
find -iname '*.oga' -exec oggenc -q 9 "{}" \; || exit 0
# find -iname '*.oga' -exec \rm "{}" \;
exit 0
;;
*)
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 0
;;
esac
;;
*)
# Default option.
# Empty input (hitting RETURN) fits here, too.
echo
echo -e $YELLOW" Please choose a valid option!"$NC
echo -e $BLUE" \"UPPER\", \"lower\" and \"Capitalized\" spelling are supported"$NC
echo -e $CYAN" Usage: [[c]current] or [[r]recursive]"$NC
echo
;;
esac
exit 0
Q: So why use flac instead of ripping your cd directly into ogg/mp3/aac et al?
A: Flac is awesome for use as an archiver plus the sound is a 1 on 1 experience for you to listen to (while converting for example.) Anyway I backup all my cds in flac/oga format and at will or convenience I will ‘copy’ them to ogg/vorbis (preferably), mp3 or aac for use with any device which will play any of the specified formats. My preference obviously goes to players who support ogg/vorbis out of the box but a cheap mp3 player will do just fine as well. Imho mp3 suits itself best for use with music that emphasizes low tones, like house/techno/drum&bass et al but that could just be the way I experience it, I am far from having an ‘absolute hearing’ though.
See the galleries for more:
This gallery shows the differences in file size before and after the conversion.
Though I use different specs in the script I included in this post! It is however perfectly fine for you to use k3b’s defaults while ripping (as it says in the apps tooltip that the defaults are fine for everyday use.) Because k3b mysteriously hangs when it is finished ripping, while using the other options, and therefore needs to be killed the hard way by me: e.g. kill -s 9 <procid of k3b> (has no side effects though
but a nuisance to do, yes!? My next step would be to figure out how to for example obtain cd text (album-artist-title tag) info without the use of a gui, i.e. direct encoding of my cd into flac from the cli.
From the ‘man flac‘:
–ogg When encoding, generate Ogg FLAC output instead of native FLAC. Ogg FLAC streams are FLAC streams wrapped in an Ogg transport layer. The resulting
file should have an ‘.oga’ extension and will still be decodable by flac.When decoding, force the input to be treated as Ogg FLAC. This is useful when piping input from stdin or when the filename does not end in ‘.oga’
or ‘.ogg’.
-8, –compression-level-8
Synonymous with -l 12 -b 4096 -m -e -r 6–best Highest compression. Currently synonymous with -8.
These are the Artist-Album (foldername) and Artist-Title (subfolder) options I use in k3b:
Ugly filenames with spaces be gone…
PS: Oh, before I forget! Please note the time it takes to encode to ogg (approx ~ 15 sec) *Very Fast* Also I’ve tried several gui’s, to achieve the goal I achieved with this script, e.g. OggConvert, soundKonverter and vlc (does encode to mp3 though!) all of which had issues with the used oga extension!?