OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

Profile
Personal Photo
Options
Options
Personal Statement
vrejakti doesn't have a personal statement currently.
Personal Info
vrejakti
Age Unknown
Gender Not Set
Location Unknown
Birthday Unknown
Interests
No Information
Statistics
Joined: 8-December 05
Profile Views: 135*
Last Seen: 12th July 2008 - 09:16 PM
Local Time: Oct 25 2014, 12:24 PM
21 posts (0 per day)
Contact Information
AIM No Information
Yahoo No Information
ICQ No Information
MSN No Information
* Profile views updated each hour

vrejakti

Members


Topics
Posts
Comments
Friends
My Content
17 Jun 2007
Anyone remember the days of telnet BBS's? I had the idea a while back that installing a BBS on my Zaurus would restore my interest in my Z. Strangely, they are hard to come by now. I did however find a BBS called iBBS which is written entirely in Bash. This peaked my interest, and lead me to start a new project.

The project is a simple shell for the Zaurus. This is a frame work, not an actual application you should use. You must modify and expand the code to suit your needs. Anything is possible with this framework, given enough creativity.


CODE
#!/bin/bash
FP="/home/fenrir/forums"
viewing="0"
export path=""


function viewthread()
{
while true
do
echo
for i in `ls $FP/$viewing/[0-9] 2>/dev/null`
do
echo "----=[ `basename $i` ]=-------------------------"
head -n 2 $i
echo "------------------------------------"
echo
done

printf "[vBBS-thread] "
read n
if [ -z $n ]
then
return
fi

if [ -a $FP/$viewing/$n ]
then
less $FP/$viewing/$n
fi
done
return
}

function viewforums()
{
while true
do
echo "----=[ FORUMS ]=--------------------"
for i in `ls $FP 2>/dev/null`
do

echo $i. `cat $FP/$i/title`

done
echo "------------------------------------"

printf "[vBBS-forums] "

read n
if [ -z $n ]
then
return
fi

if [ -a "$FP/$n" ]
then
viewing="$n"
viewthread
fi
done
return
}

function reply()
{
nano $path
}






function menu()
{
printf "
[h] <help>   Show this help
[c] <cplay>  Launch music player
[q] <exit>   Quit this Application
[s] <sleep>  Put Zaurus to sleep
[e] <nano>   Launch nano editor
[o] <online> Go online
[w] <links>  Launch web prowser
[a] <swap>   Mount swap
[t] <forum>  View threads

"
}



while true
do
printf "[vBBS] "
read c
case "$c" in
[qQ]  ) exit;;
[hH] ) menu;;
[sS] ) echo "Goign to sleep. See you soon!"; apm -s;;
[cC] ) cplay;;
[nN] ) nano;;
[lL] ) links;;
[tTrR] ) viewforums;;
*  );;
esac
done


I find there to be something nice about having a menu driven shell on the Zaurus. If you like it to, feel free to expand that script to simplify the applications you use.
10 Jul 2006
It's been a while since I posted my first encoding video for the Zaurus script, so here's an updated Version 2 of it. Enjoy. happy.gif

CODE
#!/bin/sh
# Declare some variables
INFILE=$1
OUTFILE=$2
WIDTH=640
HEIGHT=480

# Check for input video.
if [ -z "$1" ]
then echo "#########################"
echo "# ERROR! NO INPUT FILE. #"
echo "#########################"
echo
echo "Usage"
echo --------------------
echo "$0 INPUT OUTPUT width_option height_option"
echo
echo "Example"
echo --------------------
echo "$0 Funny_Clip.avi Funny_Clip_Resized.avi 320 240"
exit
fi

# Check for output file name.
if [ -z "$2" ]
then echo "##########################"
echo "# ERROR! NO OUTPUT FILE. #"
echo "##########################"
echo
echo "Usage"
echo --------------------
echo "$0 INPUT OUTPUT width height"
echo
echo "Example"
echo --------------------
echo "$0 Funny_Clip.avi Funny_Clip_Resized.avi 320 240"
exit
fi

# Change to custom height and width
if [ -n "$3" ]
then WIDTH=$3
fi

if [ -n "$4" ]
then HEIGHT=$4
fi

# Print some information
echo Video Encoding for Sharp Zaurus Playback
echo By Vrejakti
echo http://www.lan358.com
echo
echo
echo "Default 640x480"
echo "Full screen [4:3]  use 640x480 [default]."
echo "Wide screen [16:9] use 640x360."
echo --------------------
echo "   Input: $1"
echo "  Output: $2"
echo "   Width: $WIDTH"
echo "  Height: $HEIGHT"
echo --------------------

# Check responce
echo "Is this correct? [Yes/No] "
read answer
# VERY USEFUL CODE: This accepts "Yes", "yes", "Y", and "y".
if [ $answer == "Yes" ] || [ $answer == "yes" ] || [ $answer == "Y" ] || [ $answer == "y" ]
then
# Start mencoder magic
mencoder "$INFILE" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=300:vpass=1 -lameopts cbr:br=64:mode=3 -vf scale=$WIDTH:$HEIGHT -oac mp3lame -o $OUTFILE
mencoder "$INFILE" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=300:vpass=2 -lameopts cbr:br=64:mode=3 -vf scale=$WIDTH:$HEIGHT -oac mp3lame -o $OUTFILE
echo "Converted file is $OUTFILE"

else echo "Encoding canceled!!!"
fi


Please post any suggestions for improvements. I'm still learning how to write bash scripts, so there's bound to be room for improvement. happy.gif Version 3 will allow for encoding multiple files.

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

Edit notes: *shudder* The above is version 2, that is more of a proof of concept. I'm posting version 4.0 below for a side by side comparison. happy.gif Many new features have been added in version 4.0 as well as a great number of simplifications.

i) Script is easier to run. Install it as vrecoder to /usr/local/bin then run `vrecoder -i AVI_File'
ii) All options have been added as switches. See `vrecoder -h' for the details.
iii) The `-a' switch attempts to resize your video keeping the correct aspect ratio.
iv) `-s' uses an experimental smartcoder that will encode every AVI file in the current directory.



CODE
#!/bin/bash

# Encoding Video for Zaurus Playback
# Script version 4.5
# Attributions:
# Vrejakti   LAN358 Inc, http://lan358.com: Head Developer
# XorA       Open Zaurus Project: Produced original mpencoder code
# Da_Blitz   OESF Forums:  additional mencoder code, and shell code
# Xamindar   OESF Forums:  feature suggestions

MAX_WIDTH="640"    # Default max width
WIDTH="640"        # Default width
HEIGHT="480"       # Default height
encoder="vrecoder" # Default encoder
BITRATE="600"      # Default quality / bit rate
CODEC="mpeg4"      # Default codec

help () {
cat << EOF
vrecoder: Video Encoding for Sharp Zaurus Playback

Usage: vrecoder [-h] [-a] [-s] [-i infile] [-o outfile]
 [-x size] [-y size] [-b bitrate]

-h,  Display this help menu
-a,  Auto calculate resized video resolution
-s,  Use smartcoder
-i,  Input File
-o,  Output File
-x,  Change width
-b,  Change bitrate. 300 default, 6000 would be smooth
-y,  Change height
--quick  No confirms, jump to encoding.

:: Encoders ::
vrecoder:   Default encoder. Works on a signle input file.
smartcoder: Experimental encoder. Atempts to encode every AVI file in the
           current directory.
:: Notes ::
[-a] depends on awk >= 3.1.5, file >= 4.3.0, grep >= 2.5.1.
    Use at your own risk.
[-s] depends on file >= 4.18, find >= 4.3.0.
    Use at your own risk.

EOF
exit
}

if [ -z "$1" -o "$1" = "-h" ]
then
help
fi

for ARG in $@; do
    case $ARG in
 -x) WIDTH="$2";    shift;;
 -y) HEIGHT="$2";      shift;;  
 -i) IN="$2";    shift;;
 -o) OUT="$2";    shift;;
 -a) autores="yes";      shift;;
 -b) BITRATE="$2";      shift;;
 -s) encoder="smartcoder";  shift;;
 --quick) rush="x";      shift;;
 *) shift;;
    esac
done

if [ "$encoder" == "vrecoder" ]
then
if [ -z "$IN" ]
then
printf "Whoops! No input found.
Did you forget to input a file with -i file.avi?\n"
exit
fi
fi

if [ -z "$OUT" ]
then
OUT="Zaurus-"$IN""
# /*
# * Why is this switch true when -i is a complex file name?
#  */
fi

if [[ "$encoder" == "smartcoder" ]]
then
rush="x"
fi

if [[ "$rush" == "x" ]]
then
answer="yes"
else

#####calculate res#############################
case "$autores" in
    "Yes" | "yes" | "Y" | "y" )
# /*
#  * Anyone have a suggestion
#  * how to better impliment this function?
#  */
    printf "Enter screen width (ie. 640): "
    read MAX_WIDTH
    height=`file $IN | awk -F, '{print $3}' | awk -F" " '{print $1}'`
    width=`file $IN | awk -F, '{print $3}' | awk -F" " '{print $3}'`
    first="$[$width*100/$height]"     # fake float
    second="$[$MAX_WIDTH*$first/100]" # restore int
    WIDTH="$MAX_WIDTH"
    HEIGHT="$second"
;;
esac
###############################################

echo
echo "Please confirm:"
echo "------------------------------"
echo "       Input: $IN"
echo "      Output: $OUT"
echo "       Width: $WIDTH"
echo "      Height: $HEIGHT"
echo "     Encoder: $encoder"
echo "     Bitrate: $BITRATE"
echo "------------------------------"

printf "Start encoding?
[Yes/No] "
read answer
fi

####functions##################################
function vrecoder ()
{
    mencoder "$IN" -ovc lavc -lavcopts vcodec=$CODEC:\
    vbitrate=$BITRATE:vpass=1 -vf scale=$WIDTH:$HEIGHT -oac copy -o "$OUT"
#--------------------
    mencoder "$IN" -ovc lavc -lavcopts vcodec=$CODEC:\
    vbitrate=$BITRATE:vpass=2 -vf scale=$WIDTH:$HEIGHT -oac copy -o "$OUT"
}

function smartcoder ()
{
    i=1
    while read "F"
    do
    T=$(file -zibkp "$F")
    if [[ $T == 'video/x-msvideo' ]]
    then
    OUT="Zaurus-"$F""
#    mencoder "$F" -ovc lavc -lavcopts vcodec=$CODEC:vbitrate=\
#    $BITRATE:vpass=1 -vf scale=$WIDTH:$HEIGHT -oac copy -o "Output_"$F""
#    mencoder "$F" -ovc lavc -lavcopts vcodec=$CODEC:vbitrate=\
#    $BITRATE:vpass=2 -vf scale=$WIDTH:$HEIGHT -oac copy -o "Output_"$F""
    mencoder "$F" -ovc lavc -lavcopts vcodec=$CODEC:\
    vbitrate=$BITRATE:vpass=1 -vf scale=$WIDTH:$HEIGHT -oac copy -o "$OUT"
    #--------------------
    mencoder "$F" -ovc lavc -lavcopts vcodec=$CODEC:\
    vbitrate=$BITRATE:vpass=2 -vf scale=$WIDTH:$HEIGHT -oac copy -o "$OUT"
# /*
# * Can someone please tell me the difference between the commented lines
# * and the uncommented lines?
#  */

    i=$[$i+1]
    fi
    done < <(find -maxdepth 1 -printf "%f\n")
}
####/functions#################################


####main#######################################
case "$answer" in
    "Yes" | "yes" | "Y" | "y" )
 $encoder
 printf "\nEncoding completed at `date`\n"
    exit;;

    "op" )
 printf "Minutes: [hh:mm:ss] "
 read minutes
 mencoder "$IN" -ovc lavc -lavcopts vcodec=$CODEC:vbitrate=\
 $BITRATE -vf scale=$WIDTH:$HEIGHT -oac copy -endpos \
 $minutes -o "$OUT"
    exit;;

esac
###############################################

printf "\nEncoding has been cancled.\n"



Todo:
Fix script so everything will work on complex file names as well as normal file names.
Have script work on each file on the command line, not just the one file included with the `-i' switch.
Replace experimental code with real portable code.
Rewrite the entire script in x86 ASM using mencoder shared libraries. (Yeah right. ;-) )
22 Mar 2006
Hey all, I'm still working out my ideal encode/playback setting for my SL-C3100, but what I've come up with is already awesome, and I figure this is a good topic to start for anyone wanting to turn their Zaurus into an iPod Video killer. ;-)

Under pdaXrom, I use this script for playback:

hardwareaccel.sh
CODE
mplayer -ac mad -ao oss -framedrop -really-quiet -fs -vo bvdd $1

Usage ./hardwareaccel.sh videofile

Credit to OpenZaurus for getting me started. The important thing here is the "-vo bvdd", if you're looking at a console "top" command you'll see 0% CPU usage for the X server, whereas with any other video out (-vo) option mplayer and X will be fighting for CPU. So, this enable hardware acceleration, meaning bigger video same quality. smile.gif

Next, encoding:

mem_448x336.sh
CODE
#!/bin/sh

OUTFILE=$1
echo "Outputting to $OUTFILE"
shift

mencoder "$@" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=300:vpass=1 -lameopts cbr:br=64:mode=3 -vf scale=448:336 -oac mp3lame -o $OUTFILE
mencoder "$@" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=300:vpass=2 -lameopts cbr:br=64:mode=3 -vf scale=448:336 -oac mp3lame -o $OUTFILE

NOTE: Each mencoder command is ALL ONE LINE.
Usage
./mem_448x336.sh outputfile inputfile

Credit again to OpenZaurus for getting me started. I find 448x336 res (4:3 ratio) is nice, and full frame rates with 30% CPU to spare. Anyone care to offer their own tweaks? I'll be spending lots of time improving the above scrips - will post updated versions later. happy.gif
Last Visitors


31 Jan 2008 - 16:29

Comments
Other users have left no comments for vrejakti.

Friends
There are no friends to display.
RSS Lo-Fi Version Time is now: 25th October 2014 - 09:24 AM