Tuesday, October 25, 2011

Pingus script to play extra levels

Pingus is a nice Lemmings clone. Many of the levels are loadable only by the level editor or command line. You can also create custom Levelsets, but whichever method you use, they are all somewhat cumbersome.

I found a nice bash script here that loads individual levels and used it as a basis to create my own with some improvements. The new script gives you the option to open Pingus normally or select an individual level.

1. Change the PINGUS_DIR path to your pingus binary

2. Edit the Pingus command line parameters a few lines down (/pingus $f -g 1280x720 -f) if you want to change screen dimensions, etc

#!/bin/bash

#####################
# Pingus launcher #
#####################


# Pingus directory
PINGUS_DIR=~/pingus-0.7.4

# How do you wan to run Pingus
function runPingus {
  cd $PINGUS_DIR
  ./pingus $f -R 1280x720 -f
}

# Pingus level directory
PINGUS_LVL_DIR=$PINGUS_DIR/data/levels

function doExit {
  # if exit code equals 1, dialog was cancelled, exit
  if [[ $? == 1 ]]
  then
    exit
  fi
}

# show zenity menu for selecting how to start Pingus
ans=$(zenity --list --text "Pingus" --radiolist --column "" --column "" --hide-header TRUE "Start Pingus normally" FALSE "Select individual level")
# run doExit function to test if menu was cancelled
doExit

# if individual level was selected...
if [[ $ans == "Select individual level" ]]
then
  cd $PINGUS_LVL_DIR
  exec >/dev/null 2>&1
  f=1
  while [ "$f" != "" ]
  do
    # prompt for level select
    f="$(zenity --title="Last Level: $(cat ~/.pingus.last)" --file-selection)"
    [ "$f" != "" ] && echo $(basename $f) > ~/.pingus.last
    # check to see if dialog was cancelled
    doExit
    # change to Pingus dir and run
    runPingus
    cd $(dirname $f)
  done
else
  # if starting Pingus normally, just run it
  runPingus
fi

Tuesday, October 18, 2011

Trimming FLV Videos

I wanted to trim some FLV videos without re-encoding.

flvtool2 is supposed to cut flv videos (in milliseconds!), but I always got errors.
flvtool2 -C -i 6000 -o 12000 input.flv output.flv
Avidemux opened the video and I could trim it (using keyframe arrows was necessary), but trying saving in FLV format had errors. Saving as an MP4 with copy/copy was successful, but sound was no longer synced. There is an option to shift the audio, but I didn't do any testing.

ffmpeg ended up being the easiest solution, but it didn't trim exactly where I specified. I'm guessing this has to do with keyframes. The following example trims approx first 15 seconds off the front of the video, and audio is synced.
ffmpeg -ss 15 -i input.flv -acodec copy -vcodec copy output.flv
According to the man pages, the value can be specified to millisecond: "hh:mm:ss[.xxx]", but I could never get this to work.

Thursday, October 6, 2011

JDiskReport - Find folder and file sizes quickly

JDiskReport finds files, largest on down. Very useful for finding where the bulk of you disk space is going.

http://www.jgoodies.com/freeware/jdiskreport/

Finding recently modified files in Ubuntu

A slight variation from this page:
http://mediakey.dk/~cc/linux-howto-find-the-most-recently-changed-files-recursively/

find . -type f -printf "%TY-%Tm-%Td %TT %p\n" | sort -r | less
Newest files on top, scroll through list using up/down arrow keys or page up/down, press Q to quit.