ZigZag Volvo

While driving through New York on my way to the Watkins Glen 2017 opening weekend, I encountered a nut in a Volvo zig-zagging through highway traffic. I decided use ffmpeg yet again (I’m starting to wonder if OpenShot would actually bring anything to the table at this point, besides crashing)

Plan

I want a video with the rear camera until the Volvo passes, then the front camera after. I want to use the front audio for the whole video.

Sync

Luckily, the front & rear videos were synced to within a fraction of a second. Close enough.

Trim

Rear video, starting at 2:40, ending at 4:24, when the car passes me.

ffmpeg -i ../Speedy_Gonzales-Rear.MOV -ss 2:40 -to 4:24 -c copy Rear.trim.MOV

Front video, starting at 2:40, but ending at 4:57, when I want the video to end

ffmpeg -i ../Speedy_Gonzales-Front.MOV -ss 2:40 -to 4:57 -c copy Front.trim.MOV

Combine

This was pretty easy. I used an overlay as usual, but didn’t perform the scaling. I also instructed the overlay filter to continue with the original video when complete:

time ffmpeg -i Front.trim.1080.MOV -i Rear.trim.MOV -filter_complex "overlay=0:0:pass" -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart Combined-FrontAudio.mp4

You’ll note I’m using the same ffmpeg voodoo I used last time to help youtube processing time.

I was expecting to have to remove the rear audio, but interestingly enough, it was gone already. I suspect the overlay filter killed it? No idea, actually.

Crop

Except not so fast! I had acidentally recorded both videos at different resolutions. The rear was doing 1920x1080, while the front was 2560x1080. This causes weird video like this:

“htop screenshot”

Additionally, while 2560x1080 looks great to me (I have an ultrawide monitor), it letterboxes on a standard 1920x1080 display. Additionally, youtube adds that letterboxing during their processing, so watching my own 2560 video on youtube gets black bars on all four sides. Lovely. So I need to crop the video as well:

time ffmpeg -i Front.trim.MOV -i Rear.trim.MOV -filter_complex "overlay=0:0:pass,crop=1920:1080:0:0" -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart -to 10 Combined-FrontAudio.mp4

I’m fine with keeping the left of the front frame, as it looks “good enough”. If I wasn’t, I’d have had to have adjusted the overlay offset, as well as the crop offset.

Just as a note, I fixed the resolution (and removed the datestamp from the rear camera) before I hit the track on Saturday. So I didn’t have to the cropping for the videos I put on youtube earlier (but filmed chronologically after).

CPU takes it easy

My CPU seems to be taking it easy today. Maybe its upset I made it work on Easter? Or this task just didn’t parallelize as well.

“htop screenshot”

Done

The finished video turned out as well as I had hoped. I left in the first 90 seconds (despite mostly being a Pringles-related discussion) because, like any traffic video online, there often isn’t enough context. Also, it’s always the cammer’s fault, so I guess more incriminating evidence…