Tour des Châteaux

a tour of the castles

Jul 31, 2013    #mencoder   #mlug   #projects   #talks   #tour-de-france   #vuelta-a-espana  

This is a re-packaging and a light re-edit of an updated talk I produced for MLUG back in 2013 to try and extract the more interesting non-racing portions of the broadcast.

This is presented as a historical look at what I was doing at the time but not particularly relevant today as much of the technique described here is superceded.

Tour des Châteaux/Torres de Castellos

Automated filtering of Tour de France and Vuelta a España footage with Linux

Background

Tour de France

A multiple stage bicycle race primarily held in France, while also occasionally making passes through nearby countries. First organized in 1903 to increase paper sales for the magazine L’Auto, it has been held annually since its first edition in 1903 except for two World Wars. As the Tour gained popularity it has lengthened to 21 days and its reach has extended around the globe. Participation has expanded from a primarily French field, as riders from all over the world began to take part. (thanks wikipedia)

Vuelta a España

An annual multiple stage bicycle race primarily held in Spain, while also occasionally making passes through nearby countries. Inspired by the success of the Giro d’Italia and the Tour de France, the race was first organized in 1935. The race was prevented from being run by the Spanish Civil War and World War II in the early years of its existence; however, the race has been held annually since 1955. (thanks wikipedia)

Broadcasting

Tour de France

French broadcasters France 2 and 3 organise the Tour broadcast with equipment including:

Vuelta a España

Sadly, Wikipedia has next to no information on this, but we presume very similar requirements:

Impressions

Overall

Minor annoyances

Major annoyances

Items of interest

helicopter shots

Most interesting shots of scenery or buildings are from the helicopter-mounted cameras

Fast Fourier Transforms 101

Digital Systems tool to convert time-domain signal into frequency-domain signal

“Boring” shot FFT

“Interesting” shot FFT

Prototype processing method

Image processing

Convolution 101

sample input

A variety of different shapes - we’re looking for circles of a particular size

sample mask

Here is the convolution mask we’re going to use

convolution output

After running the mask across the image, the bright points indicate where the process found the circles we were after

output overlaid

We see that the bright points from the output match perfectly with the circles in the input image

Workflow

boring shot

interesting shot

histogram

A check to confirm that relying on pixel brightness is a good proxy for whether there is tone or not

brightness tone no_tone
0 59 863
1 0 9
2 0 4
3 0 7
4 0 6
5 1 2
: : :
: : :
250 1 2
251 2 2
252 2 1
253 0 2
254 0 2
255 1712 390

categorisation

How long is a good period to chunk audio into?

Commands

dumping audio

mplayer quiet dumpaudio dumpfile /dev/stdout source.mpg |
mp3splt -Q -k -t 0.7.0 -o @m3@s -d spool -

mpg123 -qw chunk.wav chunk.mp3

tone scanning

sndfilespectrogram noborder chunk.wav \
  640 480 /dev/stdout |
pngtopnm |
ppmtopgm |
pnmnorm bpercent 70 |
pnmpad top 31 bottom 31 left 31 right 31 |
pnmconvol mask.pgm |
pnmcut left 31 right 671 top 309 bottom 323 |
ppmhist noheader sort=rgb |
sed ne '/255.*255.*255.*255/!b' e 's/.* //' -ep

convert/extract

mencoder \
  -tskeepbroken \
  -edl extract.edl \
  -of avi \
  -o extract.avi \
  -oac mp3lame \
  -lameopts abr=128 \
  -audiodelay -0.100 \
  -ovc xvid \
  -xvidencopts bitrate=1200:max_bframes=0:vhq=4 \
  -vf scale= 640:352 \
  -aspect 16:9 \
  source.mpg

Final thoughts

Tour de France

Vuelta a España

Accents