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 6/27/2019.

Installing FFmpeg (YouTube videos)

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

GoPro: convert images to timelapse video (files in multiple folders)
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)
ffmpeg -framerate 30 -pattern_type glob -i '*.JPG' -vf crop=in_w:in_w9/16,scale=1920:1080 -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
Create Shortcut to Amcrest IP Camera
#!/bin/bash
ffplay "rtsp://{username}:{password}@{ip_address}:554/cam/realmonitor?channel=1&subtype=0";
exit;
Streaming an IP Camera to a Web Browser
#!/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
Streaming Live TV from a HDHomerun to a Web Browser
#!/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
Stream a Mac Screen to a Raspberry Pi
#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
Make H.265 File Compatible with Quicktime
ffmpeg -i input.mp4 -codec copy -tag:v hvc1 output.mp4
Pipe ffmpeg to ffplay
ffmpeg -i  -f h264 -vcodec libx264 pipe:1|ffplay -i pipe:0
Convert JPEG Image Sequence to MKV (with MJPEG encoding)
ffmpeg -framerate 30 -pattern_type glob -i 'timelapse/*.JPG' -codec copy out.mkv
Convert MKV (with MJPEG encoding) to JPEG Image Sequence
ffmpeg -i out.mkv -vcodec copy timelapse/pic%d.jpg
Extract Single JPEG Image from MKV (with MJPEG encoding)
ffmpeg -ss 00:00:00.03 -i out.mkv -vframes 1 -codec copy output.jpg

Leave a comment

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