This ain’t no Rotoscope

As usual it started with a tweet:

The referenced tweet looked interesting:

I’ve tried Rotoscoping before, but this looked good. I hied over to MacOS/OSX – Paint of Persia community – itch.io, read about it. paid $5 and set things up.

At that point I realise that the app helps you to manually trace frames, seemed a wee bit time consuming. I though I’d leave it for another day. I did start musing on doing something similar, I was thinging FFmpeg & ImageMagick.

Google takes me to Fred’s ImageMagick Scripts: CARTOON.

so the plan is:

  1. export a movie to a series of images.
  2. cartoonise those image
  3. create a move from the cartoon images

Bounus points for getting the sound track back in.

I already have ffmpeg & imagemagick installed on my mac. These are commandline tools.

I downloaded the cartoon script

First find a video:

YouTube downloader tool – Fastesttube!

Rename the downloaded file shower.mp4

Open the terminal and cd into the folder that has the cartoon script and the movie in it.

First extract lots of still images (make a folder shower first mkdir shower):

ffmpeg -i shower.mp4 -r 6 shower/out_%04d.jpg

this takes the input file (-i) at 6 frames per second and create jpg files in the shower folder with the file name out_0001.jpg ,out_0002.jpg ect

Given the movie is 3 minutes 22 seconds long I end up with 1212 images in the folder. I delete the last few manually to give me 1023 images.

I now need to loop through all of those images and create a cartoon version.

the use of cartoon is basically:

./cartoon face.jpg temp.jpg

There are some paramaters you can use but I stuck to the default.

This would take the image on the left and create the one on the right:

face.out

So I move into the shower folder cd shower

mkdir out;for i in *.jpg; do ../cartoon $i out/$i.jpg;done

this script:
makes a nother folder called out

for i in *.jpg for each file with a .jpg extension in the current folder do does:

../cartoon $i out/$i.jpg runs the cartoon script from the folder above (../), and saves the output file in the out folder with the same name.

When I kicked this off I quickly realised it would take a while to r=un through 1212 images, so went to bed.

The next morning I have 1023 cartoons (I don’t imagine that it took all night).
out_0672

Time to stich these together, it took me a few goes to get the paramaters right. (google helps).

ffmpeg -f image2 -framerate 6 -i out_%04d.jpg -c:v libx264 -pix_fmt yuv420p out.mp4

  1. -f chooses the format image2 which makes an image sequence.
  2. -framerate 6 to get the smae length of movie as I started with
  3. -i infiles confusinging names out_0001.jpg ect the %04d means look for 4 figured numbers starting with 0001
  4. -c codec
  5. -pix_fmt is the pixel format, I dn’t know much about these but the script failed until I added it in

It took me a few shots until I got this right.

I then moved the out.mp4 video to the same folder as the original and

ffmpeg -i shower.mp4 -acodec copy -vn shower-audio.mp4

To extract the audio from the original file.

then:

ffmpeg -i out.mp4 -i shower-audio.mp4 -vcodec copy -acodec copy -shortest final.mp4

To add the audio from the original to the out video to give me a final one.

the -shortest parameter gets rid of the audio at the end to make up for the frames I removed.

Bingo:

At this point I remembered iMovie has a comic filter…

This post is mostly as an aid to my occasional dip into the world of commandline video editing. Posting helps me remember. It also plays a wee bit fast and loose with copyright.

The featured image is a gif giffed from a few of the stills.

ps this is quite a disturbing clip, I didn’t really watch it till I finished, could have picked a nice one!

Update, Ron commented:

What would it look like if you’d run the result videos through the script one more time. Keeping the same number of jpegs but making the lines more stand out and the fills less so you’d have black outlines and white?

That didn’t make much difference os I did some tests with the parameters for cartoon, and Ron went with increasing the brightness: ../cartoon -b 300

This gave me this:

Making some Adjustments

As I had to get up early this morning I though I might make good use of my time. I popped into the Village shop and bought a screwdriver.

I wanted to have a closer look at the TV in my accommodation after last night’s blip.

I also need to get some more credits and decided on doing a wee bit of audio work. I am still trying to get an understanding of The Village by looking under the bonnet.

I had already taken a bit of audio from on of the surveillance tapes:

I ran it through the reverse filter in audacity:

Which was interesting and make some sort of sense if you are in a hypnagogia state. But it required further investigation. I found some instructions which lead to a new tool to add to my toolbox. PaulStretch is quite fascinating, and after spending quite some time testing the settings I fell back on the basic preset:

 

Feeding this into some video footage from the archives:

Tells us quite a lot about the state of Rover’s mind, or perhaps his master’s?

Some information

Movie clips extracted with MPEGStreamclip from video taken from dvd with HandBrake.

Movie clips concatenated with ffmpeg.

Slowed down with ffmpeg:
ffmpeg -i rovercon.mov -filter:v "setpts=4.0*PTS" rovercon.mp4
Which turned into mp4 too

Added the stretched audio:

ffmpeg -i rovercon.mp4 -i the-prisoner-backwards-strech.mp3 -map 0:0 -map 1:0   -shortest rovercon-audio.mp4

I am finding ffmpeg interesting as you can try different variations out quickly.

Rover normally seems to be a cold mechanical creature, this view suggests something deeper, organic perhaps, hints of ancient chants and secrets. Perhaps the Village is not as rational as we think.

 

 

Character Cutting

So Burtus was on my case pretty fast last week, trying to get a fix on me. I guess I didn’t drop enough clues. The deal was I should reveal some history, some of my favorite places, that might have given her a clue. For the folk less agile that Burtus, I’ll spell it out. I’ve been down south where the sky ain’t sentimental. I ran into a bit of bother, nothing I couldn’t handle.

Anyhow I was intrigued enough to listen to the second message on my machine. When you have more than one client things can get tricky, and this is tricky times four.

This week Groom seems to be sucking up to Burtus big time.

I saw a couple of Burtus other performances too (here and here). She is trying to come over cashmere, soften the message a bit, but she is still all steel. Wants everything her way, reports for Sunday night.

All 4 of the clients are demanding, well they can keep that up, I’ll steer my own course through this business.

Another familiar face showed up here last week. Quite a character for such a sweet face. Worth keeping you eye on Tina if you are in this game.

So, among this week’s unreasonable demands was instructions to dig into some character. I started leafing through some old cases. I got interested in Frank Bigelow, but that turned into a wild goose chase.

The Words and pictures just didn’t line up. I dived back into the files. I was looking for words and pictures at the right time and struck gold:

You can tell a lot about a character from watching others talk about them. These guys are pieces of work.

Supercut note: srt files don’t always line up with the video. I tried a couple of apps to adjust and match srts I downloaded to go with D.O.A. They didn’t work. SubShifter – Online SRT Subtitle Resync Tool looks promising for another time.

#DS106 Flickr Daily Creates Pummelvision style

I’ve been playing around with downloading groups of flickr photos and making very quick videos from them. Just blogged some of the process over on my main blog. Being a wee obsessive about this sort of stuff, I’ve created a script that will download all my photos with a particular tag, say dailycreate, and string them together into a movie.

You need to have the commandline ffmpeg application installed and have created a flickr app so that you have an api key. You need to know your flickr id too.

This works for me, copy the code below, replace the bold bits and paste into the terminal. Probably best to run this in a folder. Depending on how many photos you have it cold take a while.
FILELIST=$(curl 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=YOUR-FLICKER-APIKEY&user_id=YOUR-FLICKr_USERNAME&tags=THE-TAG&extras=url_l&per_page=200&format=rest' | sed -ne 's/.*\(http[^"]*\).*/\1/p');echo $FILELIST;for i in $FILELIST ; do curl -O $i ; done;a=1;for i in *.jpg; do
new=$(printf "%04d.jpg" "$a") #04 pad to length of 4
mv -- "$i" "$new"
let a=a+1
done;sips --resampleHeight 768 *.jpg;sips --padToHeightWidth 786 1024 *.jpg;ffmpeg -f image2 -i %04d.jpg -c:v libx264 -pix_fmt yuv420p firstmov.mp4;ffmpeg -i firstmov.mp4 -filter:v "setpts=4.0*PTS" flickr-dailycreate.mp4

This wee bit:

ffmpeg -i flickr-dailycreate.mp4 -i backgroundloop.mp3 -map 0 -map 1 -codec copy -codec:a aac -strict experimental -b:a 192k -shortest flickr-dailycreate-audio.mp4

would add some audio if there is a backgroundloop.mp3 in the same folder.

Schooling the Wire

Three SuperCut videos from season 4 of the wire on the words, school, schooled and schooling after a prompt from Jim Groom. Made with videogrep.py

I was surprised at how few times schooled or schooling were used.

Supercut videos are a nice way of looking at this sort of stuff but you can get a quick idea of the use of words by finding them in the subtitle (.srt) files.

For example I downloaded season 4 subtitles from The Wire S04(Season 4) english subtitles – TVsubs.net. This gives several versions of the files. I found before that the DVDRip.TOPAZ.en.srt ones work best for me. I’ve put them in the same folder as my wire episodes and renamed them to match these files.

I open the terminal and type cd then drag the folder from the finder into the terminal window and hit return. This moves me into the folder.

I then grep -e 'school ' *.srt which outputs a list of the episodes with school in the subtitles and the line:

The Wire Season 4 Episode 01 - Boys of Summer.srt:for some back-to-school stuff.
The Wire Season 4 Episode 01 - Boys of Summer.srt:back-to-school stuff for?
The Wire Season 4 Episode 01 - Boys of Summer.srt:When school start, I'll be selling it
The Wire Season 4 Episode 02 - Soft Eyes.srt:for your school clothes,
The Wire Season 4 Episode 02 - Soft Eyes.srt:your school shit, man.
The Wire Season 4 Episode 02 - Soft Eyes.srt:I can't wait until school starts.
The Wire Season 4 Episode 02 - Soft Eyes.srt:of school coming up, right?
The Wire Season 4 Episode 02 - Soft Eyes.srt:- Y'all need school clothes and shit?
The Wire Season 4 Episode 02 - Soft Eyes.srt:to buy school clothes with.
The Wire Season 4 Episode 02 - Soft Eyes.srt:to school some.
The Wire Season 4 Episode 02 - Soft Eyes.srt:to that school lookin'
The Wire Season 4 Episode 03 - Home Rooms.srt:do you want to go to school for?
The Wire Season 4 Episode 04 - Refugees.srt:For school or out the business,
The Wire Season 4 Episode 04 - Refugees.srt:to start out a school year,
The Wire Season 4 Episode 04 - Refugees.srt:school on Friday,
The Wire Season 4 Episode 04 - Refugees.srt:school you, brother.
The Wire Season 4 Episode 05 - Alliances.srt:ain't in school tomorrow morning,
The Wire Season 4 Episode 05 - Alliances.srt:take him in, school him,
The Wire Season 4 Episode 06 - Margin of Error.srt:- High-school biology.
The Wire Season 4 Episode 06 - Margin of Error.srt:Ain't no school today.
The Wire Season 4 Episode 07 - Unto Others.srt:Does the school have
The Wire Season 4 Episode 07 - Unto Others.srt:creep out of school after lunch.
The Wire Season 4 Episode 07 - Unto Others.srt:He's got to be at school in the morning.
The Wire Season 4 Episode 08 - Corner Boys.srt:the word around school is
The Wire Season 4 Episode 08 - Corner Boys.srt:the school or not.
The Wire Season 4 Episode 09 - Know Your Place.srt:after school lets out--
The Wire Season 4 Episode 09 - Know Your Place.srt:to the school social worker.
The Wire Season 4 Episode 10 - Misgivings.srt:I'll get the school police.
The Wire Season 4 Episode 10 - Misgivings.srt:of the school year,
The Wire Season 4 Episode 11 - A New Day.srt:front of the school today,
The Wire Season 4 Episode 11 - A New Day.srt:at school 45,
The Wire Season 4 Episode 11 - A New Day.srt:school 52, and school 58
The Wire Season 4 Episode 11 - A New Day.srt:- The school audit.
The Wire Season 4 Episode 12 - That's Got His Own.srt:when I look at the school budget.
The Wire Season 4 Episode 12 - That's Got His Own.srt:for the school budget.
The Wire Season 4 Episode 12 - That's Got His Own.srt:with the school board itself.
The Wire Season 4 Episode 12 - That's Got His Own.srt:is on the school system.
The Wire Season 4 Episode 12 - That's Got His Own.srt:As president of the school board,
The Wire Season 4 Episode 12 - That's Got His Own.srt:not the school board,
The Wire Season 4 Episode 12 - That's Got His Own.srt:- to go see the school superintendent.
The Wire Season 4 Episode 12 - That's Got His Own.srt:the Baltimore school system's
The Wire Season 4 Episode 12 - That's Got His Own.srt:middle school no more.
The Wire Season 4 Episode 12 - That's Got His Own.srt:no school closures.
The Wire Season 4 Episode 12 - That's Got His Own.srt:over the school board
The Wire Season 4 Episode 13 - Final Grades.srt:It knocks the school deficit
The Wire Season 4 Episode 13 - Final Grades.srt:your school system."
The Wire Season 4 Episode 13 - Final Grades.srt:I went to school here

Where as schooling:


01 - Boys of Summer.srt:So... he was schooling me.
07 - Unto Others.srt:Don't be schooling us now.
08 - Corner Boys.srt:we schooling them.

Only has 3 mentions as does schooled


01 - Boys of Summer.srt:You laughing. I've been schooled, dog.
09 - Know Your Place.srt:You schooled me good.
10 - Misgivings.srt:- You schooled them well.

If you just want the number of mentions:
grep -e 'school ' *.srt | wc -l
outputs 45.

I am sure lots of ds106 students can thing of some other useful and interesting ways to use this.