smallarrows.GIF
titlebar_image

FFMPEG PC and Mac

INSTALL FFMPEG
PC:
  Download FFmpeg
Under Get packages & executable files
Select your platform, PC
Select Windows builds bt Btbn
Select one of the zip file links
Find the file in your Downloads
folder
Right mouse over the zip file, select Extract All...
Change the name of the ffmpeg-....-static folder to ffmpeg
Move the folder to This PC C:\Program Files folder

Set up an Environment Variable Path to the FFMPEG program:
Be careful not to override previous paths. Copy and paste any prior path data before doing this. Sometimes paths are separated by a semi-colon, depending on the OS.
Open Settings, type env in the search
Select Edit the environment variables for your account
The Environment Variables window will pop up.
Select Environment Variables... button

     Highlight  Path
for User variables
          Select Edit...  
         Select New

     Input the entire path of the ffmpeg program, including bin after the last Path, separate with a semi-colon.
          Your path will be similar to this: C:\Program Files\ffmpeg-...-win64-static\bin
 

Mac:  Download FFmpeg
Under Get packages & executable files
Select your platform, Mac
Select Static builds for macOS 64-bit
Select the zip file near the top of the page.
Find the file in your Downloads folder
Drag the ffmpeg folder into you Applications folder
You will need to open System Preferences, Security & Privacy and allow ffmpeg after you run ffmpeg once.

Setup your Mac to work with scripts:

Open System Preferences->Users & Groups
     Unlock the padlock
     Hold Control and the mouse over your logi name while you select Advanced Options
     Change Login Shell to /bin/sh

Open a Terminal
     Open Terminal Preferences
     Select Shells open with a:    Command, input /bin/bash

PC
Scripts for running ffmpeg from a .bat file on PC
::If you prefer to run from a cmd.exe window use inputname.%04d.tif

MP4 h.264 from an mov or mp4 file
This compression format works in browsers on the internet and Unity, 8000-10,000 kbps good for internet and low bandwidth.

Run notepad.exe

Add this code below to the file.
Change the name folder to your folder name, this assumes your folder is located on your desktop.
Change the file name and extension
Change the sp value to the amount you would like to scale your file. 1 = no change
Change the output name

@echo off
set dt=%USERPROFILE%\Desktop
set input=-i %dt%\inputname.mp4
set sp=.5
set scale=-filter_complex scale=iw*%sp%:ih*%sp%,setsar=1
set codec=-c:v libx264 -x264-params bitrate=8000:vbv-bufsize=8000:vbv-maxrate=10000 -pix_fmt yuv420p -movflags +faststart
set output=-f mp4 %dt%\name.mp4
ffmpeg -y %input% %scale% %codec% %output%
pause


Save this file a name such as run_ffmpeg.bat, double click the file to run ffmpeg.


MP4 h.264 from a tiff sequence
This compression format works in browsers on the internet and Unity, 8000-10,000 kbps good for internet and low bandwidth.

Run
notepad.exe
Add this code below to the file.
Change the name folder to your folder name, this assumes your folder is located on your desktop.
Change the file name, this assumes a tiff file sequence with a padding of 4, such as inputname.0001-0100.tif
Change the sp value to the amount you would like to scale your image. 1 = no change
Change the output name

@echo off
set dt=%USERPROFILE%\Desktop
set loopend=-frames 100
set input=-framerate 30 -start_number 1 -i %dt%\folder\inputname.%%04d.tif
set sp=.5
set scale=-filter_complex scale=iw*%sp%:ih*%sp%,setsar=1
set codec=-c:v libx264 -x264-params bitrate=8000:vbv-bufsize=8000:vbv-maxrate=10000 -pix_fmt yuv420p -movflags +faststart
set output=-f mp4 %dt%\name.mp4
ffmpeg -y %input% %loopend% %scale% %codec% %output%
pause


Save this file a name such as run_ffmpeg.bat, double click the file to run ffmpeg.


MP4 h.265 2 pass from a tiff sequence for very high bandwidth such as a computer
Run notepad.exe
Add this code below to the file.
Change the name folder to your folder name, this assumes your folder is located on your desktop.
Change the file name, this assumes a tiff file sequence with a padding of 4, such as  inputname.0001.tif - inputname.0100.tif
Change the sp value to the amount you would like to scale your image. 1 = no change
Change the output name

@echo off
set dt=%USERPROFILE%\Desktop
set loopend=-frames 100
set input=-framerate 30 -start_number 1 -i %dt%\folder\inputname.%%04d.tif
set sp=.5
set scale=-filter_complex scale=iw*%sp%:ih*%sp%,setsar=1
set codec1=-vcodec libx265 -x265-params bitrate=40000:vbv-bufsize=40000:vbv-maxrate=60000 -pass 1 -pix_fmt yuv420p -movflags +faststart -passlogfile %dt%
set codec2=-vcodec libx265 -x265-params bitrate=40000:vbv-bufsize=40000:vbv-maxrate=60000 -pass 2 -pix_fmt yuv420p -movflags +faststart -passlogfile %dt%
set output=-f mp4 %dt%\name.mp4
ffmpeg -y %input% %loopend% %scale% %codec1% -f mp4 NUL
ffmpeg -y %input% %loopend% %scale% %codec2% %output%
pause


Save this file a name such as run_ffmpeg.bat, double click the file to run ffmpeg.


Change the resolution of all tiff and png files in a folder.
@echo off
mkdir temp
for %%A IN (*.tif) DO ffmpeg -y -i "%%A" -filter_complex scale=512:512 -vcodec tiff -compression_algo lzw "temp\%%A"
for %%A IN (*.png) DO ffmpeg -y -i "%%A" -filter_complex scale=512:512 -vcodec png  "temp\%%A"


MAC

Scripts for running ffmpeg from a shell script on a Mac

MP4 h.264 from an mov or mp4 file
This compression format works in browsers on the internet and Unity, 8000-10,000 kbps good for internet and low bandwidth.

Open TextEdit and create a new file, save it as run_ffmpeg.command on the Desktop.
Convert the file to plain text by selecting
Format->Make Plain Text


Add this code below to the file.
Change the name folder to your folder name, this assumes your folder is located on your desktop.
Change the file name and extension
Change the sp value to the amount you would like to scale your file. 1 = no change
Change the output name

#! /bin/bash
cur_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
input="-i $cur_dir/input.mp4"
sp="1"
scale="-filter_complex scale=iw*$sp:ih*$sp,setsar=1"
codec="-c:v libx264 -x264-params bitrate=8000:vbv-bufsize=8000:vbv-maxrate=10000 -pix_fmt yuv420p -movflags +faststart"
output="$cur_dir/output.mp4"
/Applications/ffmpeg -y $input $scale $codec $output


Run the Terminal application
Type chmod 777 ~/Desktop/run_ffmpeg.command

If you have never done this before, also type chsh -s /bin/zsh   Enter your Mac password.

Double-click the run_ffmpeg.command
file to run your script.

If ffmpeg cannot run, do this: System Preferences->Security & Privacy, unlock, click allow anyway for ffmpeg


MP4 h.264 from a tiff sequence
This compression format works in browsers on the internet and Unity, 8000-10,000 kbps good for internet and low bandwidth.

Open TextEdit and create a new file, save it as run_ffmpeg.command on the Desktop.
Convert the file to plain text by selecting
Format->Make Plain Text


Add this code below to the file.
Change the name folder to your folder name, this assumes your folder is located on your desktop.
Change the file name, this assumes a tiff file sequence with a padding of 4, such as inputname.0001.tif - inputname.0100.tif
Change the sp value to the amount you would like to scale your image. 1 = no change
Change the output name

#! /bin/bash
cur_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
input="-framerate 30 -start_number 1 -i $cur_dir/input.%04d.tif"
loopend="-frames 100"
sp="1"
scale="-filter_complex scale=iw*$sp:ih*$sp,setsar=1"
codec="-c:v libx264 -x264-params bitrate=8000:vbv-bufsize=8000:vbv-maxrate=10000 -pix_fmt yuv420p -movflags +faststart"
output="$cur_dir/output.mp4"
/Applications/ffmpeg -y $input $loopend $scale $codec $output



MP4 h.265 2 pass from a tiff sequence for very high bandwidth such as a computer
Quicktime will not open this file, use VLC

Open TextEdit and create a new file, save it as run_ffmpeg.command on the Desktop.
Convert the file to plain text by selecting
Format->Make Plain Text


Add this code below to the file.
Change the name folder to your folder name, this assumes your folder is located on your desktop.
Change the file name, this assumes a tiff file sequence with a padding of 4, such as inputname.0001.tif - inputname.0100.tif
Change the sp value to the amount you would like to scale your image. 1 = no change.
Change the output name

#! /bin/bash
cur_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
input="-framerate 30 -start_number 1 -i $cur_dir/input.%04d.tif"
loopend="-frames 100"
sp="1"
scale="-filter_complex scale=iw*$sp:ih*$sp,setsar=1"
codec1="-vcodec libx265 -x265-params bitrate=40000:vbv-bufsize=40000:vbv-maxrate=60000 -pass 1 -pix_fmt yuv420p -movflags +faststart"
codec2="-vcodec libx265 -x265-params bitrate=40000:vbv-bufsize=40000:vbv-maxrate=60000 -pass 2 -pix_fmt yuv420p -movflags +faststart"
output="$cur_dir/output.mp4"
/Applications/ffmpeg -y $input $loopend $scale $codec1 -f mp4 /dev/null
/Applications/ffmpeg -y $input $loopend $scale $codec2 $output



Apple Prores 422 HQ from an mov or mp4 file
This compression format works is very high bandwidth. This adds a default sharpening in order to improve the appearance. Adobe seems to do this to their files.

Open TextEdit and create a new file, save it as run_ffmpeg.command on the Desktop.
Convert the file to plain text by selecting
Format->Make Plain Text


Add this code below to the file.
Change the name folder to your folder name, this assumes your folder is located on your desktop.
Change the file name and extension
Change the sp value to the amount you would like to scale your file. 1 = no change
Change the output name

#! /bin/bash
cur_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
input="-i $cur_dir/input.mp4"
sp="1"
scale="-filter_complex scale=iw*$sp:ih*$sp,setsar=1,unsharp=5:5:1.0:5:5:0.0"
codec="-c:v prores_ks -profile:v 3 -f mov"
output="$cur_dir/output.mov"
/Applications/ffmpeg -y $input $scale $codec $output


Change the resolution of all tiff and png files in a folder.
Open TextEdit and create a new file, save it as run_ffmpeg.command on the Desktop.
Convert the file to plain text by selecting
Format->Make Plain Text

Add this code below to the file.

#!/bin/bash
echo " "
echo " "
echo " "
DIR="$( cd "$( dirname "$0" )" && pwd )"
cd "$DIR"
mkdir temp
find ./ -name '*.tif' -execdir ffmpeg -y -i {} -filter_complex scale=512:512 -vcodec tiff -compression_algo lzw temp/"{}" \;
find ./ -name '*.png' -execdir ffmpeg -y -i {} -filter_complex scale=512:512 -vcodec png temp/"{}" \;
mkdir HUGE
mv *.tif HUGE
mv *.png HUGE
mv temp/* .
rm -r temp

 

© 1988-2024 36 years