Archive for the 'linux' Category
Saturday, April 25th, 2009
Last Christmas my parents got me a Canon FS100 video camera. I had asked for a video camera to take videos of my son. I honed my video editing skills a bit before he arrived, but am still working on it. The camera uses flash memory, and records videos in .mod files, which are basically just .mpg files. Although the camera is not HD (the HD version was more than twice as expensive), it does have the option of recording in 16:9 widescreen. I have been using Kino to do my editing, with some success. One problem I had was that if I used Kino to import the files from the camera, the aspect ratio got messed up. Kino would treat the file as 4:3 aspect ratio, even though I had the settings to 16:9. Then it would pad the sides with black space. I saw others complaining about this problem as well, but did not find anyone with a solution. Eventually, I decided to try my hand with ffmpeg myself. After some playing around, I determined that I could create a dv file from the .mod file with ffmpeg, open the .dv with Kino, do some editing, export, and then convert again.
First the conversion from .mod to .dv
ffmpeg -i MOV001.MOD -target dv -aspect 16:9 MOV001.dv
Then I open the .dv file in Kino and edit it, and export to raw dv, making sure to uncheck the options for splitting into separate files and for resampling audio
Finally, I convert the dv to flv to put on my blog:
ffmpeg -i infile.dv -b 325k -ar 22050 -ab 24k -s 480x270 -aspect 16:9 outfile.flv
You can see the result on the fedibblety blog
Tags: ffmpeg, video
Posted in linux | 1 Comment »
Sunday, March 15th, 2009
Rob and Spencer with zebras
Once again I found myself needing to use imagemagick to do something, and was overwhelmed by the many options. After much fiddling around, I found out some options that worked for me.
In this case, I wanted to extract iptc captions from images, so that I could then insert the caption in a webpage with php. I use Picasa to edit photos and add captions. Picasa adds in the captions in the iptc information, which is the right place to add them. To extract the caption from the image above, do the following
convert robSpencer.jpg 8BIMTEXT:-
The result should be output to standard out:
8BIM#1028=”IPTC”
2#120#Caption=”Rob and Spencer with zebras”
If you want to output to a file, simply do something like:
convert robSpencer.jpg 8BIMTEXT:filename.iptc
Now it easy to extract the caption using perl, python, php or whatever you like. For perl, we could simply pipe it:
convert robSpencer.jpg 8BIMTEXT:-|perl -ne '/Caption="(.*)"/; print $1;'
And in case you are interested, I needed to do this for the postie wordpress plugin which allows you to post to your blog via e-mail. In version 1.1.5 iptc captions will be read and displayed (if they are in the image you attach).
Tags: caption, imagemagick, iptc, picasa, postie
Posted in linux, photography, wordpress | No Comments »
Thursday, December 4th, 2008
thanksgiving collage
I upgraded to Picasa 3 a couple weeks ago. I didn’t upgrade right away, because it took awhile for the linux version to come out. I can happily say that Picasa 3 works great under linux from my experience. It was easy to install (they had an rpm available), and it runs very nicely. It seems like it even runs a bit faster than Picasa 2.6. But best of all, it has some really cool new features. One such feature is the ability to make collages. There was some rudimentary collage-making features in Picasa 2, but Picasa 3 adds lots of functionality. I decided to try it out recently with some pictures I took at Thanksgiving. I would say that my only complaint so far is that captions only seem to show up when you format the pictures as “polaroids”. It seems to be that if you include a white border, the caption should show up there. This was particularly frustrating because I had “show captions” box checked, but no captions were showing up.
I’ll also admit that part of the reason I wanted to write this post was because I just learned about mediarss, which is a way to include images, sound clips, and video clips in rss feeds. A quick google search for a wordpress plugin resulted in the media rss wordpress plugin, which seems to be working. Now the only other question is whether or not it correctly shows up in my friendfeed.
Tags: collage, mediarss, picasa, wordpress
Posted in linux, photography, wordpress | 2 Comments »
Monday, September 15th, 2008
I am currently teaching a course on programming for linguists. We are using python, but for the first few classes, I have been going over some standard UNIX utilities like cd, ls and such, plus using regular expressions with grep and sed. I actually don’t use sed that much. I tend to reach for perl, since I know it better, and it can do pretty much all the same stuff that sed can plus much more. But sed is simpler than perl, and I basically just wanted to use it for doing substitutions.
Today I got an e-mail from a student asking why the following did not seem to be working:
echo abcd123 | sed 's/\([a-z]*\).*/\U\1/'
The student reported the following output: “Uabcd”. (The expected output is “ABCD”, which is what I get on Linux)
I tried it, and it worked fine for me. Then I thought: maybe this is a Mac/Linux problem. Sure enough, when I look at the man page for my Fedora 7 box, it tells me that my version of sed is GNU 4.1.5, from June 2006. Mac Leopard (10.5) is using BSD sed from July 2004. Leopard came out in 2007, as did Fedora 7. Why is it 2 years behind? Why is it still using python 2.4? Why doesn’t it come with useful utilities like dos2unix? Mac has done a great job of making a nice GUI, with some pretty cool applications like iLife. It is falling behind when it comes to the command line utilities though.
Tags: perl, python, sed, unix
Posted in linguistics, linux, mac osx, perl | 1 Comment »
Wednesday, September 3rd, 2008
I finally figured out this thorny issue I have been dealing with for the last hour. In perl, if I can create a character class like “[\[\]a-f]” which matches any characters a-f, [, and ]. This does not work in grep or sed though. I finally discovered that the right bracket “]” should not be escaped in grep or sed. I don’t really understand why. Perl will let you do it either way.
You know what they say: “knowing is half the battle.”
Tags: grep, regular expressions, sed
Posted in linux | No Comments »