Extracting Video Frames and Overlaying Text

The avconv incantation required to put text on frames extracted from a video file looks like this (it’s all on one line, so you’ll need some side scrolling action):

avconv -ss 00:11:47 -i /mnt/backup/Video/2014-09-08/MAH00070.MP4 -t 1 -f image2 -q 1 -vf "drawtext=fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf : text='2014-09-08 10\:58\:47' : fontcolor=white : fontsize=60 : box=1 : boxcolor=black@0.7 : x=1200 : y=30" MAH00070-001147-%03d.jpg

That’s applying some hints to the rather succinct drawtext doc.

The -ss 00:11:47 sets the starting time relative to the beginning of the file, so it’s an offset that, when added to the file start time in the Exif metadata, produces the actual time-of-day. The extracted frames begin at the closest “seek point”, which I presume will be pretty close to the specified second. The -accurate_seek option may be relevant. Verifying all that could be tricky.

The -t 1 specifies the duration. Each second produces 60 frames, numbered from 001 to 060 in the output filename, as defined by the %03d in the output filename format string.

The -vf "drawtext=" gibberish does the actual text overlay, with all the parameters tucked inside the double quotes.

You must escape all colons in the text string (as '10\:58\:47', note the single quotes), because unescaped colons separate the drawtext options.

The fontsize seems to be in pixels with an upper limit of 72.

The boxcolor rectangle just barely covers the characters; there’s no way to enlarge it just a few more pixels to make a nice frame. The fraction at the end of black@0.7 string produces 70% opacity.

I manually added the actual starting time (10:47) to the offset time for each segment (previewed with vlc), jammed that into the avconv command, and extracted some interesting frames from a recent ride…

I get plenty of clearance while approaching an intersection, which is pleasant:



Absorbed in something on the passenger seat while I’m trackstanding the ‘bent and watching the brake lights:



The turn signal goes on just after acceleration commences:



Because I never pass on the right, I didn’t participate in a classic right hook:



The traffic signal goes yellow as I cross the walk ladder, with the tail of the SUV visible beyond the crosswalk on the right. The green-to-yellow transition takes 10 frames = 1/6 second and this image shows the half-intensity point of both incandescent bulbs:



The rest of the ride seemed less eventful.

Frankly, that’s way too much handwork for the results in the upper-right corner. I think a better way starts with extracting unannotated frames from the video, then slapping timestamps on them using ImageMagick, calculating and feeding it the appropriate values for each frame.

Putting the annotation up in the sky seems better than near the bottom corners, if only because images of the pavement might actually be useful. The timestamp needs the frame number and I think splitting it into two shorter sections (date and time) in the left and right upper corners might work better.

About these ads

Leave a comment

Monthly Image: Hummingbird!

Mary grows Scarlet Runner Beans with vivid red flowers specifically for the Ruby Throated hummingbirds that frequent the back yard:

Hummingbird with Scarlet Runner Bean flowers

Hummingbird with Scarlet Runner Bean flowers

This female perched quite a while on that tendril while sticking her tongue out; it looks like a length of monofilament fishing line. The male also feeds on those flowers, although I’ve never seen him perch anywhere for more than a few seconds.

We wish them success in raising their chicks!

Hand-held with the Canon SX-230HS zoomed all the way in, then ruthlessly cropped.

Leave a comment

StaticCider Sighting

We took a river cruise from Hudson NY on the first day of the Cycling the Hudson Valley ride and, being that type of guy, I spotted this redecorated rail car on the east shore of the Hudson River:

StaticCider railcar tag sighting - Hudson NY

StaticCider railcar tag sighting – Hudson NY

Feeding the obvious search term into the obvious search engine produced two other sightings in Minnesota during 2011. Puts one in mind of Where’s George

Mad props: unlike most taggers, he / she painted around the car number and ID patterns.


Cellular Toad II

It seems toads really like the plant cell packs that Mary uses to start her garden veggies:

Cellular Toad - in cell pack

Cellular Toad – in cell pack

The garden isn’t quite as snug, but the camouflage works much better:

Cellular Toad - in garden

Cellular Toad – in garden

It’s been a dry year and we haven’t seen many toads or slugs around the house.

Leave a comment

Dell Optiplex GX270 Power Control PCB Connections

The general idea is to gut an old Dell Optiplex GX270 and stuff the high-voltage parts of the sewing machine controller inside a well constructed and solidly grounded metal shield inside a not-too-ugly plastic box. It’d be nice to reuse the power control button and status LEDs on the front panel…

The few parts on the front of the through-hole board:

Dell Power Button PCB - component

Dell Power Button PCB – component

The copper side, with annotations:

Dell Power Button PCB - copper

Dell Power Button PCB – copper

The red tracer on the ribbon cable goes to Pin 1, which is a blind key on the PCB.

The LEDs do not have ballast resistors, so those must go on a circuit board somewhere else.

The connections:

16 14 12 10 8 6 4 2
Gnd nc nc nc nc HD+ HD- Button+
Gnd nc Gnd Pwr Y+ Gnd Pwr G+ Gnd Key
15 13 11 9 7 5 3 1



Invisible Asterisk: Except Cops

The signs at every Dutchess Rail Trail grade crossing and access point seem unambiguous:

DCRT - No Motor Vehicles

DCRT – No Motor Vehicles

More specific signs appear at random intervals along the trail:

DCRT - All Terrain Vehicles Prohibited

DCRT – All Terrain Vehicles Prohibited

You can’t see it, but every sign includes an invisible asterisk introducing the invisible clause “Except Cops”:

DCRT - Sheriff ATV Convoy

DCRT – Sheriff ATV Convoy

Back when the Dutchess County deputy sheriffs rode huge ATVs that occupied nearly the entire paved trail and bulldozed everybody out of their way, I had the temerity to ask why they weren’t riding bikes. The deputy sheriff told me, rather condescendingly, that they had to be prepared for anything and that there had already been incidents.

These little ATVs aren’t quite so imposing and, more likely, also fit on the new bridges and between the bollards, which may explain everything.

I’ve seen what might be their best use case, although ambulances can attract your attention without an ATV escort:

DCRT - Sheriff ATV Leading Ambulance

DCRT – Sheriff ATV Leading Ambulance

Straight up, I have no objection to police patrols on the rail trail.

do object to the official mindset that simply adds an invisible exception to any inconvenient rule.

As I see it, the root cause of the militarized police and extralegal government activities we’ve seen across the country in recent years boils down to “That law / regulation / rule does not apply to us, because we are the government.”

I can ride the length of the DCRT and back in about two hours, averaging 12 mph, without getting particularly sweaty in the process; the track in that link shows a three hour ride that includes the HVRT and a Walkway scrum, plus the ride from and to home. A police ATV can’t go much faster than that on the trail, even with lights and sirens, because oblivious pedestrians keep getting in the way.

If an officer on a bike can’t keep up with me, then something has gone badly wrong with the job requirements for becoming a deputy sheriff.

As far as “being prepared for anything” goes, the cargo capacity of those little ATVs rules out a bunch of hardware that fit in the big ones: anything seems an elastic concept. A bike can carry enough equipment for many incidents; my tool kit weighs more than some bike frames, the packs have plenty of room to spare, and there’s always the trailer option. I doubt genuine Mil-Spec assault rifles would come in handy on the rail trail.

It’s also not clear why an officer on a bike can’t call for the same backup as an officer on an ATV: those buggies lack fancy VHF antennas, so they’re using a hand-held radio or phone. The 5 W amateur radio on my bike, through a mobile VHF antenna on a crappy ground system, can easily reach local amateur radio repeaters and APRS nodes. Many pedestrians seem absorbed with their phones, so getting microwaves into and out of the trail doesn’t pose much of a problem.

Cops-on-bikes present a much less aggressive aspect than cops-on-ATVs who ignore the rules that apply to the rest of us.

They could do it differently, as the department has both bikes and ATVs.



Dis-arming a Steelcase Leap Chair

Steelcase lists the arm rests on their Leap chairs as “factory installed” and not removable, perhaps because the brackets supporting the arms also support the backrest. In the event you must ever remove the arms, perhaps because your wife decides she’d like to try the chair without them, it’s straightforward.

Loosen the Torx screw visible through the slot in the bottom of the plastic shroud about a dozen turns (it will not click or feel loose), use a flat screwdriver to unlock the shroud from of the flat plastic plate on the seat side of the bracket, then forcibly pull the sides of the shroud outward until you can pull the arm extension mechanism up-and-out of these slots in the bracket:

Steelcase Leap - arm bracket

Steelcase Leap – arm bracket

This view from the side of the chair shows the screw hole in the bottom, with a pair of holes for alignment pins beside it:

Steelcase Leap - arm bracket

Steelcase Leap – arm bracket

You can remove the flat plate by pushing the latch at the top center (just below the backrest screw boss), then sliding the plate upward.

As nearly as I can tell, there’s no way to remove the shroud from around the arm extension mechanism, so you must pull off the whole thing in one lump:

Steelcase Leap - arm mechanism

Steelcase Leap – arm mechanism

The two pairs of slots in the edges of the shroud engage tabs on the plastic plate; that’s why you need the flat screwdriver.

The two pins on the bottom lock the arm into the bracket: you must raise it vertically until those come out, after which you can ease the bottom outward until the pins on the sides (which you can’t see inside the shroud) disengage from the bracket slots.

It takes a whole lot more force than seems necessary, but it can be done.

Wrap Gorilla tape around the raw edges until you decide whether it’s worthwhile to design and print a pair of plastic caps to cover the whole bracket.