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.

FFmpeg Notes

This page is a collection of FFmpeg notes and snippets. It is a work in progress. If you have any questions or suggestions, please leave them in the comments. Last edited 1/22/2021.

Installing FFmpeg (YouTube videos)

Mac (without Macports)
macOS Catalina (without Macports)
Mac (with Macports)
Windows 10
Ubuntu 18.04 LTS

GoPro: convert images to timelapse video (files in multiple folders)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -framerate 30 -pattern_type glob -i "*/*.JPG" -vf crop="in_w:in_w*9/16,scale=1920:1080" -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
ffmpeg -framerate 30 -pattern_type glob -i "*/*.JPG" -vf crop="in_w:in_w*9/16,scale=1920:1080" -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
ffmpeg -framerate 30 -pattern_type glob -i "*/*.JPG" -vf crop="in_w:in_w*9/16,scale=1920:1080" -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
GoPro: convert images to timelapse video (files in single folder)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -framerate 30 -pattern_type glob -i "*.JPG" -vf "crop=in_w:in_w*9/16,scale=1920:1080" -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
ffmpeg -framerate 30 -pattern_type glob -i "*.JPG" -vf "crop=in_w:in_w*9/16,scale=1920:1080" -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
ffmpeg -framerate 30 -pattern_type glob -i "*.JPG" -vf "crop=in_w:in_w*9/16,scale=1920:1080" -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

Related Video

Create Shortcut to Amcrest IP Camera
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/bin/bash
ffplay "rtsp://{username}:{password}@{ip_address}:554/cam/realmonitor?channel=1&subtype=0";
exit;
#!/bin/bash ffplay "rtsp://{username}:{password}@{ip_address}:554/cam/realmonitor?channel=1&subtype=0"; exit;
#!/bin/bash
ffplay "rtsp://{username}:{password}@{ip_address}:554/cam/realmonitor?channel=1&subtype=0";
exit;

Related Video

Streaming an IP Camera to a Web Browser
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/bin/bash
VIDSOURCE="rtsp://{username}:{password}@{ip_address}:554/cam/realmonitor?channel=1&subtype=0"
AUDIO_OPTS="-c:a aac -b:a 160000 -ac 2"
VIDEO_OPTS="-s 854x480 -c:v libx264 -b:v 800000"
OUTPUT_HLS="-hls_time 10 -hls_list_size 10 -start_number 1"
ffmpeg -i "$VIDSOURCE" -y $AUDIO_OPTS $VIDEO_OPTS $OUTPUT_HLS mystream.m3u8
#!/bin/bash VIDSOURCE="rtsp://{username}:{password}@{ip_address}:554/cam/realmonitor?channel=1&subtype=0" AUDIO_OPTS="-c:a aac -b:a 160000 -ac 2" VIDEO_OPTS="-s 854x480 -c:v libx264 -b:v 800000" OUTPUT_HLS="-hls_time 10 -hls_list_size 10 -start_number 1" ffmpeg -i "$VIDSOURCE" -y $AUDIO_OPTS $VIDEO_OPTS $OUTPUT_HLS mystream.m3u8
#!/bin/bash
VIDSOURCE="rtsp://{username}:{password}@{ip_address}:554/cam/realmonitor?channel=1&subtype=0"
AUDIO_OPTS="-c:a aac -b:a 160000 -ac 2"
VIDEO_OPTS="-s 854x480 -c:v libx264 -b:v 800000"
OUTPUT_HLS="-hls_time 10 -hls_list_size 10 -start_number 1"
ffmpeg -i "$VIDSOURCE" -y $AUDIO_OPTS $VIDEO_OPTS $OUTPUT_HLS mystream.m3u8

Related Video

Streaming Live TV from a HDHomerun to a Web Browser
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/bin/bash
VIDSOURCE="http://ip-address-of-hdhomerun:5004/auto/v11.1?transcode=internet240"
AUDIO_OPTS="-c:a aac -b:a 160000 -ac 2"
VIDEO_OPTS="-vcodec copy"
OUTPUT_HLS="-hls_time 10 -hls_list_size 10 -start_number 1"
ffmpeg -i "$VIDSOURCE" -y $AUDIO_OPTS $VIDEO_OPTS $OUTPUT_HLS mystream.m3u8
#!/bin/bash VIDSOURCE="http://ip-address-of-hdhomerun:5004/auto/v11.1?transcode=internet240" AUDIO_OPTS="-c:a aac -b:a 160000 -ac 2" VIDEO_OPTS="-vcodec copy" OUTPUT_HLS="-hls_time 10 -hls_list_size 10 -start_number 1" ffmpeg -i "$VIDSOURCE" -y $AUDIO_OPTS $VIDEO_OPTS $OUTPUT_HLS mystream.m3u8
#!/bin/bash
VIDSOURCE="http://ip-address-of-hdhomerun:5004/auto/v11.1?transcode=internet240"
AUDIO_OPTS="-c:a aac -b:a 160000 -ac 2"
VIDEO_OPTS="-vcodec copy"
OUTPUT_HLS="-hls_time 10 -hls_list_size 10 -start_number 1"
ffmpeg -i "$VIDSOURCE" -y $AUDIO_OPTS $VIDEO_OPTS $OUTPUT_HLS mystream.m3u8

Related Video

Stream a Mac Screen to a Raspberry Pi
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#This lists audio/video sources on the Mac:
ffmpeg -f avfoundation -list_devices true -i ""
#Run this on the Mac:
ffmpeg -f avfoundation -i "1" -vcodec h264_videotoolbox -realtime 1 -pix_fmt nv12 -b:v 5000k -f mpegts udp://ip_address_of_pi:1234
#Run this on the Raspberry Pi:
omxplayer --timeout 60 ip_address_of_mac:1234
#This lists audio/video sources on the Mac: ffmpeg -f avfoundation -list_devices true -i "" #Run this on the Mac: ffmpeg -f avfoundation -i "1" -vcodec h264_videotoolbox -realtime 1 -pix_fmt nv12 -b:v 5000k -f mpegts udp://ip_address_of_pi:1234 #Run this on the Raspberry Pi: omxplayer --timeout 60 ip_address_of_mac:1234
#This lists audio/video sources on the Mac:
ffmpeg -f avfoundation -list_devices true -i ""

#Run this on the Mac:
ffmpeg -f avfoundation -i "1" -vcodec h264_videotoolbox -realtime 1 -pix_fmt nv12 -b:v 5000k -f mpegts udp://ip_address_of_pi:1234

#Run this on the Raspberry Pi:
omxplayer --timeout 60 ip_address_of_mac:1234

Related Video

Make H.265 File Compatible with Quicktime
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i input.mp4 -codec copy -tag:v hvc1 output.mp4
ffmpeg -i input.mp4 -codec copy -tag:v hvc1 output.mp4
ffmpeg -i input.mp4 -codec copy -tag:v hvc1 output.mp4

Related Video

Pipe ffmpeg to ffplay
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i -f h264 -vcodec libx264 pipe:1|ffplay -i pipe:0
ffmpeg -i -f h264 -vcodec libx264 pipe:1|ffplay -i pipe:0
ffmpeg -i  -f h264 -vcodec libx264 pipe:1|ffplay -i pipe:0

Related Video

Convert JPEG Image Sequence to MKV (with MJPEG encoding)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -framerate 30 -pattern_type glob -i 'timelapse/*.JPG' -codec copy out.mkv
ffmpeg -framerate 30 -pattern_type glob -i 'timelapse/*.JPG' -codec copy out.mkv
ffmpeg -framerate 30 -pattern_type glob -i 'timelapse/*.JPG' -codec copy out.mkv
Convert MKV (with MJPEG encoding) to JPEG Image Sequence
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i out.mkv -vcodec copy timelapse/pic%d.jpg
ffmpeg -i out.mkv -vcodec copy timelapse/pic%d.jpg
ffmpeg -i out.mkv -vcodec copy timelapse/pic%d.jpg
Extract Single JPEG Image from MKV (with MJPEG encoding)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -ss 00:00:00.03 -i out.mkv -vframes 1 -codec copy output.jpg
ffmpeg -ss 00:00:00.03 -i out.mkv -vframes 1 -codec copy output.jpg
ffmpeg -ss 00:00:00.03 -i out.mkv -vframes 1 -codec copy output.jpg

Related Video

Creating an Elapsed Timer
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -f lavfi -i color=c=black:s=240x96 -ss 00:00:00 -t 00:48:00 -vf "drawtext=fontfile=/System/Library/Fonts/Monaco.dfont:text='%{pts\:gmtime\:0\:%M\\\\\:%S}':fontcolor=white:fontsize=64:x=(w-tw)/2:y=(h-th)/2:box=1:boxcolor=green@0.5:boxborderw=10,format=yuv420p" timer.mp4
ffmpeg -f lavfi -i color=c=black:s=240x96 -ss 00:00:00 -t 00:48:00 -vf "drawtext=fontfile=/System/Library/Fonts/Monaco.dfont:text='%{pts\:gmtime\:0\:%M\\\\\:%S}':fontcolor=white:fontsize=64:x=(w-tw)/2:y=(h-th)/2:box=1:boxcolor=green@0.5:boxborderw=10,format=yuv420p" timer.mp4
ffmpeg -f lavfi -i color=c=black:s=240x96 -ss 00:00:00 -t 00:48:00 -vf "drawtext=fontfile=/System/Library/Fonts/Monaco.dfont:text='%{pts\:gmtime\:0\:%M\\\\\:%S}':fontcolor=white:fontsize=64:x=(w-tw)/2:y=(h-th)/2:box=1:boxcolor=green@0.5:boxborderw=10,format=yuv420p" timer.mp4

Related Video

Create Timer with Transparent Background (Apple ProRes codec, prores_ks)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -f lavfi -i color=white@0.0:s=240x96,format=rgba -ss 00:00:00 -t 00:00:30 -vf "drawtext=fontfile=/System/Library/Fonts/Monaco.dfont:text='%{pts\:gmtime\:0\:%M\\\:%S}':fontcolor=white:fontsize=64:x=(w-tw)/2:y=(h-th)/2" -vcodec prores_ks timer_prores.mov
ffmpeg -f lavfi -i color=white@0.0:s=240x96,format=rgba -ss 00:00:00 -t 00:00:30 -vf "drawtext=fontfile=/System/Library/Fonts/Monaco.dfont:text='%{pts\:gmtime\:0\:%M\\\:%S}':fontcolor=white:fontsize=64:x=(w-tw)/2:y=(h-th)/2" -vcodec prores_ks timer_prores.mov
ffmpeg -f lavfi -i color=white@0.0:s=240x96,format=rgba -ss 00:00:00 -t 00:00:30 -vf "drawtext=fontfile=/System/Library/Fonts/Monaco.dfont:text='%{pts\:gmtime\:0\:%M\\\:%S}':fontcolor=white:fontsize=64:x=(w-tw)/2:y=(h-th)/2" -vcodec prores_ks timer_prores.mov

Related Video

Create Scrolling Credits
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffplay -f lavfi -i color=green@0.0:s=1280x720:rate=60,format=rgba -ss 00:00:00 -t 00:01:30 -vf "drawtext=fontfile=/System/Library/Fonts/Supplemental/Impact.ttf:fontsize=60:fontcolor=green:x=(w-text_w)/2+20:y=h-40*t:line_spacing=80:textfile='names.txt'"
ffplay -f lavfi -i color=green@0.0:s=1280x720:rate=60,format=rgba -ss 00:00:00 -t 00:01:30 -vf "drawtext=fontfile=/System/Library/Fonts/Supplemental/Impact.ttf:fontsize=60:fontcolor=green:x=(w-text_w)/2+20:y=h-40*t:line_spacing=80:textfile='names.txt'"
ffplay -f lavfi -i color=green@0.0:s=1280x720:rate=60,format=rgba -ss 00:00:00 -t 00:01:30 -vf "drawtext=fontfile=/System/Library/Fonts/Supplemental/Impact.ttf:fontsize=60:fontcolor=green:x=(w-text_w)/2+20:y=h-40*t:line_spacing=80:textfile='names.txt'"

Note: On Window systems, access the fonts like this: “/Windows/Fonts/arial.ttf”. You can’t use the traditional “C:\Windows\Fonts\arial.ttf” because the colon is a reserved character in the FFmpeg syntax.

Related Video

Add Background Image to an Audio File
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -loop 1 -f image2 -i airplane.jpg -i train_whistle_audio.aac -vf crop=in_w:in_w*9/16,scale=1920:1080,fps=fps=30 -pix_fmt yuv420p -vcodec libx264 -shortest train_whistle_airplane.mp4
ffmpeg -loop 1 -f image2 -i airplane.jpg -i train_whistle_audio.aac -vf crop=in_w:in_w*9/16,scale=1920:1080,fps=fps=30 -pix_fmt yuv420p -vcodec libx264 -shortest train_whistle_airplane.mp4
ffmpeg -loop 1 -f image2 -i airplane.jpg -i train_whistle_audio.aac -vf crop=in_w:in_w*9/16,scale=1920:1080,fps=fps=30 -pix_fmt yuv420p -vcodec libx264 -shortest train_whistle_airplane.mp4
Add Solid Color Background to an Audio File
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i train_whistle_audio.m4a -f lavfi -i color=c=blue:s=640x480:r=15 -acodec copy -shortest train_whistle_blue_background.mp4
ffmpeg -i train_whistle_audio.m4a -f lavfi -i color=c=blue:s=640x480:r=15 -acodec copy -shortest train_whistle_blue_background.mp4
ffmpeg -i train_whistle_audio.m4a -f lavfi -i color=c=blue:s=640x480:r=15 -acodec copy -shortest train_whistle_blue_background.mp4
Extract Audio/Remove Video from a Video File
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i train_whistle.mp4 -vn -acodec copy train_whistle_audio.m4a
ffmpeg -i train_whistle.mp4 -vn -acodec copy train_whistle_audio.m4a
ffmpeg -i train_whistle.mp4 -vn -acodec copy train_whistle_audio.m4a
Extract Video/Remove Audio from a Video File
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i train_whistle.mp4 -vcodec copy -an train_whistle_no_audio.mp4
ffmpeg -i train_whistle.mp4 -vcodec copy -an train_whistle_no_audio.mp4
ffmpeg -i train_whistle.mp4 -vcodec copy -an train_whistle_no_audio.mp4
Add Silent Audio Track to a Video File
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i video_without_audio.mp4 -f lavfi -i anullsrc -vcodec copy -acodec aac -shortest video_with_silence.mp4
ffmpeg -i video_without_audio.mp4 -f lavfi -i anullsrc -vcodec copy -acodec aac -shortest video_with_silence.mp4
ffmpeg -i video_without_audio.mp4 -f lavfi -i anullsrc -vcodec copy -acodec aac -shortest video_with_silence.mp4
Speed Up Video 500x
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i sky.mp4 -vf "setpts=0.002*PTS,crop=in_w:in_w*9/16,scale=1920:1080" -vcodec libx264 -b:v 10000k -r 60 -pix_fmt yuv420p sky_speedier.mp4
ffmpeg -i sky.mp4 -vf "setpts=0.002*PTS,crop=in_w:in_w*9/16,scale=1920:1080" -vcodec libx264 -b:v 10000k -r 60 -pix_fmt yuv420p sky_speedier.mp4
ffmpeg -i sky.mp4 -vf "setpts=0.002*PTS,crop=in_w:in_w*9/16,scale=1920:1080" -vcodec libx264 -b:v 10000k -r 60 -pix_fmt yuv420p sky_speedier.mp4
Use every 500th Frame of Video
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ffmpeg -i sky.mp4 -vf "select='not(mod(n,500))',setpts=N/FRAME_RATE/TB,crop=in_w:in_w*9/16,scale=1920:1080" -vcodec libx264 -b:v 10000k -r 60 -pix_fmt yuv420p sky_virtual_timelapse.mp4
ffmpeg -i sky.mp4 -vf "select='not(mod(n,500))',setpts=N/FRAME_RATE/TB,crop=in_w:in_w*9/16,scale=1920:1080" -vcodec libx264 -b:v 10000k -r 60 -pix_fmt yuv420p sky_virtual_timelapse.mp4
ffmpeg -i sky.mp4 -vf "select='not(mod(n,500))',setpts=N/FRAME_RATE/TB,crop=in_w:in_w*9/16,scale=1920:1080" -vcodec libx264 -b:v 10000k -r 60 -pix_fmt yuv420p sky_virtual_timelapse.mp4

Leave a comment

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