How to make a video clip with avconv / ffmpeg

The following commandline will make a 30 second clip in output.avi, from the file input.avi starting at 2 mins 25.5 seconds:

avconv -i input.avi -ss 00:02:25.500 -t 30 -codec copy output.avi

ffmpeg takes the same arguments if you have that (avconv is just the newer name for ffmpeg)
The -codec copy is important, and should be used as long as you are using the same output and input file type. Without it, the video will be decoded and re-encoded, which may cause a dramatic loss in quality.

I got a lot of warnings about renumbering frames or somesuch, but the output file worked fine.

A better, faster way to write a Raspberry Pi SD card image

The standard way of writing an SD card image for a Raspberry Pi (or any other purpose that requires writing a whole disk image to the card) from any unix-like system (eg Linux or Mac OSX) is to use the venerable dd(1) utility.

dd has been around, basically unchanged, since the dawn of time. It has an arcane syntax that’s completely different to every other unix command, and its screen output is spectacularly unhelpful. While it’s working, it remains silent. You have no idea how fast it’s going or how long it’s going to take, until it eventually finishes and tells you how many blocks came in and went out – and even that minimal information is presented in a rather obscure format.

On my Mac I found using dd to write a Raspi boot image to an SD card to be very slow and unreliable. For some reason it refused to write to the raw disk device (/dev/rdiskn), even though there were no active mounts. Using the buffered device file instead (/dev/diskn) it took a full 30 minutes to write a 650MB image… and even then, when I pulled the card and put it in my Raspi, somehow it still booted the old OS that was on there before.

Then I discovered a lovely utility called pv, which stands for Pipe Viewer. On a Mac it’s available in Homebrew (brew install pv) and Macports (port install pv).

Using this, instead of dd if=osimage.img of=/dev/diskn (30 minutes, remember), I did pv osimage.img > /dev/rdiskn and it took just over 2 minutes, and the card worked perfectly. (These commands need to run as root, of course).

The other big advantage of pv over dd, is that it shows you what’s going on – it provides a progress bar, data transfer rate, ETA and so on (this is actually its raison d’etre, it just seems to be much more efficient than dd at piping data too) – whereas dd just sits there saying nothing until it’s finished.

pv has a ton of potential uses, and is a shining example of the strength of the UNIX philosophy: a small program that does one thing and does it well, interconnecting with other programs in a standard way to make them better. I don’t know how long it’s been around, but I love the fact that even after 20 years of using Linux I can still stumble upon something new and neat that I know will immediately become a well-used part of my toolkit and make life easier. And I have to laugh, because I’ve just found out it was written by Andrew Wood, an old friend from years ago. Looks like it’s been around for quite a while, and is still being actively maintained. Kudos.

Links

* Wherever you see n in this article, you’ll need to replace it with the appropriate number for the SD card on your system. On my Macbook Pro it’s 2, but your system may be different, and if you get it wrong, you could overwrite a critical system disk. My first ever big data loss event back in 1994 was caused by an error like this, which is why I’ve not put the number in above, I wouldn’t want anyone to blindly copy&paste – find out the correct number for your system, double, triple and quadruple check the commandline before you hit enter, take backups and take care!

M-Audio Xponent Woe – an update

You may have read my generally glowing review of the M-Audio Xponent. I’ve been meaning to update you all with some important news on that front. After I wrote the review, my Xponent developed a fault. I’d had it less than a month, and it had had only fairly light use, maybe 8-10 hours total.

One of the audio channels started cutting out (on both Main and Booth out). Started as just a bit of distortion, then it was really quiet and badly distorted, then it cut out completely. The headphone channel wasn’t affected.

I surmised that this was a bad electrical connection. To test this theory, I did what any self-respecting techie would do: gave it a whack (well, a gentle tap on the side, and then lifting the right-hand side of the unit by about an inch and letting it drop). That did the trick: the sound cut back in, diagnosis confirmed.

Obviously I was mortified that the unit should have such a trivial manufacturing fault (it wasn’t the only one either… I’d already started to uncover some much more subtle and minor problems, like one of the pots being centred at controller value 66 rather than 64). So it was sent back to DV. A month later, repairs were still not done and there was no ETA, so after some argument and quoting of the Sale of Goods Act, DV graciously agreed to a refund.

All of that prompted a reassessment of what I was aiming for with DJing, and whether computer-based mixing would really work for me even if I got a fully working Xponent. Was I happy to be staring at a monitor to mix? No, I do that all day for my day job. Could I imagine taking a laptop and console out to a club every time I play out? No, I’d just worry about it getting nicked, broken, and the hassle of setting it up. Was I content with the quality? Sort of, but in my heart I knew it wasn’t ever going to be as good as a pro quality mixer. If I’m serious about DJing, I might as well do it on the equipment that is already there in every club the length and breadth of the land.

So I decided to invest in Pioneer CDJ1000s and a new mixer after all. That has definitely turned out to be the right choice for me. I’m having a lot more fun now than I was doing it on the computer, and getting professional-quality results that I don’t think I’d have got from the Xponent. All at much higher cost, of course, so it comes down to considering it as an investment rather than an expense. I’m glad I tried out the computer mixing option first, and did it with a console that (manufacturing defects aside), can seriously claim to be the best or one of the best out there. That left me in no doubt that I needed to pursue a different approach, rather than just a different console.