The Complete Guide to Embedded Videos in Beamer under Linux

It is now possible to embed videos in Beamer presentations under Linux.  It’s stable and works well.

The strategy is to use acroread and a flash player to play .flv files. Credit to this post for a lot of this work. Here’s how to do it:

The short version:
1. Get acroread version 9.4.1 [local mirror]
2. Download the example.
3. Convert your video to flv (mess with the resolution to get smooth playback).

ffmpeg -i movie.avi -sameq -s 960x540 movie.flv

Now the explanation:


I. Get the right version of acroread.


1. Uninstall acroread using apt-get (which isn’t likely to be the right version)

sudo apt-get remove acroread

2. Download version 9.4.1 of acroread from Adobe (note that the i486 version will still work on 64-bit systems) [FTP page] [local mirror]
3. Mark the package executable:

cd your-download-directory
chmod +xx AdbeRdr9.4.1-1_i486linux_enu.bin

4. Install acroread:

./AdbeRdr9.4.1-1_i486linux_enu.bin

I installed to /opt/acroread, so I run it like so:

/opt/acroread/Adobe/Reader9/bin/acroread

II. Get Beamer files and flash player


Read the rest of this entry »


flash encoding using ffmpeg

ffmpeg -i movie.avi -sameq movie.flv

If you have issues with the sound and just want to remove it:

ffmpeg -i movie.avi -an -sameq movie.flv


S107G Helicopter Control via Arduino

I have worked with two types of S107G helicopters. One is a 2-channel (A and B) and the other is a 3-channel (A, B, and C) version. Their protocols differ significantly. The more common 2-channel (32-bit) version’s protocol is well documented elsewhere, so here I will only document the 3-channel (30-bit) version.

(First posted at rcgroups.)

S107G at FIAP Workshop

 

The protocol for this is 30 bits long.

  • To send a bit you flash the IR lights 16 times for a 0 and 32 times for a 1.
  • Each flash is off for 8-9 microseconds and on for 8-9 microseconds.
  • Between bits you wait for 300 microsecond
  • Between 30-bit packets you delay an amount depending on the channel you are using.
  • Channel A: 136500 us
  • Channel B: 105200 us
  • Channel C: 168700 us

The order of the bits is as follows:

CC00 PPPP TTTT TTTT YYYY XXXX RRRR RR

C – channel
P – pitch
T – throttle
Y – yaw
X – checksum
R – trim

There are a few other things to note:

1) It has a checksum. The 21-24th bits are a bitwise XOR of 4-bit words with the two zeros appended to the end of the bitstring. Thus you can compute the checksum for the first packet:

1000 0000 1000 1100 0000 1111 1111 11
with:
1000 ^ 0000 ^ 1000 ^ 1100 ^ 0000 ^ 1111 ^ 1100 = 1111

and for the second packet:

1000 0000 0011 1001 0000 0001 1111 11
with
1000 ^ 0000 ^ 0011 ^ 1001 ^ 0000 ^ 1111 ^ 1100 = 0001

Read the rest of this entry »


Run script on resume from suspend

Put your script into

/etc/pm/sleep.d

with a number at the beginning and mark it executable. Here’s an example that sets my Thinkpad mouse sensitivity and enables two-fingered scrolling on my touchpad.

$ cat /etc/pm/sleep.d/99-trackpoint-and-twofinger
#!/bin/bash
case "$1" in
    thaw|resume)
	echo -n 220 > /sys/devices/platform/i8042/serio1/serio2/sensitivity 2> /dev/null
	echo -n 95 > /sys/devices/platform/i8042/serio1/serio2/speed 2> /dev/null
	xinput set-int-prop 'SynPS/2 Synaptics TouchPad' "Synaptics Two-Finger Pressure" 32 4
xinput set-int-prop 'SynPS/2 Synaptics TouchPad' "Synaptics Two-Finger Width" 32 7
xinput set-int-prop 'SynPS/2 Synaptics TouchPad' "Synaptics Two-Finger Scrolling" 8 1 1
xinput set-int-prop 'SynPS/2 Synaptics TouchPad' "Synaptics Jumpy Cursor Threshold" 32 250
        ;;
    *)
        ;;
esac
exit $?

Note that if you want to have the script run at boot as well you probably want to add your code to

/etc/rc.local


VirtualDub settings for .MTS video

Video: MTS off a Canon Vixia HG21.
Setup: Linux, working in wine.

Conversion to avi for VirtualDub/AviSynth:

ffmpeg -i 00394.MTS -vcodec libxvid -b 100000k -deinterlace -acodec libmp3lame output.avi

Set up VirtualDub:

  • Options > Preferences > AVI > Check Directly decode uncompressed YCbCr (YUV) sources
  • Select Video > Compression…
    • Select ffdshow Video Codec
    • Select Configure and then set the bitrate to 10000
  • Select Video > Fast recompress


Speed up MATLAB figures with OpenGL

You can substantially increase your MATLAB figure performance by using OpenGL rendering. Put this in your startup.m file:

set(0, 'DefaultFigureRenderer', 'OpenGL');

You can check if MATLAB has detected your hardware by using:

>> opengl info

Other relevant figure properties are:

>> set(gcf,'Renderer','OpenGL')
>> set(gcf,'RendererMode','manual')

Warning: this breaks saving EPS files as vectorized figures.


Gumstix wifi (wlan1: link not ready)

I just spent a long time trying to diagnose an issue with a Gumstix Overo Fire and brining up WiFi (802.11b/g) on boot.  I did all the standard things (when using a desktop image, you must uninstall NetworkManager and then set up your configuration in /etc/network/interfaces. I could get a connection sometimes, but it was very unclear why it would or would not connect. So unclear that I couldn’t write a script that would bring the WiFi up on boot.

I kept getting this issue:

ADDRCONF(NETDEV_UP): wlan1: link is not ready

occasionally followed by the better:

ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready

Also, something odd was going on that I don’t understand because when the interface would configure on boot, it would rename to wlan1:

[... boot messages ...]
libertas_sdio: Libertas SDIO driver
libertas_sdio: Copyright Pierre Ossman
Remounting root file system...
libertas: 00:19:88:21:59:1c, fw 9.70.7p0, cap 0x00000303
libertas_sdio mmc1:0001:1: wlan0: Features changed: 0x00004800 -> 0x00004000
libertas: wlan0: Marvell WLAN 802.11 adapter
udev: renamed network interface wlan0 to wlan1
Caching udev devnodes
[...]

Finally, I found a solution: use an image from 2010. I’m using the omap3-console-image-overo-201009091145 build found here and mirrored locally here.


Colors in `ls`

How to make (a gumstix say) show colors for ls (assuming your login shell is bash). Edit ~/.bashrc and ~/.bash_profile to match these files:

Make sure your shell is bash (if it’s not, you can change it in /etc/passwd):

root@overo:~# echo $SHELL
/bin/bash

In ~/.bashrc:

root@overo:~# cat .bashrc
export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'

In ~/.bash_profile:

root@overo:~# cat .bash_profile
source ~/.bashrc


Recursively get (or set) a property in svn

Edit: There’s an easier way to delete properties recursively:

svn propdel -R rlg:email robotlib-mydev

Use find to traverse recursively through the directory structure:

find . -type d \! -path *.svn* -exec echo {} \; -exec svn propget rlg:email {}@ \;

To print out the current directory:

-exec echo {} \;

To find only directories:

-type d

To ignore svn folders:

\! -path *.svn*

To execute the propget command:

-exec svn propget rlg:email {}@ \;

The {} is the place find puts the path and the @ at the end causes SVN to parse correctly for paths that have “@” in them.


Firefox 5 extension compatibility check

The old preference for disabling compatibility checks (extensions.checkCompatibility) is now gone. The new one marks the version you chose to do this at:

To re-enable your broken (but likely still working) add-ons in Firefox 5.0, add the extensions.checkCompatibility.5.0 preference in about:config:

1. Type about:config into the firefox URL bar.

Read the rest of this entry »


Enable editable shortcut keys in Gnome

There used to be a checkbox for it, but it’s gone now. You can still enable the option by opening

gconf-editor

and checking the box under

/desktop/gnome/interface/can_change_accels


Reload udev rules without restarting udev

sudo udevadm control --reload-rules


Email CPU usage

Say you’re going to be out of solid contact for a while, but you’d like to monitor your CPU usage (so you can make sure to SSH in and fix something if the CPUs go idle, indicating a simulation crash.)

Solution: a quick script to email me my CPU load every hour. Then all my sessions are on screen, so I can SSH in with my phone and edit/restart what I need over 3G. If it looks bad, I’ll know to get to a real net connection ASAP.

Here’s the script (requires sudo apt-get install sendemail)

#!/bin/bash

while true; do
    echo `uptime` | sendemail -f abarry@abarry.org -t abarry@abarry.org -u "Uptime report (auto)"

    sleep 3600
done


video conversion with mencoder

With sound:

mencoder VIDEO0046.3gp -ovc x264 -oac mp3lame -o VIDEO0046.ogg

No sound:

mencoder VIDEO0046.3gp -ovc x264 -nosound -o VIDEO0046.ogg


Reverting to old versions in SVN

If you want to revert everything to a previous version (ie revision 72):

svn merge -rHEAD:72 .

Note the “.” at the end!

If you want to revert all local changes (ie say go back to the head revision):

svn revert -R .

Again, note the “.” at the end.

To view the diff between two versions (ie what changed between revisions 72 and 73), use:

svn diff -r 72:73 file.java


Resize with imagemagick

convert pic.jpg -resize 50% pic.png

or

for file in *.png; do convert $file -resize 15% thumbs/$file; done

or

convert ../task1.png -resize 300x100 task1.png

File conversion is also nice:

for foo in *.jpg ; do convert ${foo} ${foo%.jpg}.png ; done


Browse old revision in SVN using the web interface

Append

!svn/bc/[revision number]/

to the URL of the repository (not just any folder in the repository).

So in other words:
https://svn.csail.mit.edu/locomotion/!svn/bc/681/


Export Cinelerra Video to YouTube

I took me a while to figure out the best Cinelerra export settings for YouTube. I ended up going with MPEG4 and an AVI container.


Use mencoder to convert from recordmydesktop to dv format that cinelerra can open

mencoder -vf crop=720:576:0:0 -ovc lavc -lavcopts vcodec=dvvideo seeded-1.ogv -o scaled2/colorized.avi

crop options: width:height:x:y

where x and y are the top left coordinates of the cropping box.


Antialiased rings / filled circles in pygame

This shouldn’t be hard. But it is.

If you want to have a filled circle / ring in pygame you need to draw the antialiased part yourself. This is a terribly complicated way to get antialiased circles.

Unfortunately, pygame does not implement an antialiased filled circle, so you basically have to create them yourself. Also, the antialiased circles that pygame does implement seem to only antialiase to white, so they cause further problems by encroaching on the colored parts of the image.

def DrawTarget(self):

    # outside antialiased circle
    pygame.gfxdraw.aacircle(self.image, self.rect.width/2, self.rect.height/2, self.rect.width/2 - 1, self.color)

    # outside filled circle
    pygame.gfxdraw.filled_ellipse(self.image, self.rect.width/2, self.rect.height/2, self.rect.width/2 - 1, self.rect.width/2 - 1, self.color)

    temp = pygame.Surface((TARGET_SIZE,TARGET_SIZE), SRCALPHA) # the SRCALPHA flag denotes pixel-level alpha

    if (self.filled == False):
        # inside background color circle

        pygame.gfxdraw.filled_ellipse(temp, self.rect.width/2, self.rect.height/2, self.rect.width/2 - self.width, self.rect.width/2 - self.width, BG_ALPHA_COLOR)

        # inside antialiased circle

        pygame.gfxdraw.aacircle(temp, self.rect.width/2, self.rect.height/2, self.rect.width/2 - self.width, BG_ALPHA_COLOR)

    self.image.blit(temp, (0,0), None, BLEND_ADD)