Extracting video from FLV using ffmpeg

Use

ffmpeg -i input.flv -vcodec copy output.mkv

to copy audio and video from input.flv to output.mkv (.mp4 or .avi also work) without transcoding it. This comes in handy when working with tools that are unreliable when processing certain container formats such as FLV. The otherwise great HDConvertToX, for example, is such a tool.

Windows file type association

Windows does not offer an equivalent to Unix’ shebang, e.g. #!/usr/bin/perl -T, which is unfortunate. Instead, Windows users can register a default program with each file extension, that is invoked if the user double-clicks on a file or if a file is run from the Windows command prompt. This is less flexible because file-specific arguments to the invoked program, such as -T in my initial shebang example, cannot be stored alongside the file. Moreover, having to use a graphical interface to register programs with extensions doesn’t overly excite me.

However, since Windows 2000 there exists the – so far unknown to me – possibility of getting the task done via the shell utilities assoc and ftype:

$>assoc .scala=ScalaFile
.scala=ScalaFile
  
$>ftype ScalaFile=C:\Program Files\scala\bin\scala.bat -savecompiled %1 %*
ScalaFile=C:\Program Files\scala\bin\scala.bat -savecompiled %1 %*

This still is less flexible than the shebang, but, well … everybody needs something that he/she is looking forward to see implemented in his/her favourite operating system, right?

Thanks to the folks at ActiveState for pointing this out.

Batch script forwarding arguments with double quotes

Imagine that you have a program foo.exe which takes multi-word command line arguments, for example

$>foo.exe aShortArg aKey:"multi-word arg"
arg1 = aShortArg
arg2 = aKey:"multi-word arg"

You also have a timing script timer.scala (could also be written in Java) which runs another program and measures its runtime. To facilitate starting the script you have written a batch file which runs the actual script.

// timer.bat
@echo off
SetLocal
 
set CP=.;%SCALA_HOME%\lib\scala-library.jar
set JAVA_OPTS=%JAVA_OPTS% -Xss16m
 
call java %JAVA_OPTS% -cp "%CP%" TimerMain %*

In order to not worry about properly escaping double quotes when passing them to timer.bat, .e.g

$>timer.bat bbb.exe path\to\aaa.exe aKey:"multi-word arg"
Starting benchmark ...
Running aaa.exe at path\to:
arg1 = aKey:multi-word
arg2 = arg
... DONE
Runtime: 1s
 
$>timer.bat bbb.exe path\to\aaa.exe aKey:"\"multi-word arg\""
Starting benchmark ...
Running aaa.exe at path\to:
arg1 = aKey:"multi-word arg"
... DONE
Runtime: 1s

you can change timer.bat such that double quotes get escaped automatically before they are forwarded:

// timer.bat
@echo on
SetLocal EnableDelayedExpansion
 
set ARGS=
 
:parse_args
if not %1.==. (
  set ARG=%1
  set ARGS=!ARGS! ^"!ARG:"=\"!^"
  shift
  goto :parse_args
)
 
set CP=.;%SCALA_HOME%\lib\scala-library.jar
set JAVA_OPTS=%JAVA_OPTS% -Xss16m
 
call java %JAVA_OPTS% -cp "%CP%" TimerMain %ARGS%

This also you to forget about escaping double quotes, and enables you to simply specify the arguments to foo as if they were direct arguments, i.e. as if they would not be looped through the timer script:

$>timer.bat bbb.exe path\to\aaa.exe aKey:"multi-word arg"
Starting benchmark ...
Running aaa.exe at path\to:
arg1 = aKey:"multi-word arg"
... DONE
Runtime: 1s

Graphviz poster workflow at ETH, CoPM

Given a Graphviz gv-file, perform the following steps to create and print an arbitrarily-sized image tiled into A3 tiles.

Continue reading Graphviz poster workflow at ETH, CoPM

Scala compiler AST nodes

The AST nodes of the Scala compiler (2.8.0) are usually imported from an instance of scala.tools.nsc.Global, e.g.

import scala.tools.nsc.Global
import scala.tools.nsc.plugins.Plugin
// ...
class MyPlugin(val global: Global) extends Plugin {
  /* Import the AST node ClassDef */
  import global.ClassDef
  // ...

but they are actually defined in scala.reflect.generic in the trait Trees.

“auseinanderzugehen” und andere zusammengesetzte Wörter mit “zu”

Unten stehend die Antwort von Wolfgang Zimmerm?nn zur Frage, ob und wann man Wörter mit “zu” zusammenschreibt.

Continue reading “auseinanderzugehen” und andere zusammengesetzte Wörter mit “zu”

Scala, Windows CMD, Simple Build Tools, Unicode

In order to see Unicode characters when running a Scala project using SBT inside a Windows console (cmd) you have to perform the following steps:

  • Fire up regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ Console\TrueTypeFont. There should be an entry with key-value pair (“0″, “Lucida Console”). Add new pairs with a sequence of zeros as the key and a font as the value, e.g. (“00″, “DejaVu Sans”), (“000″, “Lucida Sans Typewriter”) etc.
  • Edit your SBT launcher-script – the one that runs SBT e.g. as java %SBT_OPTS% -Xmx256M -jar "tools/sbt-launch-0.7.4.jar" %* and add the Java option -Dfile.encoding=UTF-8.
  • Open a Windows command box and run chcp 65001 to set the code page to UTF-8.

That’s it. You should now be able to see Unicode output of your Scala project when run from inside the SBT shell.

If you want to change the code page permanently, run regedit, go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage and change the “OEMCP” value to “65001″.

Windows Media Player context menu

Found the following in this article. It will remove the WMP context menu entries ("add to burn list", "add to sync list" etc.) if you right-click on e.g. an mp3 audio file.

Remove WMP context menus:

  • Click Start
  • Click Run
  • Type in gsvr32 /u wmpshell.dll
  • Click Enter

Enable WMP context menus:

  • Click Start
  • Click Run
  • Type in regsvr32 wmpshell.dll
  • Click Enter