Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

Rolling “Live” Timelapse on Mac using FFmpeg and Amcrest IP Camera

Amcrest UltraHD 5MP POE Bullet IP Security Camera* (Amazon Affiliate)
US: https://amzn.to/39CjeFg
*This camera is similar to the one used in the video.

FFmpeg notes (including FFmpeg install): https://www.rickmakes.com/ffmpeg-notes/

FFmpeg playlist: https://www.youtube.com/playlist?list=PLErU2HjQZ_ZOPDZ71Khzt5PX4X4j6flkg

Amcrest playlist: https://www.youtube.com/playlist?list=PLErU2HjQZ_ZNYE224qh9K0hhaaIxU-rta

Create RAM Disk (Mac only)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
diskutil erasevolume HFS+ "tlramdisk" `hdiutil attach -nomount ram://409600`
diskutil erasevolume HFS+ "tlramdisk" `hdiutil attach -nomount ram://409600`
diskutil erasevolume HFS+ "tlramdisk" `hdiutil attach -nomount ram://409600`

A RAM disk is created to store the images. This reduces wear on the computer’s SSD or hard drive. The RAM disk size is 2048 * megabytes. 409600 is 200MB.

Create Image Download Script
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
nano rollingtimelapse.sh
nano rollingtimelapse.sh
nano rollingtimelapse.sh
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/bin/bash
url=http://username:password@ip_address/cgi-bin/snapshot.cgi
fps=60
tl_length=5
image_count=$((fps*tl_length))
function download_image {
# This loops until an image is saved as temp. This prevents the saving of empty image files. "temp" purposefully doesn't have an extension so it doesn't get picked up by ffmpeg.
until [ -s "temp" ]
do
curl --digest -o "temp" $url
done
# "temp" is renamed to the current file
mv "temp" $1
echo $1
}
# Download image once and copy it image_count number of times to preload the image set
download_image `printf "%003d.jpg" 1`
for ((i=1; i<=image_count; i++)); do
cp -v `printf "%003d.jpg" 1` `printf "%003d.jpg" $i`
done
# Continually download images in a loop
#initialsize the image_number
image_number=1
while :
do
# Reset image number when it is greater than image count
if [ $image_number -gt $image_count ]
then
image_number=1
fi
# current_file is padded with 2 zeros to help with ordering in file system
current_file=`printf "%003d.jpg" $image_number`
download_image $current_file;
image_number=$((image_number+1))
sleep $tl_length
done
#!/bin/bash url=http://username:password@ip_address/cgi-bin/snapshot.cgi fps=60 tl_length=5 image_count=$((fps*tl_length)) function download_image { # This loops until an image is saved as temp. This prevents the saving of empty image files. "temp" purposefully doesn't have an extension so it doesn't get picked up by ffmpeg. until [ -s "temp" ] do curl --digest -o "temp" $url done # "temp" is renamed to the current file mv "temp" $1 echo $1 } # Download image once and copy it image_count number of times to preload the image set download_image `printf "%003d.jpg" 1` for ((i=1; i<=image_count; i++)); do cp -v `printf "%003d.jpg" 1` `printf "%003d.jpg" $i` done # Continually download images in a loop #initialsize the image_number image_number=1 while : do # Reset image number when it is greater than image count if [ $image_number -gt $image_count ] then image_number=1 fi # current_file is padded with 2 zeros to help with ordering in file system current_file=`printf "%003d.jpg" $image_number` download_image $current_file; image_number=$((image_number+1)) sleep $tl_length done
#!/bin/bash

url=http://username:password@ip_address/cgi-bin/snapshot.cgi

fps=60
tl_length=5
image_count=$((fps*tl_length))

function download_image {
    # This loops until an image is saved as temp. This prevents the saving of empty image files. "temp" purposefully doesn't have an extension so it doesn't get picked up by ffmpeg.

    until [ -s "temp" ]
    do
        curl --digest -o "temp" $url
    done

    # "temp" is renamed to the current file

    mv "temp" $1
    echo $1
}

# Download image once and copy it image_count number of times to preload the image set

download_image `printf "%003d.jpg" 1`

for ((i=1; i<=image_count; i++)); do
    cp -v `printf "%003d.jpg" 1` `printf "%003d.jpg" $i`
done

# Continually download images in a loop

#initialsize the image_number

image_number=1

while :
do
    # Reset image number when it is greater than image count

    if [ $image_number -gt $image_count ]
    then
        image_number=1
    fi

    # current_file is padded with 2 zeros to help with ordering in file system

    current_file=`printf "%003d.jpg" $image_number`

    download_image $current_file;

    image_number=$((image_number+1))

    sleep $tl_length

done

Type control-o to save control-x to exit.

Make Script Executable
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
chmod +x rollingtimelapse.sh
chmod +x rollingtimelapse.sh
chmod +x rollingtimelapse.sh
View Video without Re-encoding (mjpeg)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -c:v copy -b:v 10000k -r 60 -f mjpeg pipe:1|ffplay -i pipe:0
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -c:v copy -b:v 10000k -r 60 -f mjpeg pipe:1|ffplay -i pipe:0
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -c:v copy -b:v 10000k -r 60 -f mjpeg pipe:1|ffplay -i pipe:0
Play video and resize on the fly
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -vf crop=in_w:in_w*9/16,scale=1920:1080,fps=fps=60 -c:v h264_videotoolbox -b:v 10000k -r 60 -pix_fmt yuv420p -f flv pipe:1|ffplay -i pipe:0
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -vf crop=in_w:in_w*9/16,scale=1920:1080,fps=fps=60 -c:v h264_videotoolbox -b:v 10000k -r 60 -pix_fmt yuv420p -f flv pipe:1|ffplay -i pipe:0
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -vf crop=in_w:in_w*9/16,scale=1920:1080,fps=fps=60 -c:v h264_videotoolbox -b:v 10000k -r 60 -pix_fmt yuv420p -f flv pipe:1|ffplay -i pipe:0
Play Video without Resizing
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -vf fps=fps=60 -c:v h264_videotoolbox -b:v 10000k -r 60 -pix_fmt yuv420p -f flv pipe:1|ffplay -i pipe:0
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -vf fps=fps=60 -c:v h264_videotoolbox -b:v 10000k -r 60 -pix_fmt yuv420p -f flv pipe:1|ffplay -i pipe:0
ffmpeg -framerate 60 -f image2 -stream_loop -1 -pattern_type glob -i '*.jpg' -vf fps=fps=60 -c:v h264_videotoolbox -b:v 10000k -r 60 -pix_fmt yuv420p -f flv pipe:1|ffplay -i pipe:0

If you aren’t using an Intel Mac, you can use “libx264” in place of “h264_videotoolbox”.

Leave a comment

Your email address will not be published. Required fields are marked *