Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Create Side by Side or Top-Bottom 3D Video With ffmpeg and Imagemagick or Mencoder by Converting Alternate-Frame Sequencing 3D Video

Diposkan oleh Unknown on Tuesday, June 14, 2011

These are some commands for top-bottom or side-by-side 3D video transcoding with mencoder or ffmpeg and imagemagick.

Read more »
More aboutCreate Side by Side or Top-Bottom 3D Video With ffmpeg and Imagemagick or Mencoder by Converting Alternate-Frame Sequencing 3D Video

Logging and Graphing Power Consumption of Embedded Linux Systems -- Busybox and GnuPlot analyzing the Kindle 3

Diposkan oleh Unknown on Sunday, May 15, 2011

Actually this should've been really easy. A small script loop on the kindle to log the battery consumption and then plug that data into gnuplot. But it turned out gnuplot afaik doesn't support to output the difference between values. Thanks to apo_ from #gnuplot I've got it running with the help of awk now. The great thing is that this script runs in busybox and can hence easily be adapted for pretty much any kind of portable devices including Android phones, Kindles, Tablets, Notebooks, Netbooks, etc. And that's how it looks.
Kindle 3 Battery Consumption
Measurement points are marked with an x.

Read more »
More aboutLogging and Graphing Power Consumption of Embedded Linux Systems -- Busybox and GnuPlot analyzing the Kindle 3

Checking if at least a Kernel Version is Runnig in Bash

Diposkan oleh Unknown

kernelatleast() { # provide number like 2639
kver=$(uname -r|cut -d\- -f1|tr -d '.'| tr -d '[A-Z][a-z]')
kver=${kver:0:4}
if [ $1 -ge $kver ] ; then
return 0;
else
return 1;
fi
}
More aboutChecking if at least a Kernel Version is Runnig in Bash

Minimal Powertop as Bash Script esp. for Embedded Environments

Diposkan oleh Unknown on Thursday, May 5, 2011

I wrote this for my kindle and android devices. It's a nice, easy script though and should be great especially for embedded environments, where you have a shell but not all of the powertop dependencies. It works wonderfully on my notebook and netbook, but you may have to slightly adjust the path names to work on your system.

It turns out that this wasn't needed for either, as the kindle comes with powertop preinstalled. But it can't work on either of my devices, as timer_stats are disabled in their kernels.
I do wonder: Why do they disable the timer_stats? Is the overhead of timer_stats too high? Let me know how you use it!
Read more »
More aboutMinimal Powertop as Bash Script esp. for Embedded Environments

Convert 1080i AVCHD directly to 720p avi with ffmpeg 0.5

Diposkan oleh Unknown on Sunday, August 30, 2009

With the realease off ffmpeg 0.5 there is much better AVCHD support in my experience, so you can use it for perfect conversions. You can download ffmpeg from ffmpeg.org and then use this script:

#!/bin/sh
# ffmpeg-avchd script by linux-tipps.blogspot.com
# to encode a directory use this command:
# for i in *.m2ts; do ffmpeg-avchd $i; done
IN="$1"; shift
OUT=$(echo $IN | sed 's/.m2ts//')-720p.avi
echo Encoding $IN to $OUT.
ff="ffmpeg -deinterlace -i "$IN" -acodec copy -vcodec libx264 -vpre normal -crf 25 -sws_flags lanczos -s hd720 -r 25"
echo $ff $OUT
nice $ff "$OUT"

The only thing I'm not really happy with yet is the deinterlacing and deshaking. I would like to use a sharper deinterlacer, but I guess I'd need mencoder for that. The Lanczos software scaler does make steady images pretty sharp already, though.
More aboutConvert 1080i AVCHD directly to 720p avi with ffmpeg 0.5

"Never use the second pass encoding again" - Using 'Constant Ratefactor' Instead of Average Bitrate in x264

Diposkan oleh Unknown on Sunday, March 22, 2009

Okay, I may not be able to completely fulfill that promise, but you will most likely be saved from the second pass and thus a lot of encoding time quite often with this tip. If you don't need the resulting file to e.g. fit on a CD, Constant Ratefactor aka Constant Quality is probably perfect for you. Let me supply you with a quick overview and my quick mencoder script that does the job.

Did you know you can use a roughly vorbis-like quality selection, constant quality crf even in x264? This will save you a lot of encoding time with more or less the same quality. Or maybe not? Well it will look different, but it should be fine. For x264 a range of 18-26 is recommended. The higher the number the lower the bitrate and thus the file size will be.

Nice! Finally I don't need to adjust and calculate bitrates myself anymore! The algorithms really seem to work, because when I now change the codec settings to more efficient ones (e.g. increase the frameref, subq or enable mixed_refs) the quality (SSIM) remained pretty similar, while the bitrate sank.

Some experience with the parameters: The mixed_refs parameter did regularly increase the SSIM for me, but also took a lot more time to encode. Frameref=2 increases the efficiency with little performance impact in my experience. I wonder why it's not the default. Bframes decrease the quality slightly but shave a lot off the bitrate and even increase performance a bit for me.

Let me show you my "quick" example script for mencoder.
#!/bin/bash

CRF=23.5 # 21-26 recommended, the higher the smaller the resulting file, see http://mewiki.project357.com/wiki/X264_Settings#crf

INPUT="$1"; shift
X264OPTS="$1"; shift
OUT=`basename "$INPUT"`"-x264.avi"
echo Encoding $INPUT to $OUT

mencoder="time nice /usr/bin/mencoder -quiet -cache 16384"
enc="$mencoder -ovc x264 -oac copy -x264encopts crf=$CRF:trellis=1:frameref=2:bframes=2:8x8dct:psnr:ssim:$X264OPTS"
# I suggest nr= of no more than 2 or 3 with current x264 from svn.
# something along the lines of -vf
# eq=contrast=20:brightness=2,hue=saturation=1.25 for bleak videos
# denoise3d for noisy and unsharp=l:3x3:1.045 for blurry videos.
# I recommend to try out the result with mplayer first.
# A combination of all may work well, too.

echo $enc -o "$OUT" "$INPUT" $*

[ -f "$OUT" ] && echo File exists && exit 1;

$enc -o "$OUT" "$INPUT" $*

# You can call the script like this:
# script.sh input [x264encopts] [mencoder parameters]
# $ sh menc.sh somefile.mpg "interlaced" "-vf crop=..." or
# $ sh menc.sh somefile.mpg "" "-vf crop=..." or simply
# $ sh menc.sh somefile.mpg
# to get the right crop settings try $ mplayer -vf cropdetect


Feel free to get out the flame thrower - or just make some productive comments.
More about"Never use the second pass encoding again" - Using 'Constant Ratefactor' Instead of Average Bitrate in x264

How To: Comfortably Make your own WINE Bottles

Diposkan oleh Unknown on Saturday, March 21, 2009

If you're installing a few programs in WINE, you may notice that they tend to influence each other negatively. The fix is to install them in completely different operating system environments, also known as WINE bottles. This way it's easy to completely remove applications by just deleting their "bottle". Let me show you how to make this effortless with standard WINE and a simple shell script.

The script is the key part. You tell it a directory where you want your bottles installed and then it will create a new folder each time you install a program. Of course you may also install several programs into one bottle. Let's call the script wine-bottle, which I suggest to put into your $PATH:

!/bin/bash
# wine-bottle v. 0.2
# (c) 2009 Linux-Tipps.blogspot.com, (c) 2009 Joost @ http://home.student.utwente.nl/j.vanderhof
# newest version at http://linux-tipps.blogspot.com/2009/03/how-to-make-your-own-wine-bottles.html
# published under the GPL v. 3.0 http://gplv3.fsf.org/
INSTALLDIR="$HOME/.wine/bottles"; #Set this to where you want to put your Wine bottles
[ $# -lt 1 ] && #if you gave no parameters
echo "Please give me parameters! Usage:" &&
echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
echo "Configure a bottle : $0 --conf \"BottleName\"" &&
echo "List bottles : $0 --list" &&
exit 1;
[ $# -lt 2 -a $1 != "--list" ] && #if you didn't give the right parameters
echo "Please give me at least two parameters or a --list parameter! Usage:" &&
echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
echo "Configure a bottle : $0 --conf \"BottleName\"" &&
echo "List bottles : $0 --list" &&
exit 1;
[ $1 == "--list" ] && #if you want to list the bottles
echo "Wine bottles in $INSTALLDIR:" &&
ls -1 $INSTALLDIR &&
exit 1;
[ -d "$INSTALLDIR" ] || ( #if installdir is not existing
echo "Root of Wine bottles not existing: $INSTALLDIR" &&
mkdir "$INSTALLDIR"
) || ( #if installdir creation failed
echo "Could not create installation Directory: \"$INSTALLDIR\"." &&
exit 1);
which wine || ( #if wine is not found
echo "Wine not found, please install it first" &&
exit 1);
[ $1 == "--conf" ] && #if you wish to configure a bottle
WINEPREFIX="$INSTALLDIR/$2/" winecfg &&
exit 1;
#finally, the only remaining possibility is you want to run an application
PREF="$1";
shift; #drop first parameter to leave the command with its parameters
WINEPREFIX="$INSTALLDIR/$PREF/" wine "${@}";

You can now use this script almost like wine. The only difference is that you first need to tell it the bottle's name. E.g. wine-bottle lingopad setup.exe installs the program inside setup.exe into the bottle lingopad. I suggest using the "create Desktop short cut" option of installers, as it lets you easily start them later, without the need to use this script.

If you want to create a backup of your bottle, simpy put the bottle directory inside $INSTALLDIR together with the related .desktop file into an archive. If you want to manually start a program, you can of course still use wine-bottle from the shell: e.g. wine-bottle lingopad "$HOME/Wine/lingopad/drive_c/Program Files/Lingopad/Lingopad.exe".

You may also want to install a current wine via the wine ubuntu repository.

Let me know if you liked this howto!

Update: Updated to Joost's version, thanks!

Update2: It seems my script has inspired "Joost". He's created a version including a simple GUI. Check out his website.
More aboutHow To: Comfortably Make your own WINE Bottles

Automatically switch to connected External Display on Boot with XRandR

Diposkan oleh Unknown on Wednesday, March 11, 2009

I bought a notebook to be flexible, but when at home I use it with external monitor, keyboard and mouse to be comfortable. Now the problem was that I couldn't tell Ubuntu I want to only use the external monitor - if it's available.

Well, I've written a one-liner that fixes that problem. If the external display is attached, it will automatically switch over to it and display the internal display. Otherwise it boots normally (leaving the internal display enabled).

I put the script into the Xsession.d directory so it gets started for every user on boot: /etc/X11/Xsession.d/98vgaonly and made it executable.

The actual script line is this:
xrandr -q | grep 'VGA connected' && xrandr --output LVDS --off --output VGA --auto
It checks if the line 'VGA connected' was found in xrandr's query and then asks your X server to turn off the internal output and use the external one with automatic resolution detection.

So to automatically switch to a connected VGA during boot just execute:
echo 'xrandr -q | grep \'VGA connected\' && xrandr --output LVDS --off --output VGA --auto' | sudo tee /etc/X11/Xsession.d/98vgaonly && sudo chmod a+x /etc/X11/Xsession.d/98vgaonly


You may have to change the name of the outputs for your setup. xrandr -q will let you know what's available. It would probably be possible to somehow call this script automatically when plugging in a monitor, but I've not figured out how. xrandr only works when called from inside the running X session in my experience.


If you want to know more about XRandR, check this recent article.

Any comments are welcome!
More aboutAutomatically switch to connected External Display on Boot with XRandR

Easily Receiving Big Files via Droopy Webserver

Diposkan oleh Unknown on Tuesday, November 25, 2008

There's a nice little python script named droopy available which let's you receive big files quite comfortably over a simple web browser upload.
More aboutEasily Receiving Big Files via Droopy Webserver

Prepare JPG Files for Fax

Diposkan oleh Unknown on Sunday, November 9, 2008

This script prepares your scanned Jpgs for using them e.g. with the sipgate fax. Or you can simply join them together in a small (black&white) pdf. Of course you can change it.

#!/bin/bash
# (c) 2008 linux-tipps.blogspot.com
# published under GPL v. 3.0 or later.

which convert || echo Please install ImageMagick && exit 0;
which sam2p || echo Please install sam2p && exit 0;
which pdftk || echo Please install pdftk && exit 0;

mkdir tmp
cd tmp
ln ../*.jpg .
for i in *.jpg; do nice convert $i -unsharp 3x3 -monochrome $i.png; done
for i in *.png; do sam2p -pdf:b2 $i -pdf: $i.pdf; done
pdftk *.pdf cat output output.pdf
mv output ..
cd ..

rm -rI tmp
More aboutPrepare JPG Files for Fax

A Tiny Backup Script with Rsync

Diposkan oleh Unknown on Wednesday, November 5, 2008

This script lets you easily mirror a local directory to foreign computers that have rsync installed - securely via ssh. It assumes you have already set up a public key authentication with those servers. (Have a look at ssh-keygen and ssh-copy-id)
#!/bin/sh
# (c) 2008 linux-tipps.blogspot.com
#

FROM=/home/user
# the base path
DIRS="Desktop Documents"
# you can also use absolute paths

RSYNC="rsync -av --progress -e ssh"
# add -z for compression

ssh-add -l || ssh-add
# this adds ssh private keys if not added already
# for cron scripts use keychain instead:
# source ~/.keychain/*-sh
# see here for more

cd $FROM

$RSYNC -z $DIRS djtm@server1:/some/path/Backup/ &

$RSYNC $DIRS djtm@server2:/some/path/Backup/ &

wait && echo Sync Done. || echo Sync Failed or Aborted.
More aboutA Tiny Backup Script with Rsync

32 Bit Software in 64-Bit Debian-Based Distribution (e.g. Ubuntu)

Diposkan oleh Unknown on Sunday, November 2, 2008

There's a wonderful script named getlibs, that makes the annoying process of installation 32-bit libraries really comfortable.
More about32 Bit Software in 64-Bit Debian-Based Distribution (e.g. Ubuntu)

Backup with Rsync

Diposkan oleh Unknown on Saturday, November 1, 2008

There's a nice article about backups with rsync at Linux.com.
I shall leave the explanations to it and just post my script as example here
DIRS="Documents Desktop"

cd ~
for i in $DIRS;
do
echo Syncing $i
rsync -av --progress -e ssh "$i" user@server:/path/to/dir
done
More aboutBackup with Rsync

KDE Webkit

Diposkan oleh Unknown on Thursday, October 2, 2008

I just found out there is a webkit KDE port, called webkitkde, with Ubuntu (372kb) packages:

Webkit is what Apple uses for Safari and Google used for Chrome.

Update: This does not work cleanly if you use the kde 4.1.1 packages for hardy from the motu developers. Or to make it short: webkitkde works only in intrepid, because of wrong paths. If I have a workaround at the end.

Update2: Google Mail works with a bit of tweaking now. (I had to set Konqueror to identify as Safari 2.0 and reload the page mail.google.com.)

Update3: It's really beta software, you're not likely to have a lot of fun with it... :(. Gmail does not really work after all.

Update4: Even compiled from svn-trunk it's not really fun. There's some problem with the page loading, the fonts are too small I think. And just using khtml is much faster and more fun.

Just put this into your (Ubuntu hardy) shell:

sudo su -c "echo 'deb http://archive.ubuntu.com/ubuntu intrepid main' > /etc/apt/sources.list.d/intrepid.list"
apt-get update
apt-get install webkitkde
sudo su -c "echo > /etc/apt/sources.list.d/intrepid.list"
apt-get update

# workarounf for hardy
cd /usr/lib/kde4/share/kde4/services/
sudo ln -s /usr/share/kde4/services/webkitpart.desktop .
cd /usr/lib/kde4/lib/kde4/
sudo ln -s ../../webkitkdepart.so
# now the fine-tuning
cd /usr/lib/kde4/share/kde4/apps/ && sudo ln -s /usr/share/kde4/apps/webkitpart
cd /usr/lib/kde4/share/icons/hicolor/ && for i in 16x16 32x32 48x48 64x64 128x128; do cd $i/apps; sudo ln -s /usr/share/icons/hicolor/"$i"/apps/webkit.png; cd ../..; done;

kbuildsycoca4


And to uninstall:

sudo rm /usr/lib/kde4/share/kde4/services/webkitpart.desktop /usr/lib/kde4/lib/kde4/webkitkdepart.so /usr/lib/kde4/share/kde4/apps/webkitpart
cd /usr/lib/kde4/share/icons/hicolor/ && for i in 16x16 32x32 48x48 64x64 128x128; do cd $i/apps; sudo rm webkit.png; cd ../..; done;
sudo apt-get purge webkitkde


The README tells us:
You can switch between the different rendering engines:
View -> View Mode -> {KHTML, WebKit} (Website needs to be opened)
If WebKit does not show up in Konqueror, run 'kbuildsycoca4'.

If you want to set the WebKit part as default, run:
'keditfiletype text/html'
and move "WebKit (webkitpart)" in the "Embedding" tab to the top.

For more information about this project please see also:
http://techbase.kde.org/Projects/WebKit
More aboutKDE Webkit

Quick Transcoding with Mencoder and Xvid

Diposkan oleh Unknown on Sunday, September 28, 2008

This little script helps you to quickly transcode any content mplayer accepts to an xvid avi file. It copies the audio track and encodes the video track to xvid in the original resolution in your current directory.


#!/bin/bash
# mencode.sh (c) 2008 linux-tipps.blogspot.com

# settings

BR=1400 # bitrate
lang=en # your language code for the DVD audio track, e.g. en/de/es
OUT=`basename "$1"`"-xvid-fast.avi" # output file in current directory
XVID="lumi_mask:interlacing:nochroma_me:me_quality=4:vhq=1:autoaspect:chroma_opt:bitrate=$BR" # xvid settings

# settings end

[ -f "$OUT" ] && echo File exists && exit 1;

echo Encoding $i
screen -O mencoder -alang $lang -cache 32768 -ovc xvid -oac copy \
-xvidencopts $XVID "$1" -o "$OUT";

e.g. bash mencode.sh dvd://

You may want to compile xvid and mencoder for your machine to speed it up even more, but I've already set the xvid settings to a reasonably fast mode. I get around 25-30 fps when doing a DVD to Xvid backup on my notebook.

You could add -vf scale=640:-1 but it doesn't really increase speed, but makes it look worse. I use screen, so I can detach(Ctrl-a, Ctrl-d) from the encoding when I have to e.g. exit the current X session.

Detaching also helps to decrease unnecessary screen updates which eat cpu in many terminals. And it's better than passing -quiet as command line argument, because you now have the choice between seeing what's going on and how long it'll take or not. Screen is great... You can re-attach with screen -r. If you have several cores, try adding threads=x to the xvid options.

Black borders are not removed. If you have an idea how to do that automatically, let me know. Interlacing is kept for a good reason: Deinterlacing slows down the process and usually also degrades the quality. Deinterlacing while playing is usually the better alternative.

By the way: The most important parts are the xvid setting me_quality=4 and vhq=1 - they speed it up a lot - and compiling xvid for your processor, because some distributions don't properly compile it, even for amd64.

You may not use this script for content you do not have the rights to transcode.
More aboutQuick Transcoding with Mencoder and Xvid

Power Save Script

Diposkan oleh Unknown on Wednesday, September 3, 2008

I wrote a little powersave script that quickly executes a few commands to improve battery life, esp. on notebooks. You can put it in /etc/acpi/battery.d/20-powersave.sh to start automatically when the computer runs on battery.


#!/bin/bash

SUDO=`which sudo`
SU=`which su`
EXEC="$SUDO $SU -c"

echo Activating power saving mode...

# Automatically suspend USB -- How to automatize?
# usbcore.autosuspend=1 to kernel cmdline didnt work
$EXEC "echo 1 > /sys/module/usbcore/parameters/autosuspend"

# Disable CD autodetection by hal
# sudo hal-disable-polling --device /dev/scd0

$EXEC "ethtool -s eth0 wol d"

# reduce disk writes
$EXEC "echo 1500 > /proc/sys/vm/dirty_writeback_centisecs"

# SATA powersaving mode
$EXEC "echo min_power > /sys/class/scsi_host/host0/link_power_management_policy"

# AC97 power saving
$EXEC "echo 1 > /sys/module/snd_ac97_codec/parameters/power_save"

# Intel-HDA power saving
$EXEC "echo 1 > /sys/module/snd_hda_intel/parameters/power_save"

# optimize scheduling for dual-core cpus
$EXEC "echo 1 > /sys/devices/system/cpu/sched_mc_power_savings"

# Remove fixed network adapter, intel watchdog
sudo rmmod iTCO_wdt iTCO_vendor_support tg3

# set minimum frequency
#$EXEC "echo 866664 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"

sudo killall guidance-power-manager.py

xrandr --output TV --off

for i in /sys/bus/usb/devices/%s/power/autosuspend; do $EXEC "echo 1 > $i"; done

$SUDO iwconfig wlan0 power on



Actually I think a part of the script might be from someone else...
More aboutPower Save Script

Fast PAL HD Video encoding in Sync with ffmpeg-svn from AVHCD to Mpeg4 under Linux

Diposkan oleh Unknown on Friday, August 22, 2008

I have actually found a very very nice solution to the high definition video(AVCHD) transcoding problem. I got the ffmpeg svn checkout from yesterday (21.08.2008) and it works great with this script, all in one. No need for extra tools. And it's quite speedy.


#/bin/sh

FFM=$HOME/src/ffmpeg/ffmpeg
BR=3000 # kbit
OUT="${1}.mkv"

[ -f "$OUT" ] && exit 1;

echo $1
# old ffmpeg versions (2008):
nice $FFM -r 50 -i "$1" -s 1280x540 -ilme mpeg4 -acodec copy -aspect 16:9 -b ${BR}k "$OUT"
# new ffmpeg versions (January 2009): -r 50 might still be necessary.
nice $FFM -i "$1" -s 1280x540 -flags ilme -flags ildct -vcodec mpeg4 -acodec copy -aspect 16:9 -b ${BR}k "$OUT"


The only problem is that the current ffmpeg checkout does not listen to the -r parameter. So you have to manually override the frames per second when playing the file, e.g. mplayer -fps 50. I use mplayer -fps 50 -fs -af volnorm -vf pp=fd.

You need might need to adjust the path to ffmpeg in the script obviously, e.g. to $HOME/ffmpeg/ffmpeg.

Of course if you have a camera that records 29.97 frames per second you have to change the numbers accordingly. (-r 59.94)

If you've got several cores you may want to experiment with the -threads option and make sure you have compiled with --enable-pthreads, see below.

The great thing is that the video is encoded quickly - I get 23 fps on my celeron m530 notebook - and the video is perfectly in sync, and you only need ffmpeg, nothing else.

You should install a fresh ffmpeg from SVN:

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --enable-nonfree --enable-gpl --enable-pthreads && make && sudo make install.


Be careful where you put every ffmpeg parameter, as ffmpeg interprets them differently depending on the order you give them. E.g. ffmpeg -r 50 -i ... differs from ffmpeg -i ... -r 50.

Enjoy fast and sync video transformation!

If it doesn't work for you, try out this script, which is the result of the long discussions below.
More aboutFast PAL HD Video encoding in Sync with ffmpeg-svn from AVHCD to Mpeg4 under Linux

Comfortable Direct HD Video Encoding from AVCHD to Mpeg4

Diposkan oleh Unknown on Sunday, August 17, 2008

This nice little script encodes avchd m2ts files from e.g. an HD camcorder directly to mpeg4 avis. It uses a temporary file in the /tmp dir for the audio stream, but the rest is done using fifo pipes. You need to install the csh shell interpreter to run it. And you need to setup the environment from this package: (by invoking ./install, then ./installasroot, you need to modify the download script and change the JM version).

The script works badly on multi-core systems, but you can invoke it several times at once. It's originally a modified version of the script from this package, but I changed it so you can run it several times concurrently (with the same file names in different folders). I also added a check to prevent it from encoding files where the output files already exist. I recommend to run it on an entire directory for i in *.m2ts; do echo encoding $i; hdencode $i; done


#!/bin/csh

set BR=5000
set lavcopts="-lavcopts vcodec=mpeg4:vbitrate="$BR":turbo:threads=1:autoaspect:ilme:ildct"
set lavf="-of lavf -lavfopts format=mp4"
set menco="-vf scale=1280:540:1 $lavf"
set fps="25" # "29.97"
set ending="mp4"
set delay="-delay +0.7"

nice
#The scripts and instructions in this package are free to use and
#redistribute AT YOUR OWN RISK!! Standard disclaimers apply.
#NO WARRANTY!

if ( $#argv == "0" ) then
echo usage: $0 filename.m2ts ...
exit
else
set files=($*)
endif

set path = ( . $path )

echo using:
which xporthdmv || exit
which ldecod || exit
which ffmpeg || exit

echo $0 Starting.
echo " "
foreach file ($files)
if ( ! -f $file ) then
echo file $file not found
exit
endif

rm -f ./bits0001.mpv ./bits0001.mpa

set filebase=`basename $file | sed s/\.m2ts// | sed s/\.MTS//`
set audiofile=/tmp/$filebase-$$".ac3"
set videofifo=/tmp/$filebase-$$".yuv"
set outputfile=$filebase"."$ending

if ( -f $outputfile ) then
echo file $outputfile already exists
exit
endif

if ( ! -f $audiofile ) then
echo xporthdmv -h $file 1 1 1
xporthdmv -h $file 1 1 1 && mv bits0001.mpa $audiofile
else
echo $audiofile already exists, not creating it.
endif

mkfifo $videofifo

if ( ! -f $videofifo ) then
echo ldecod -i bits0001.mpv -o $videofifo
ldecod -i bits0001.mpv -o $videofifo &
#ldecod -i bits0001.mpv -o $videofifo
else
echo $videofifo already exists, not creating it.
endif

if ( ! -f $outputfile ) then
echo mencoder $videofifo -demuxer rawvideo -rawvideo w=1440:h=1080 -aspect 16:9 -ofps $fps \
-ovc lavc -o $outputfile"-tmp" $lavcopts $menco

mencoder $videofifo -demuxer rawvideo -rawvideo w=1440:h=1080 -aspect 16:9 -ofps $fps \
-ovc lavc -o $outputfile"-tmp" $lavcopts $menco

echo mencoder $outputfile"-tmp" -aspect 16:9 -ofps $fps \
-audiofile $audiofile \
-oac copy -ovc copy \
-o $outputfile

mencoder $outputfile"-tmp" -aspect 16:9 -ofps $fps \
-audiofile $audiofile $delay \
-oac copy -ovc copy \
-o $outputfile
else
echo $outputfile exists, not creating it.
endif
end

#echo To remove temporary files: rm -f /tmp/*.ac3 /tmp/*.yuv
rm -f ./dataDec.txt ./log.dec bits0001.mpv $videofifo $audiofile $outputfile"-tmp"
echo $0 complete.
More aboutComfortable Direct HD Video Encoding from AVCHD to Mpeg4

Oggrecode Script

Diposkan oleh Unknown on Friday, August 15, 2008

This script recodes an entire directory to a new quality of vorbis. It could easily be modified to transcode to ogg as well.


#!/bin/bash
# (c) 2008 linux-tipps.blogspot.com
# published under the GNU GPL v 3.0

echo OggRecode v 0.01
echo

OUTDIR="$1-recode_q$2"
ME=`basename $0`

if [ $# != 2 ]; then
echo \#$ME \"directory\" quality
echo I need two parameters: a directory and a quality setting,
echo but you gave me $# parameter\(s\): \($ME $*\)
echo
exit 1;
fi

if [ ! -d "$1" ]; then
echo Parameter \"$1\" is not a directory!
# direct file handling here
exit 2;
fi

if [ -e "$OUTDIR" ]; then
echo A file or directory with the name \"$OUTDIR\" already exists.
exit 3;
fi

if [ ! -f "$1"/*.ogg ]; then
echo No vorbis files found in directory \"$1\":
echo Directory listing:
ls "$1";
echo ---
echo
exit 4
fi

mkdir "$OUTDIR"
cd "$1"

for i in *.ogg; do
TO="`basename $i`"
TO="$i"
cd ..
cd "$OUTDIR"
echo Recoding \"$i\" ...
echo oggdec -Q -o - ../"$1"/"$i" \| oggenc -q "$2" -o "$TO" -
oggdec -Q -o - ../"$1"/"$i" | oggenc -q "$2" -o "$TO" -
echo ... finished recoding \"$i\".;
echo
done

cd ..
echo Finished encoding


More aboutOggrecode Script

Helping Windows Users with UltraVNC Single Click and ssvnc from Linux

Diposkan oleh Unknown on Thursday, August 14, 2008

If you ever (try to) use UltraVNC Single Click to help Windows users from Linux, you will find out that it's not that easy. Though you can use the UltraVNC viewer in Wine, you may see disconnects after around 15 minutes. The easy solution lies in starting a regular TightVNC with these parameters:

xtightvncviewer -listen 0 -encodings "hextile copyrect"

Replace the 0 with the display number, e.g. 0 for port 5500 or 400 for 5900. (port = 5500 + x) You need to have the package xtightvncviewer installed for this to work in Ubuntu. The color parameter does not work properly in this configuration.

Or give ssvnc a try. It works even with SCIII (uvnc Single Click via SSL), supports different color depths and much more!

And if you've got a current wine version, you might as well use the original ultravnc viewer. It works fine by now.

I usually use ssvn and the following script to start the vnc listener and quit it when finished.
VNC=$HOME/src/ssvnc/bin/tightvncviewer
$VNC -listen 487 -use64 & # 64 colors
read -p "Press enter when finished"
killall tightvncviewer vncviewer
More aboutHelping Windows Users with UltraVNC Single Click and ssvnc from Linux