Skip to content

Instantly share code, notes, and snippets.

@monsieuroeuf
Last active May 4, 2021 10:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monsieuroeuf/1aceac1b32de886ba4b4369b3bf31ecd to your computer and use it in GitHub Desktop.
Save monsieuroeuf/1aceac1b32de886ba4b4369b3bf31ecd to your computer and use it in GitHub Desktop.

quiver:///notes/85DE3C89-A451-4736-B3B4-82EB872067DE

make a bunch of MP4s out of pngs and mp3s

typeset -Z2 c=0; for f in png/*png; do ((c++)) ffmpeg -y -loop 1 -f image2 -r 25 -i $f -i audio/${f:t:r}.mp3 -c:v libx264 -c:a copy -shortest $c.mp4 done


Prores stuff

ffmpeg -i $f -codec:v prores -profile:v 1 ${f:r}-prores.mov

Prores quality

-profile:v 0 			// proxy
-profile:v 1 			// LT
-profile:v 2 			// regular
-profile:v 3 			// HQ

while read f; do dest='/Volumes/ARC8050T3-4/work/BES034 Asia Roadshow/support/5_footage/re-encoded' < /dev/null ffmpeg -i "$f" -filter:v scale=1920:-1 -codec:v prores "$dest/${f:t:r}-proxy.mov" done < to-transcode.txt

added the weird /dev/null trick because apparently ffmpeg was reading from stdin … i know, weird


for f in *mov; do ffmpeg -i $f -q:v 1 -b:v 5M -pix_fmt yuv420p ${f:r}.mp4 done

thumbnails

for f in *MXF; do
  ffmpeg -y -ss 5 -i $f -vframes 1 -f image2 ${f:r}.jpg
done

MKV

Get an MKV ready for editing (proxy prores)

for f (*MKV) ffmpeg -i $f -codec:v prores -profile:v 1 ${f:r}.mov

Extract audio

mkvmerge -i $f # list formats
mkvextract tracks 1:output.ogg
ffmpeg -i output.ogg output.wav

General Notes

The -q:v switch

"The -q:v 1 was the ticket. It sets the quality of the video encoder, where the -q means quality and the :v means video. Values range from 1 to 31, where lower means better."

Audio

Strip audio (mute)

ffmpeg -i example.mkv -c copy -an example-nosound.mkv

Extract audio (from MXF for example)

for f in *MXF; do
      ffmpeg -i $f -map 0:1 -c:a copy -ac 2 ${f:r}.wav
 done

Choose which files to process

use fzf in multiselect to put them in array "a":

a=$(print * | fzf -m)

Then pipe them into this loop:

echo $a| while read f; do
	ffmpeg -i $f -filter:v scale=854:-1 -vcodec wmv2 -acodec wmav2 -b:v 2M ${f:r}.wmv
done

Encode as WMV without resizing

ffmpeg -i $f -q:v 4 -vcodec wmv2 -acodec wmav2 "${f:r}.wmv" && say "The dude abides"

Encode as WMV with resizing

	ffmpeg -i $f -q:v 4 -filter:v scale=1280:-1 -vcodec wmv2 -acodec wmav2 ${f:r}-720p.wmv

Image sequences

Output to image sequence, high quality jpegs

ffmpeg -i Connect-\ DayOnCampus.mp4 -qscale 1 foo-%03d.jpg

image sequence to ProRes

s=71 # for example
ffmpeg -start_number 0 -f image2 -r 25 -i render_${s}_%03d.jpg -codec:v prores -profile:v 2 -r 25 $s.mov

ffmpeg -i 'frank reveal flip.%04d.exr' -codec:v prores -profile:v 2 frank-flip-reveal-prores.mov

regular old prores, strip audio

ffmpeg -i $f -codec:v prores -an ${f:r}-nosound.mov

Specific jobs

webm for AGSM website

ffmpeg -i "$f" -filter:v scale=1280:-1 -c:v libvpx -b:v 2M -pix_fmt yuv420p -an ${f:r}.webm

AVI for AGSM

ffmpeg -i $f -q:v 5 ${f:r}.avi

Jeremy's Spitzer job

v1

ffmpeg -i $f -vcodec wmv2 -acodec wmav2 -qscale:v 2 ${f:r}.wmv

v2

ffmpeg -i $f -vcodec wmv2 -acodec wmav2 -b:v 2M ${f:r}.wmv

v3

ffmpeg -i $f -filter:v scale=854:-1 -vcodec wmv2 -acodec wmav2 -b:v 2M ${f:r}.wmv
ffmpeg -i $f -filter:v scale=854:-1 -vcodec wmv2 -acodec wmav2 -b:v 1M ${f:r}.wmv

Lendlease Royal Adelaide WMV

High-res:

ffmpeg -i $f -q:v 5 -vcodec wmv2 -acodec wmav2 "${f:r} 1080p.wmv" && say "The dude abides"

Low res:

ffmpeg -i $f -filter:v scale=1024:-1 -q:v 4 -vcodec wmv2 -acodec wmav2 "${f:r} 576p.wmv" && say "The dude abides"

Uncompressed AVI for Optus EPL stadium

ffmpeg -i "$in" -vcodec rawvideo -pix_fmt uyvy422 -vtag 2vuy ${in:r}.avi

encode to wmv for Lend Lease Hong Kong screens

ffmpeg -i $f -q 3 -b:v 10M -vcodec msmpeg4 output-q_3.wmv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment