Tuesday, July 14, 2009

dvd_rip.sh script updated

I completed a fair amount of updates and small refactoring to my dvd_rip.sh bash script program for ripping/backing up DVDs. Yes, its still written in bash (for now!), but runs pretty fast and has lots of error checking. Some updates from this release include:

  • Updated with a $mountpoint variable (works better with ubuntu systems that auto mount disks under /media/cdrom{0}.
  • Required packages checking function is more robust and lets you know which packages you are missing (if any) instead of just exiting.
  • Added version string (long time coming)
  • Improved help output
  • $PATH variable now includes /usr/local/bin in case required binaries live here
  • General code cleanup (removed 18 lines of code!)

    Please feel free to download and give it a try. I have a couple other imrpovements coming soon when I get a chance to work on them. They should include:

  • Option to rip dvd as raw iso
  • Option to rip dvd as avi or mpg

    Direct link for download is here: http://www.box.net/shared/un3x08ato4
  • Thursday, April 30, 2009

    Synchronized Backflips @ Queens Bath, Kauai

    Just got back from Kauai, HI. Brian and I having some fun at Queens Bath in Princeville. Are we ready for olympic tryouts yet? =P

    Monday, March 16, 2009

    Encode video files for ipod-touch/iphone and T-Mobile G1/Andriod [Linux Hacks]

    I posted an article back in February on how to re-encode movies for ipod and other pmp devices in linux, based on my mini_encoder.py script. I have a few more updates now to add to the script for your enjoyment. Release notes as follows:

    -Now uses optparse python module for command line argument process handling
    -New option for iphone/ipod-touch in addition to ipod-video and default modes
    -Uses ffmpeg for processing ipod/iphone videos (H.264 and AAC codecs encoded to mp4 format)
    -General code cleanup and slight re-factoring
    -More verbose help options

    The main takeaway from this version is that mini_encoder.py is now capable of resizing mpg or avi video files for your ipod-video, iphone/ipod-touch or even your T-Mobile G1/Android, in addition to any other pmp player that is capable of handling avi or mpg video streams.

    The default resolution is 320x240, but for the iphone/ipod-touch and G1, it bumps it up to 480x320 to fit nicely on the screen and utilize the larger screen size. See the help option for more info


    $ ./mini-encoder.py --help
    ./mini-encoder.py - Encodes and resizes video files (avi or mpg) to fit
    small screen resolution pmp devices. Resolution and codec formulas:

    default - 320x240 (preserves original codecs from source video file)
    ipod - 320x240 (re-encodes to mp4 using H.264 and AAC codecs)
    iphone - 480x320 (re-encodes to mp4 using H.264 and AAC codecs)

    Supply a path to the movie file you wish to encode (required):
    ./mini-encoder.py [options] --movie /path/to/file.avi
    Options:
    --version Print the version number of this program
    -m, --movie Path to video file you wish to encode
    -p, --ipod Encodes to mp4 format for use with ipod-video
    -i, --iphone Encodes to mp4 format for use with iphone/ipod-touch

    Usage: mini-encoder.py [options]

    Options:
    --version show program's version number and exit
    -h, --help show this help message and exit
    -m INMOVIE, --movie=INMOVIE
    Input video file to encode
    -p, --ipod Encode to ipod-video format
    -i, --iphone Encode to iphone/ipod-touch format

    Example for encoding for iphone/ipod-touch:
    ./mini_encoder.py --iphone --movie /path/to/movie.avi


    Requirements for running this program are:
    1. A recent version of python
    2. transcode package
    3. ffmpeg package

    Please feel free to download it and let me know what you think.

    Sunday, March 8, 2009

    Convert wav to mp3 for a directory [Linux Hacks]

    There are some really nice Linux tools out there to do wav to mp3 conversion (lame, bladeenc etc). Here is a small shell script to run on a given directory that will convert all .wav files to .mp3:

    wav2mp3.sh

    Output:


    $ ./wav2mp3.sh /home/nmaxwell/foo/
    /usr/bin/bladeenc
    Performing mp3 conversion on: /home/nmaxwell/foo/
    Old filename: /home/nmaxwell/foo/song.wav
    New filename: /home/nmaxwell/foo/song.mp3

    BladeEnc 0.94.2 (c) Tord Jansson Homepage: http://bladeenc.mp3.no
    ===============================================================================
    BladeEnc is free software, distributed under the Lesser General Public License.
    See the file COPYING, BladeEnc's homepage or www.fsf.org for more details.

    Files to encode: 1

    Encoding: /home/nmaxwell/foo/song.wav
    Input: 44.1 kHz, 16 bit, stereo.
    Output: 128 kBit, stereo.

    Completed. Encoding time: 00:00:07 (21.71X)

    All operations completed. Total encoding time: 00:00:07


    The script will run this conversion on any files it sees in the directory with the .wav extension.

    Monday, February 16, 2009

    Convert avi or mpg video files to mp4 easily for ipod [Linux Hacks]

    I posted a short article back in November and referenced one of the scripts I wrote last year called mini_encoder.py. This python script has worked well for converting my fullsize avi and mpg files to fit nicely on my Cowon D2 PMP player, but I also have a 5th generation ipod video. Thanks to the jackasses over at Apple, ipod is only capable of playing mp4 video types, and is picky about the specific codecs used.

    I have updated my python script to now accept an option for an ipod (-i or --ipod), which will use ffmpeg for the conversion (rather then transcode). Grab a copy of the script hosted at box.net mini_encoder.py and give it a whirl. Let me know what you think. Output looks as follows:


    $ ./mini-encoder.py --ipod /movie/pineapple_express.avi
    Filecheck: OK
    Input filename: pineapple_express.avi
    Output filename: pineapple_express_mini.mp4
    Now running command: ffmpeg -i /movie/pineapple_express.avi -s qvga -vcodec libx264 -b 800k -g 300 -acodec libfaac -ab 128k pineapple_express_mini.mp4
    FFmpeg version SVN-r15615, Copyright (c) 2000-2008 Fabrice Bellard, et al.
    configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-static --enable-shared --cc=x86_64-pc-linux-gnu-gcc --disable-debug --disable-network --disable-optimizations --enable-libfaac --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libx264 --enable-libxvid --disable-demuxer=v4l --disable-demuxer=v4l2 --enable-x11grab --enable-libfaad --disable-ssse3 --disable-altivec --cpu=athlon64 --disable-vhook --enable-gpl --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-swscale --disable-stripping
    ...
    frame=161231 fps= 65 q=8.0 Lsize= 768341kB time=6721.71 bitrate= 936.4kbits/s
    video:659616kB audio:105001kB global headers:1kB muxing overhead 0.487023%
    [libx264 @ 0x64e6b0]slice I:546 Avg QP:14.37 size: 17141
    [libx264 @ 0x64e6b0]slice P:160685 Avg QP:16.54 size: 4145
    [libx264 @ 0x64e6b0]mb I I16..4: 8.4% 0.0% 91.6%
    [libx264 @ 0x64e6b0]mb P I16..4: 4.5% 0.0% 0.0% P16..4: 83.2% 0.0% 0.0% 0.0% 0.0% skip:12.3%
    [libx264 @ 0x64e6b0]final ratefactor: 15.34
    [libx264 @ 0x64e6b0]SSIM Mean Y:0.9895233
    [libx264 @ 0x64e6b0]kb/s:803.5
    Encoding complete! Filename is: pineapple_express_mini.mp4

    Sunday, January 4, 2009

    Mediatomb - UPnP Server to PS3

    After messing with TVersity (which is a great mediacenter), I decided I wanted to give one of the native Linux UPnP servers a go. Some searching led me to Mediatomb. This mediacenter app is really nice. It was a cinch to install (`emerge mediatomb` on Gentoo), and streams all my movies, pics and music to my PS3.

    My PS3 found it right away on the network, while I have it running in daemon mode in the background. It has a very nice, simplistic webserver UI that allows you to select directories and/or files to serve. You can do all of this on the cli as well too, or use the web UI. You can also disable to web UI completely, if you are worried about security on your LAN (anyone with a browser can hit up the server by ip:port on your LAN and browse/copy your filesystem).

    I had to tinker with the mappings for different filetypes to play to my PS3 (at first, it would not play any .avi files etc). Here are my modified mappings from my config.xml file:


    <map from="mp3" to="audio/mpeg"/>
    <map from="ogg" to="application/ogg"/>
    <map from="asf" to="video/x-ms-asf"/>
    <map from="asx" to="video/x-ms-asf"/>
    <map from="wma" to="audio/x-ms-wma"/>
    <map from="wax" to="audio/x-ms-wax"/>
    <map from="wmv" to="video/x-ms-wmv"/>
    <map from="wvx" to="video/x-ms-wvx"/>
    <map from="wm" to="video/x-ms-wm"/>
    <map from="wmx" to="video/x-ms-wmx"/>
    <map from="m3u" to="audio/x-mpegurl"/>
    <map from="pls" to="audio/x-scpls"/>
    <map from="flv" to="video/x-flv"/>
    <map from="avi" to="video/x-divx"/>
    <map from="DivX" to="video/x-divx"/>
    <map from="divx" to="video/x-divx"/>
    <map from="AVI" to="video/x-divx"/>
    <map from="vob" to="video/x-mpeg"/>
    <map from="VOB" to="video/x-mpeg"/>
    <map from="ts" to="video/x-mpeg"/>
    <map from="TS" to="video/x-mpeg"/>
    <map from="mpeg" to="video/x-divx"/>
    <map from="mpg" to="video/x-mpeg"/>
    <map from="MPG" to="video/x-mpeg"/>
    <!-- Uncomment the line below for PS3 divx support -->
    <map from="avi" to="video/divx"/>
    <map from="divx" to="video/divx"/>
    <!-- Uncomment the line below for D-Link DSM / ZyXEL DMA-1000 -->
    <!-- <map from="avi" to="video/avi"/> -->

    These settings seem to work very well with my setup, and my PS3 is able to play all of the filetypes I have tried based on this mapping.

    One other really cool added bonus is the low resource needs of Mediatomb. The output of `top -p $(pgrep mediatomb)`

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    5725 nmaxwell 20 0 235m 11m 4140 S 0 0.3 0:54.79 mediatomb

    As you can see, it only uses about .3 % memory, and even less cpu. Even while streaming video content, the resource usage is quite low. For comparison, my Tversity resource usage (while running in WinXP Virtualbox) was much more intensive (~33% memory usage and 15% cpu usage). MediaTomb is very easy to live with, and saves me from having to have my WinXP guest os running in the background at all times in order to stream media to my PS3. Great app, and Im looking forward to more streaming content (YouTube, Hulu etc), hopefully soon. Im really impressed and happy with MediaTomb thus far, and its highly recommended for any linux user looking to stream content to your UPnP capable device.

    Shot of simplistic MediaTomb web UI: