CamDo Bullet and Blink - How to create a quick Bullet Time Slice or Time Lapse video with FFmpeg

by Dean E January 11, 2017

CamDo Bullet and Blink - How to create a quick Bullet Time Slice or Time Lapse video with FFmpeg

The CamDo Solutions Bullet is a great piece of kit, allowing simultaneous activation of multiple GoPro cameras.

This is most often used by our clients in the creation of ‘Bullet time’, the effect made famous by the Matrix series of movies. This is also known as a Time Slice effect. GoPros are great for creating time slice footage as they have high image quality for the price, which is important, as normally quite a few cameras are required. We have clients who run 30 camera bullet time slice rigs!

To make life simpler for our clients, we explain in this article how to use a simple script and the powerful ffmpeg tool to quickly create a time slice video from a series of stills in a Bullet time rig. This lets you quickly check the alignment of your rig. It can also be used to quickly pull together time lapse movies without having to import it into another piece of software.

As with many powerful tools, ffmpeg can be quite complicated due to the myriad of options.

So we have created some simple batch files / scripts for use in a Windows environment and a Mac environment. This is the perfect companion to our GoPro Autodownload ‘Grab’ software (coming soon!).

The video resolution is downsampled to 1332x1000 pixels to keep file size down and performance snappy (especially for quick initial viewing) but maintaining the width/height ratio of 1.33.

This can be edited in the batch script if you wish (change parameter -s 1332x1000 to your desired resolution) but keep it in the same ratio of 1.33, otherwise the footage will look squashed or stretched. Note the width must be an even number.

For reference, the various photo modes of the GoPro HERO4 camera are as follows:


PIXELS

PHOTO MODE

Width

Height

Ratio

Aspect Ratio

WIDE 12MP

4000

3000

1.33

4:3

WIDE/MEDIUM 7MP

3000

2250

1.33

4:3

MEDIUM 5MP

2560

1920

1.33

4:3


It is interesting to compare this with 720p, 1080p and 4K television resolutions as follows:


PIXELS

TV RESOLUTION

Width

Height

Ratio

Aspect Ratio

SD

720

576

1.25

HD

1280

720

1.78

16:9

FULL HD

1920

1080

1.78

16:9

QUAD HD / GOPRO 4K

3840

2160

1.78

16:9

4K/2K

4096

2160

1.90


Note that native 4K recording is supported by the HERO4 Black at the standard 16:9 aspect ratio.

 


 

The script is as follows, and can be downloaded below. Commentary is provided within the script explaining what is occurring.

For a Windows batch file, line commenting is denoted by a double colon (::) on each line.

To use on Mac, the hash ‘#’ character is used instead.

If you want to brush up on your batch file knowledge, SS64.com is a fantastic resource.

Windows: http://ss64.com/nt/syntax-run.html

Mac: http://ss64.com/osx/syntax-shellscript.html


:: Copyright (C) CamDo Solutions Incorporated 2016
:: Opens a command prompt to create a Bullet time video based on the images in the folder using the powerful FFMPEG tool.
:: 
:: Usage as follows:
:: Relies on the following:
:: 1. Input JPG files numbered in an increasing fashion. Batch file makes a temporary copy to deal with any filenaming anomalies.
:: eg GOPR01750, GOPR01751, etc or PHOTO_01, PHOTO_02, etc are acceptable.
:: 2. ffmpeg.exe must be in the same folder as the images. You must download and install FFmpeg from https://ffmpeg.zeranoe.com/ (static build)
:: 3. Creates a folder with timestamp and moves all images and output video file to that folder.

@ECHO OFF
setlocal enableextensions enabledelayedexpansion
cls

@echo CamDo Solutions Incorporated 2016 - Bullet Time Video Tool
@echo.
@echo Tool relies on the following:
@echo 1. Input JPG files numbered in an increasing fashion. 
@echo eg GOPR01750, GOPR01751, etc or PHOTO_01, PHOTO_02, etc are acceptable.
@echo.
@echo 2. ffmpeg.exe must be in the same folder as the images. 
@echo Please download and install FFmpeg from https://ffmpeg.zeranoe.com/ (static build)
@echo.

:: Check if ffmpeg.exe is present in the folder. If not, exit.

IF NOT EXIST ffmpeg.exe (
  ECHO ffmpeg.exe could not be found.
  ECHO ffmpeg.exe must be in the same folder as the images. 
  ECHO Please download and install FFmpeg from https://ffmpeg.zeranoe.com/ 
  ECHO Note, the file must be called ffmpeg.exe 
  GOTO:error
)

ECHO ffmpeg.exe successfully found.
ECHO.

:: Create a folder to place the images and output video file.
:: Folder created is date and timestamped

:: Use date /t and time /t from the command line to get the format of the date and
:: time; change the substring below to customise as needed.

:: This will create a timestamp like yyyy-mm-dd-hh-mm-ss.
set TIMESTAMP=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%-%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%

:: Create a new directory
md "%TIMESTAMP%"

@echo Folder "%CD%\%TIMESTAMP%" created.
@echo All input images and output video will be placed in this folder.
@echo.
pause

:: Now move all of the files over and make a temp copy into the newly created datestamp folder

SET COUNT=1
SET PREFIX=CamDoTemp
FOR /f "tokens=*" %%G IN ('dir /b *.jpg') DO (call :renum "%%G")
GOTO :encode

:renum
:: Add leading zeroes to COUNT:
SET COUNT1=000!COUNT!
:: Trim to only four digits, from the end
set COUNT1=!COUNT1:~-4!
:: Make a copy temporarily of the file. Files will be deleted at the end. stdout messages suppressed via "> NUL"
copy %1 "%TIMESTAMP%\%PREFIX%_%COUNT1%.jpg" > NUL
move %1 "%TIMESTAMP%" > NUL
set /a count+=1
GOTO :eof

:encode
:: This uses H.264 encodig and scales the images to 1332x1000 resolution.
:: Apple QuickTime only supports YUV planar color space with 4:2:0 chroma subsampling therefore use -vcodec libx264, -pix_fmt yuv420p, 
:: Note on Mac/Linux can use the glob command to specify *.jpg which is more flexible. Still requires numerical sequence.
:: -pattern_type glob -i '*.jpg'

:: each image is displayed for 0.1 seconds. Video also operates at a frame rate of 10 fps.

:: add this for an overlay file 
:: -i ~/path_to_overlay.png -filter_complex "[0:v][1:v] overlay=0:0"
:: ~/path_to_overlay.png is the full/relative path to the overlay image
:: [0:v][1:v] joins the two video streams together, stream 1 is the set of images, stream 2 is the overlay file
:: overlay=0:0 specifies the position of the overlay, in this case the overlay image is assumed to be the same size as the video so no offset is needed. The offset is specified as overlay=x:y where x is the x offset in pixels and y is the y offset in pixels

ffmpeg -framerate 10 -r 10 -f image2 -i "%TIMESTAMP%\CamDoTemp_%%04d.jpg" -i overlay.png -filter_complex "[0:v][1:v] overlay=0:0" -s 1332x1000 -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 CamDoBullet.mp4
move CamDoBullet.mp4 "%TIMESTAMP%"

:: delete the temporary files
cd "%TIMESTAMP%"
del CamDoTemp_*.jpg

ECHO.
ECHO Output Complete, see the newly created CamDoBullet.mp4 file.
ECHO Created in folder: "%CD%"
ECHO.

GOTO:EOF

:error
ECHO.
ECHO Press any key to exit.
PAUSE >nul
GOTO:EOF
end local

How do I use it?

  1. To use the following batch scripts you will need to download the FFmpeg static builds suitable for your environment (32bit or 64bit for Windows) from here:
  1. Create a folder where you can place your images, ffmpeg.exe and the batch file.
  2. Download the CamDo Bullet batch file here.
  3. Place the batch file and FFmpeg.exe in the same folder.
  4. Download your images and also place them in the same folder (images must be sequentially numbered but naming convention does not matter as the script takes care of this). Eg GOPR_0001.jpg, GOPR_0002.jpg will work the same as Shoot1_001.jpg, Shoot1_002.jpg.
  5. Place an overlay.png file with your company logo (or anything else) - this will be overlaid in the top left hand corner. We recommend using a transparent png file.
  6. Run the batch file by double clicking in Explorer or from the terminal (cmd in Windows and bash on a Mac).
  7. Movie file will be created in the same folder called CamDoBullet.mp4.

That’s it. We hope this saves you some time in checking that your footage is appropriately framed.

 

With the release of our new Blink time lapse controller, CamDo will be investigating other scripts to create powerful time lapse effects and other useful functionality. Be sure to look out for our blog posts by signing up to our newsletter here.

If you have a specific request, please let us know and we will do our best to help out!




Dean E
Dean E

Author



Also in Blog

With Recent Solar & Dry Enclosure Improvements, Get Better Long Term Time Lapse Footage
With Recent Solar & Dry Enclosure Improvements, Get Better Long Term Time Lapse Footage

by Terry G January 11, 2017 0 Comments

For our long term time lapse customers, the SOLAR and DRY enclosures are critical products to ensure successful projects. We give you a behind-the-scenes look at the important updates to these products.

Continue Reading

GoPro HERO5 Update for CamDo Solutions
GoPro HERO5 Update for CamDo Solutions

by Kyle K December 21, 2016 0 Comments

We break down the features and functions of the GoPro HERO5 camera -- and what this means for our products in the future.

Continue Reading

CamDo Solutions Holiday Sale: 15% Off Of Everything!
CamDo Solutions Holiday Sale: 15% Off Of Everything!

by Sarah W December 20, 2016 0 Comments

What a year! To wrap things up, we're offering 15% off of everything on www.Cam-Do.com plus free ground shipping on U.S. orders. Just use code XMAS16 at checkout through December 26, 11:59pm.

Continue Reading