Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - vrejakti

Pages: [1] 2
1
General Discussion / Oldschool Cli
« on: June 17, 2007, 04:05:59 pm »
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: [Select]
#!/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]   Show this help
[c]  Launch music player
[q]   Quit this Application
[s]  Put Zaurus to sleep
[e]   Launch nano editor
[o] Go online
[w]  Launch web prowser
[a]   Mount swap
[t]  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.

2
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: November 01, 2006, 10:29:54 pm »
It would be nice if quoting was the solution---(rant cut short)

Da_Blitz, grog, your suggestions worked! Thanks! It really was as simple as quoting "$IN". Looks like zsh won't be needed after all.

I must have offset the quoting of my variables somewhere in previous scripts causing that type of quoting not to work, but it works as it should now.

3
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: November 01, 2006, 07:02:15 pm »
Quote
any particular reason for zsh? i try hard to keep my dependencies down to bash
[div align=\"right\"][{POST_SNAPBACK}][/a][/div]
Here's the issue I had when using /bin/bash or /bin/ksh

Code: [Select]
debian% ls
[S^M] Galaxy Ange-lune 04 RAW.avi
debian% ./script.sh
File not found: '[S^M]'
Failed to open [S^M].
zsh seems to be the only shell that can properly pass complex file names in variables to mencoder. Personally, I use whatever works. At some point, I may even try doing this same script in perl or C - just for heck of it.

Edit: After thinking about it, you raise a very good point. I assume a lot more people have access to bash than zsh, so I changed my newest release to use #!/bin/bash by default, leaving the end user the option to change it to use #!/bin/zsh if needed for complex file name issues.

I've tried a lot of solutions to file names. From using a long script of sed replacement commands, to saving files to a text file and greping each line, as well as quoting, double quoting, and single quoting. zsh works for now.

Keep up the good work on your script Da_Blitz. I'm looking forward to seeing your next release. I still think the scripts we're working on are very useful. Not many people have the time to read the mplayer man pages to learn how to write a profile for their needs, that's why scripts that simplify or automate the proccess are still useful, I think.




Here's my latest script
[a href=\"http://www.lan358.com/scripts/vrecoder-3.65.txt]View script online as text.[/url]
Download script.

Notes on features.
Using -e smartcoder tells the script to automagically seek out any video files in the current directory and encode them for Zaurus Playback.

Experimental auto-resolution calculation tries to guess a correct 4:3 resolution for you when scaling the video.

Selecting "op" when asked "Start encoding? [Yes/No/op]" will allow you to encode the first hh:mm:ss of a video. It's good for catching opening themes from anime.

4
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: November 01, 2006, 11:24:02 am »
You're right about this thread being all over the place.  To answer your question, I always assumed the encoding would be done on a desktop, mainly because computer resources greatly affect the time to encode a video. It is still possible to encode on the Zaurus, if you have the mencoder package installed.

I have seen a mencoder package for the Zaurus, though I'm sorry I don't have a link.

5
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: November 01, 2006, 12:09:36 am »
In a couple days I'll be releasing a new version of vrecoder that has two new features:

First off, it can handle any file name. So if you happen to have a lot of files named similar to [S^M] Galaxy Ange-lune 04 RAW.avi, the new script will have no issues at all with them.

Second, the script will be able to determine what files in the current directory are video files, and it will encode everyone of them. Obviously, this feature will be very useful if you want to convert your entire collection of videos over night.

Anyone who'd like a head start is welcome to hack the following code into a script of their own. Also, the shell zsh will be required to run the new script, so please grab it from
http://www.zsh.org/
or by using the package manager of your distro.

Code: [Select]
#!/bin/zsh
SMART_CODE=smart_code
smart_code () {
i=1
while read F
do
T=$(file -zibkp "$F")
minutes="00:01:00"
[[ $T == 'video/x-msvideo' ]] && mencoder $F -ovc lavc -lavcopts debug=0:vcodec=mpeg4:vbitrate=6000 -oac copy -endpos $minutes -o Zaurus-$i.avi
i=$[$i+1]
done < <(find -maxdepth 1 -printf "%f\n")
}
$SMART_CODE

The above code is a proof of concept for the two features. ;-)

6
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: October 30, 2006, 10:29:16 am »
Several tweaks later... I've got your script encoding a file after typing ./zencoder -i video.avi -o z-video.avi   The tweaks are barely proof of concept, but you may find something worth building on.  

http://lan358.com/scripts/zencoder.txt

7
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: October 30, 2006, 09:22:37 am »
Combining scripts is an interesting idea. For now, I'll take a good hard look at your code and see what ideas I can come up with.  Your script has a lot of features I like, such as the custimization options and the flags. At the moment, I'm looking for what code would be needed so a user simply types "./zencoder movie.avi" for the first time and the script takes care of the rest.

It should be possible to have the script make the dir $HOME/zencoder and use the same cat << EOF trick to drop the config text into $HOME/zencoder/zencoder.conf

All this remeinds me, I wanted to ask you what you would think of a ncurses interface for this whole script? Could be overkill, but it could also be useful in the sence of having a menu to check off which codec to use and such?

8
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: October 28, 2006, 04:44:33 pm »
I've tweaked my script once again. Code is cleaner. As for features, I added
1) Option to quickly jump to encoding. Type x when asked to, and it'll skip the next 3 questions.
2) A bit of an easter egg that lets you rip the OP of an anime episode in very high quality. At the last menu when it asks "Start encoding?" type "op" then enter  hh:mm:ss of the episode to rip to HQ. 00:02:00 would grab the first 2 minutes. I wrote this code when I wanted to show a friend the coolest OP's from the newest anime season.
3) Tried to make it clearer for errors and note the importance of simple file names.

Complex file names are a bit of an issue in bash. Make sure your infile is "simplefilename.avi" and not "[I AM] 4 c0m|>;e'x' fiL_e name~~~~!". Renaming it is eacy in a GUI, select the file, hit F2, and type in something sane. In the console, make sure you're using Bash or ZSH, then type a single quote, a couple unique first letter, then press tab to auto comple the name. Use mv to rename that file to something simple.

Posting all these scripts as text is getting pretty crazy. *laughs* Here's a direct link to a download.

Download:http://www.lan358.com/scripts/vrecoder.sh
View:http://www.lan358.com/scripts/vrecoder.txt

9
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: October 04, 2006, 06:13:38 pm »
Quote
The script above  gives me this error:

Code: [Select]
./zencoder.sh: line 77: syntax error near unexpected token `='
./zencoder.sh: line 77: `               if (echo $PROVIDES | grep $1) = 0; then'

Any ideas? I use bash.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=143105\"][{POST_SNAPBACK}][/a][/div]

Huh, at first glance, I'm thinking you may have saved the config file into the shell script. I haven't give this much thought, so I'm probably completly wrong here: Half the code may be a template for a config file that you save your perferences in. The other half is the shell script that does the encoding, reading defaults from the configuration file.

10
OpenBSD / 4.0 -beta Packages (and Asst C3200 Info) Available
« on: September 22, 2006, 01:18:38 am »
Quote
FVWM2 uses only 1.5MB RAM?!?!? Going to have to check this out. Fluxbox uses ~3.0MB RAM!

How about posting a screenshot of your fvwm desktop on your website to show off your fvwm2rc config?

I can top that: dwm uses less than 1.1MB of memory. It is an elitist window manager, hence it's lack of popularity. ^^

You can read about it here.

Some info from the author:

* dwm is only a single binary, it's source code is intended to never exceed 2000 SLOC.

* dwm is customized through editing its source code, that makes it extremely fast and secure - it does not process any input data which hasn't been known at compile time, except window title names and status text read from standard input. You don't have to learn Lua/sh/ruby or some weird configuration file format (like X resource files), beside C to customize it for your needs, you only have to learn C (at least editing header files).

* Because dwm is customized through editing its source code, it's pointless to make binary packages of it. This keeps its userbase small and elitist. No novices asking stupid questions.

I've been playing around with it since version 0.1 - I have compiled it on OpenBSD 3.9, pdaXrom, Gentoo Linux, Fedora Core... long as you have a good amount of X11 headers installed, it should compile OK.

Keep in mind, the author wrote dwm for himself. wmii is another project of his that has plenty more features with an active community.

11
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: September 15, 2006, 08:24:18 pm »
Phew, looks like I don't have to implement ogg or mkv support into the script after all.

From the legendary Gentoo Wiki: http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
Quote
"Ogg or Ogg bitstream format is also an open-source video container, part of the Xiph project. OGM is an extension of Ogg bitstream format to support some proprietary video codecs. Like matroska, mplayer can play, but not create Ogg and OGM videos."

"Matroska is an open-source video container, similar to AVI, except that it has many more advanced options and settings that can be included in the metadata. mplayer and mencoder can play and read matroska files, but not create them. Matroska audio and video files use filename extensions .mka and .mkv, respectively."

So, as of yet, mencoder and mplayer can read and play mkv or ogg file formates, but they can not create them.

Da_Blitz thank you for pointing out Aliens Bash Tutorial - that's the perfect resource to bring me up to speed on bash scripting.  I've played around with the ABS guide for about a year now, and it's great, but Aliens guide looks to be the perfect compliment to it.

As for your shell prompt, that has got to be the most customized shell prompt I have ever seen.

12
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: September 13, 2006, 06:59:09 pm »
nice code Da_Blitz, very nice! Admittedly, I am still learning how to write bash code, and the difference in professionalism between our scripts is quite crushing to me, but I don't mind. ^^ I'll keep improving my script as I learn more.

Keep up the good work.

13
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: September 11, 2006, 08:26:24 pm »
If you guys liked my first scripts, you're going to LOVE this one! I simplified the heck out of it, and the auto resolution calculation works so nicely.

All you have to do is type
./script video.avi
Yes
Yes

And it does the rest. :-D

Code: [Select]
#!/bin/sh
# Encoding Video for Zaurus Playback
# Script version 3
# Attributions:
#
# Vrejakti of LAN358 Inc (http://lan358.com): Main contributor of Bash code
# XorA of the Open Zaurus Project: Produced original mencoder code
# Da_Blitz from OESF Forums: Provided additional mencoder code
# Xamindar from OESF Forums: Provided feature suggestions


# Declare some variables
INFILE=$1
OUTFILE=Zaurus-$1
WIDTH=640
HEIGHT=480
AUDIO=mp2
VIDEO=lavc
VIDEO_CODEC=mpeg4
#--------------------
ERROR1="#########################
# ERROR! NO INPUT FILE. #
#########################

(Usage) $0 INPUT OUTPUT width_option height_option
--------------------
(Ex) $0 Funny_Clip.avi 320 240\n"

#--------------------
# Check for input video.
if [ -z "$1" ]
then printf "$ERROR1"
exit
fi

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

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

# Print some information
printf "Video Encoding for Sharp Zaurus Playback\n\n"

printf "Would you like to use experimental auto resolution calculation? [Yes/No] "
read custom
case "$custom" in
 "Yes" | "yes" | "Y" | "y" )
height=`file $INFILE | gawk -F, '{print $3}' | gawk -F" " '{print $1}'`
width=`file $INFILE | gawk -F, '{print $3}' | gawk -F" " '{print $3}'`
first="$[$width*100/$height]"
second="$[640*$first/100]"
WIDTH=640
HEIGHT=$second
;;
esac

#--------------------
#--------------------
MAGIC1="mencoder "$INFILE" -ovc $VIDEO -lavcopts vcodec=$VIDEO_CODEC:vbitrate=300:vpass=1 -lameopts cbr:br=64:mode=3 -vf scale=$WIDTH:$HEIGHT -oac lavc -lavcopts acodec=$AUDIO -o $OUTFILE"
#--------------------
MAGIC2="mencoder "$INFILE" -ovc $VIDEO -lavcopts vcodec=$VIDEO_CODEC:vbitrate=300:vpass=2 -lameopts cbr:br=64:mode=3 -vf scale=$WIDTH:$HEIGHT -oac lavc -lavcopts acodec=$AUDIO -o $OUTFILE"
#--------------------
#--------------------

echo "Full screen [4:3]  use 640x480 [default]."
echo "Wide screen [16:9] use 640x360."
echo --------------------
echo "       Input: $INFILE"
echo "      Output: $OUTFILE"
echo "       Width: $WIDTH"
echo "      Height: $HEIGHT"
echo " Audio Codec: $AUDIO"
echo " Video Codec: $VIDEO_CODEC"
echo --------------------
echo " First mendoder command: $MAGIC1"
echo --------------------
echo " Second mencoder command: $MAGIC2"


# One last chance to bail out
printf "\nStart encoding? [Yes/No] "
read answer

# Start mencoder magic
case "$answer" in
  "Yes" | "yes" | "Y" | "y" )
$MAGIC1
$MAGIC2
printf "\n\nConverted file is $OUTFILE"
exit;;
esac

printf "\nEncoding has been cancled.\n"

14
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: September 11, 2006, 03:34:41 am »
Quote
Great script vrejakti!  Thanks.  It makes videos that play the best I have seen on my zaurus.

I have an idea.  Is it possible to just specify the width, for example 640, and then have the height automaticly set according to the aspect ratio of the input video?  It seems a few of my videos have strange aspect so I have to open them up in xine, check the aspect, then calculate it myself.  And sense I am never interested in streching the video this would be very usefull.

You know what I mean? 
W/640=H/h
where:
W= original width
640= new width
H= Original height
h= new height
[div align=\"right\"][a href=\"index.php?act=findpost&pid=135441\"][{POST_SNAPBACK}][/a][/div]

Thanks xamindar.   I'm sorry for taking so long to reply to you - that's an excellent idea to have the script calculate the the height given the aspect ratio.

I have the formual A/B = C, B*C=A written on my wall so I always remember how to calculate the right ratio. *laughs* Might as well code that math into the next script.  I'll see what I can do. ^^

15
C1000/3x00 Hardware / Encoding Videos For Zaurus
« on: September 11, 2006, 03:24:22 am »
Hey everyone, I have some free time, so I'll be re-writing this script to add the option of custimizing the video and audio formate easily. I was going to post an updated script... a couple months ago    but I gave up figureing out how mencoder works. I can write bash scripts with ease, but what mencoder does is all magic to me.

If anyone can explain how mencoder chooses the video codex and/or audio codex, I'd be happy to write a script that includes all the options you can provide me.

Well, I'd like to keep my development code secret, but here's what we're looking at for the next script:
Code: [Select]
# Declare some variables
INFILE=$1
OUTFILE=$2
WIDTH=640
HEIGHT=480
AUDIO=mp2
VIDEO=lavc
VIDEO_CODEC=mpeg4


echo Choose an audio codec
echo "[mp2] // MPEG Layer 2"
echo "[ac3] // AC3, AKA Dolby Digital"
echo "[adpcm_ima_wav] // IMA adaptive PCM (4 bits per sample, 4:1 compression)"
echo "[sonic] // experimental lossy/lossless codec"


 # 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 copy -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
mencoder "$INFILE" -ovc $VIDEO -lavcopts vcodec=$VIDEO_CODEC:vbitrate=300:vpass=1 -lameopts cbr:br=64:mode=3 -vf scale=$WIDTH:$HEIGHT -oac lavc -lavcopts acodec=$AUDIO -o $OUTFILE
mencoder "$INFILE" -ovc $VIDEO -lavcopts vcodec=$VIDEO_CODEC:vbitrate=300:vpass=2 -lameopts cbr:br=64:mode=3 -vf scale=$WIDTH:$HEIGHT -oac lavc -lavcopts acodec=$AUDIO -o $OUTFILE

All I need is some options to code in for $VIDEO_CODEC and $AUDIO.

I wish it was as simple as VIDEO_CODEC=mkv AUDIO=ogg - it seems a fair bit more complicated.

Pages: [1] 2