Category Archives: Uncategorized

FFmpeg: Unrecognized option ‘filter:v’

I have a script that splits a given video vertically. Basically it looks like

ffmpeg -y -i input.avi -filter:v crop=480:360:0:0 output.avi

It worked all well on my local machine. But when I uploaded to the server, which is running an older version of FFmpeg on Ubuntu 12.04, it threw this error:

Unrecognized option 'filter:v'

Updating FFmpeg (or libavfilter, perhaps) will solve this error.

sudo apt-get remove ffmpeg
sudo apt-add-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

Default Bash Autocompletion

I was writing a bash auto completion script, following this tutorial.

But one thing that stuck me for a while was that I could not use default bash auto completion for some options.

Let’s say I have a command called mycmd, which has such a synopsis:

Usage: mycmd [options]

Options:
  hello       Say "Hello"
  help        Show this help
  show file   Show file

It’s not hard to write a script like this following the tutorial.

#!/bin/bash

_mycmd()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="hello help show"

    case "${prev}" in
        *)
            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
            return 0
            ;;
    esac
}
complete -F _mycmd mycmd

It works pretty well that It can auto complete the options “hello”, “help” or “show”. But I also want it to show possible files after mycmd show just like cat.

I have tried like compgen -f or ls -1p but they can not handle spaces in the file name or home directory (~/).

After some exploration (i.e. complete | grep cat), I found out that _longopt looks like what I want.

#!/bin/bash

_mycmd()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="hello help show"

    case "${prev}" in
        show)
            _longopt
            return 0
            ;;
        *)
            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
            return 0
            ;;
    esac
}
complete -F _mycmd mycmd

It works perfect!

Use External Background Image in BorderContainer in ActionScript 3.0, Flex 4.6

Here is a BorderContainer, which uses an embedded image as background.

<s:BorderContainer width="100%" height="100%" backgroundImage="@Embed('Internal/Image.jpg')" visible="true">
    <!-- Some contents -->
</s:BorderContainer>

An easy way to use an external background image without creating a skin class is this:

<s:BorderContainer width="100%" height="100%"visible="true">
    <mx:Image source="External/Image.jpg" width="100%" height="100%" maintainAspectRatio="false"></mx:Image>
    <!-- Some contents -->
</s:BorderContainer>

WoW addon: Cross Realm Auto Invite

This is my first World of Warcraft addon. Actually it was done like one year ago. When I was cleaning my repositories today I found it.

https://github.com/01zhou/WoW_CrossRealmAutoInvite

Basically it allows you to automatically invite your friend into your party when s/he whispers you ‘1’. Well it may help those players who are looking for rare pets or rare NPCs by switching between realms frequently.