Friday, November 30, 2012

Extracting WAVs from VOB Files

The Station to Station box set contains a DVD with hi-resolution digital rips of the album, including one in 96/24. Since I play all of my digital stuff through a Logitech Transporter, I needed to rip those files to the media server. Here's how I did it.

First, I used mplayer to rip the VOB files from the DVD. These files have trivial video in them, so that has to be removed. The command to do that is:

ffmpeg -i <infile.vob> -acodec pcm_s24le <outfile.wav>

The audio codec here is the usual one for 24-bit audio, as you can see if look at a wav generated from a flac file. E.g.:

# ffmpeg -i 01-statesboro_blues.wav
...
Input #0, wav, from '01-statesboro_blues.wav':
Duration: 00:04:19.94, bitrate: 4608 kb/s
Stream #0.0: Audio: pcm_s24le, 96000 Hz, 2 channels, s32, 4608 kb/s
At least one output file must be specified


Note that this is independent of the sampling rate, so it works for 48/24 files, as well.

So now I had a bunch of 96/24 wavs, which I could convert to flac in the usual way.

Monday, November 19, 2012

Perl Filters

A nice trick for easily writing Perl filters:

perl -pe 's/a/b/g'

will do the substitution on each line of input and spit it back out. And:

perl -i bak -pe 's/a/b/g' file1 file2....

will do the same, except it will change the given files and back them up to file1.bak, etc, as it does so.


Thursday, July 19, 2012

How To Add to an LVM Drive

One of the great things about LVM is that you never run out of space. If it seems as if you are about to do so, you just add a new "physical volume" to your "volume group", add that to your "logical volume", and resize the file system. In effect, it's as if you have a partition that spans multiple drives.

It would of course be a good idea to back things up before you do this. But sometimes we don't have that option, do we?

I'll suppose our existing volume group is "vgroup", and our existing logical volume is "vvolume".

All of this of course needs to be done as root.

A little hint first: You can (and probably should) give the "-t" (test) option to each LVM command first, to make sure it's going to do what you want. Then I hit up arow (history) and delete the "-t" option, so I make sure I'm running that same command.
  1. Add the new disk to the machine, and format whatever space we want on it (all of it, if we wish) as type 8e (Linux LVM). I'll assume this is now /dev/sde1.
  2. Create a physical volume:
    # pvcreate /dev/sde1
  3. Add the physical volume to the volume group:
    # vgextend vgroup /dev/sde1
  4. Check your work:
    # vgdisplay vgroup
    You should now see something like:
    VG Name               vgroup
    System ID
    Format lvm2
    Metadata Areas 2
    Metadata Sequence No 5
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 1
    Open LV 0
    Max PV 0
    Cur PV 2
    Act PV 2
    VG Size 3.68 TiB
    PE Size 4.00 MiB
    Total PE 1192327
    Alloc PE / Size 476931 / 1.82 TiB
    Free PE / Size 476931 / 1.82 TiB
    VG UUID JitzBk-zFH0-vhzm-XhYk-V5Xi-Nt7d-87K9En
    Note the free space we now have.
  5. Extend the logical volume:
    # lvresize -l 100%VG /dev/vgroup/vvolume
    The "-l 100%VG" says to resize to use all of the space in the volume group assigned to this logical volume. The argument can be given many ways. See "man lvcreate".
  6. Check our work:
    # lvdisplay
  7. Now we are ready to resize the filesystem:
    # e2fsck -f /dev/vgroup/vvolume
    It made me do that first.
    # resize2fs /dev/vgroup/vvolume
The LVM HowTo covers all of this.

    Saturday, May 19, 2012

    Using Remember the Milk with Thunderbird

    I've been looking for a few days now for a good task list to use under KDE. The main requirement is that I want something that will be easily usable on many computers, and mobile devices, and without my having to worry a lot about sync'ing.

    Google Tasks look great, but I don't want to have to use Google all the time, just to see and manage my tasks, and there doesn't appear to be a decent API for Tasks. So you can't sync them to Thunderbird or anything else.

    KOrganizer looks nice, but I don't see any good sync options there, either.

    So I stumbled across Remember the Milk, which is also a web-based task manager, but with lots of other support. There's an Android app, and there's also an iCal URL you can use to view tasks in other places. The only downside is that the iCal support is read-only.

    But I found a way around that in Thunderbird. First, you just add the iCal service as a calendar. (Get that URL from Settings> Info, in Remember the Milk.) That'll at least let you see your tasks in Thunderbird.

    Now, how to add tasks? Answer: Use RTM's google gadget in a tab in Thunderbird. First, you'll need to download the WAT extension for Thunderbird. Among other things, this will give you a box in the upper right corner where you can enter a URL, which will then be opened in a new tab. The URL to enter is:
    • http://www.rememberthemilk.com/services/modules/googleig/
    You'll need to sign in the first time, of course. You can now bookmark the page and have easy access to it whenever you need to add or modify a task. And, of course, you can do the same with the main RTM URL.

    Monday, August 15, 2011

    Natbib's Same Name Problem

    When working yesterday on my book on Frege's Grundgesetze, I suddenly realized that I had a problem with the bibliography. I have references to papers written by both Charles Parsons and Terence Parsons, one each from 1995. These were coming out in the citations as: (Parsons, 1995a) and (Parsons, 1995b). These are at least unambigious, but they are not what one would want. And, indeed, even if I hadn't had papers published the same year, I'd still be getting: (Parsons, 1965) and (Parsons, 1995), which still isn't what I'd want. What I'd want is: (Parsons, C., 1965) and (Parsons, T., 1995).



    Googling turned up several complaints about this, which I would characterize as a bug in the LaTeX package natbib, that being what has traditionally been used with LaTeX for author-year references. Many people now are using biblatex, of course, and perhaps this bug has been resolved there. But I already have a custom bibliography style written for natbib, so I'm not sure I want to do the work to switch over to biblatex yet, anyway.



    So, I got to work to solve the problem. My goal was to modify the standard plainnat.bst style so that it would give me the kinds of citation labels I want. It actually turned out not to be that difficult, given that I've worked before with the strange postfix stack language that is used to write BibTeX styles in developing my own bst file.

    I've posted the results here:


    The former is the modified bst file; the latter is a diff against plainnat.bst, so that you can see exactly what I've done. The changes should be fairly easy to port to other bst's---I hope so, since I still need to port them to my own bst---since they are pretty much confined to one part of the file.



    There are limits to the approach. First, I deal only with authors and editors. Second, I deal only with single name cases. But I also provide ways to override the calculated labels, so that you can force a certain label if you need to do so. There are two new entry fields for this purpose:


    1. dupelabel
      Defines a label that will be used if a duplicate author is found, e.g.:

      dupelabel = {Parsons, Ch.}

      dupelabel = {Parsons, Ca.}

      might be put in entries by Christopher Parsons and Carrie Parsons, respectively. 

    2. forcelabel

      Defines the label we will use, period. 


    Friday, October 22, 2010

    Linux LVM

    Instructions for creating a new file system via LVM.
    I'll assume we have two disks we're going to use, /dev/sde and /dev/sdf.
    All of this has to be done as root.
    1. Create partitions on both disks using fdisk. Set the type to 8e (Linux LVM). These may be the full disk, or not. I'll assume these are now /dev/sde1 and /dev/sdf1
    2. Create physical volumes:
      # pvcreate /dev/sde1
      # pvcreate /dev/sdf1
    3. Check our work:
      # pvdisplay
    4. Create a volume group:
      # vgcreate NameOfGroup /dev/sde1 /dev/sdf1
    5. Check our work:
      # vgdisplay
    6. Create the logical volume, which is what Linux will see as if it were a partition:
      # lvcreate  -l 100%VG -n NameOfVolume NameOfGroup
      Note that the -l option can be provided in many forms. This one says to assign 100% of the space in the volume group to this logical volume.
    7. Check our work:
      # lvdisplay
    8. Create the filesystem:
      # mke2fs -j -L VolumeLabel /dev/NameOfGroup/NameOfVolume
    9. Now the new filesystem can be mounted in the usual ways.
    Some good links for more info:

    Initial Post

    This blog is mostly so I can record things I tend to forget. Most of them will be about Linux, but some may be about other things.