Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

video production Notes

Chris Jones edited this page Aug 19, 2019 · 39 revisions

Contents

Working with Aspect Ratios

To calculate the aspect ratio of a screen given the resolution of a screen, ie. my MacBook Pro 2013; width = 1440 pixels @ 2x | height = 900 pixels @ 2x

  1. Divide the width by the height

Ex

1440 / 900 = 1.6
16 / 10 = 1.6

Another way of saying the aspect ratio is that the screen is 16 by 10

A decent video for calculating aspect ratios here

Working with Blender as a Video Editor

Blender can be used not only as a 3D animation / modeling program but also has support for editing video based files, ie. raw mpeg files, DVD mpeg 2 files, and so on.

Blender stores its configuration directory, ie. Blender in different paths based on the system that Blender is running on, ie. if running Blender on macOS as a standard user, then Blender will store its configuration files in $HOME/Library/Application\ Support/Blender, whereas on most GNU+Linux distros, Blender will store it's configuration directory / files in $XDG_CONFIG_HOME, ie. $HOME/.config/Blender.

Working with Avidemux

In short, avidemux is a great lightweight utility for trimming the beginning and ending of a a video clip / movie, ie. if one has recorded a screencast using OBS, and wants to remove the first and end three seconds of the clip avidemux is a decent tool for the job.

ffmpeg

To install ffmpeg with all the goodies 🍩 πŸ₯ƒ πŸͺ

brew install ffmpeg --with-tools --with-fdk-aac --with-libvpx --with-x265 --HEAD

To rotate a video using ffmpeg, ie. rotate a video recorded in portrait mode via an iOS device to landscape ie. more suitable for watching on YouTube.

  • method 1 should not reencode video but rather fill unused space with black bars.

    ffmpeg -i [input.mov] -metadata:s:v rotate="90" -codec copy [output.mov]

    ❗️ the "transpose=[0,1,2,3]" options have since been deprecated, and it more suitable to use "transpose=[cclock_flip,clock,cclock,clock_flip]"

  • method 2 should reencode the video but the video not contain blackbars

    ffmpeg -i [input.mov] -vf "transpose=cclock" [output.mov]

    ❗️ the above cmd will reencode both the audio and video, ⌚️ that said, the audio can be copied without reencoding as we only need to rotate the video.

    ffmpeg -i [input.mov] -vf "transpose=cclock" -c:a copy [output.mov]

To transcode a x265 HEV1 encoded video file

ffmpeg -i input.MOV \
-filter:v scale=1280:-1 -r 30 -c:v libx265 \
-crf 21 -c:a aac -b:a 128k -f mp4 -pix_fmt yuv420p \
-tag:v hvc1 -movflags faststart output.mp4

To transcode a video from one container format to another, ie. from .mkv to .mp4

ffmpeg -i input.mkv -codec copy output.mp4

To transcode an audio file from codec to another, ie. Microsoft WAV to mp3

ffmpeg -i input.wav -vn -ar 44100 -ac 2 -ab 192k -f mp3 output.mp3

To extract an audio stream from a audio video interlieved file

ffmpeg -i input.avi -vn -acodec copy output.mp3

The above command will NOT transcode the stream and keep the audio stream in the original codec.

To convert a audio file useful for working with Mozilla's DeepSpeech

ffmpeg -i [INPUT.aac] -acodec pcm_s16le -ac 1 -ar 16000 [OUTPUT.wav]

The above ffmpeg command will take a aac input file and convert it to 16bit 16khz mono channel WAV file useful for working with Mozilla's DeepSpeech project.

To combine multiple video files into one output file

echo file file1.mp4 > list.txt
echo file file2.mp4 >> list.txt
echo file file3.mp4 >> list.txt
echo file file4.mp4 >> list.txt

Concatenate the files into one continuos file

ffmpeg -f concat -i list.txt -c copy output.mp4

ffmpeg Quickly recording an audio stream

A use case that I have quickly come across is being able to record an audio stream playing through the system audio on macOS, ie. when I listen to a YouTube stream in my terminal using mpv. Ideally I would want to record the audio stream in it's native codec to avoid real-time or transcoding on the fly to minimize CPU usage when recording a stream. ffmpeg is a great tool for recording audio via the command line.

To list available sources that ffmpeg can record from on macOS

ffmpeg -f avfoundation -list_devices true -i ""

To list available capture devices on different OS's such as Windows or Linux see

After displaying the capturing devices use ffmpeg to select a capture device and begin recording the stream from the system audio.

For my particular use case mpv decodes YouTube live streams on macOS using an aac audio codec, so I would want to record the stream using an aac codec on my system. Also, as opposed to recording the output of the speakers playing the audio, which would be a "turrible" idea, I route my audio through app known as Background Music on macOS which is quite magical πŸ•΄ to say the least, so I'm able to record the audio stream being funneled into Background Music using ffmepg with minimal to no audio degredation.

To capture only audio being streamed through Background Music

ffmpeg -f avfoundation -i ":0" /path/to/recording.aac

ffmpeg will require a known audio file extension in order to capture the audio.

ffmpeg > overhauling a multimedia file, ie. an .mp4

In other words this section describes a way one can spend an afternoon fucking around with a multimedia file to get a deeper understanding of the tools provided by ffmpeg and friends.

ffmpeg > ... > working with chapters

In short, ffmpeg supports working with chapters for .mp4 files which allow for labeling a particular section a video file, and also allow for quickly jumping between different segments of a video file. For more info see

ffmpeg > ... > extracting segments of a video file

ffmpeg provides utilites to extract certain a segment of a particular video file based on timecodes of the source video file, thus allowing to create a smaller segmenting video from the original file, ie. the source. For more info see

ffmpeg > ... > ... > Useful Command
ffmpeg -i [INPUT.file] -ss 00:42:42 -to 00:84:84 -vcodec copy -acoded copy -y [OUTPUT.file]

ffmpeg > ... > combining video files

ffmpeg provides utilities for combining multiple video files useful if certain parts were extracted from a particular video file. Also the segmented files can be combined in a single file without transcoding the output file thus allowing for lightning ⚑️ fast concatenation of files. For more info, see

ffmpeg > Useful Links

Working with mpv

To play a audio & video file, but not play the video portion of the file, ie. just decode and play the audio portion of the file.

mpv --vid=no /path/to/media/file.{mkv,mp4}

Useful Key Bindings for mpv

To control the volume output of the audio in mpv via CLI

9 or 0

To jump to the next & previous chapters in mpv

PGUP PGDWN

On a MBP Macbook Pro use fn + arrow keys, ie.

fn + ↑ fn + ↓

For a more detailed list about key bindings see

mpv Understanding hardware decoding in mpv

The main difference between hardware decoding vs. software decoding is that hardware decoding decompresses the binary blob of data, ie. the video file directly on the video card, where as with software decoding it is to my understanding that the binary blob of data will be decompressed via the CPU and then moved onto the GPU, ie. the decompressing of the video / blob of data does not happen on the GPU.

To print a list of video output drivers accessible to mpv

mpv --vo=help

On macOs put vo=gpu in ~/.config/mpv/mpv.conf

To print a list of hardware, ie. GPU accelerated decoding codecs

mpv --hwdec=help

Quick note, videotoolbox is Apple's implementation for macOS to interface with a GPU to peform common video tasks on the GPU as opposed to a CPU, that said, videotoolbox API is relevant for *nix or Windows, but if a Nvidia GPU is present Nvidia provides nvenc for GPU's β‰₯ to Keepler for using a GPU for video related tasks.

On macOS put hwdec=videotoolbox in ~/.config/mpv/mpv.conf Running mpv on Linux, and using hardware acceleration will obviously require different settings. 🀷

Troubleshooting mpv

Troubleshooting hardware decoding in mpv

To troubleshoot the below warning / error message on macOS add the below config settings.

Not trying to use hardware decoding: codec h264 is not on whitelist, or does not support hardware acceleration.

mpv.conf settings macOS specific

vo=gpu
hwdec=videotoolbox

mpv Useful Links

Working with VLC

To start vlc with logging

vlc --verbose=2 --file-logging --logfile=/path/to/vlc.log

Working with MKV files

MKVToolNix provides great tools for working with the matroska container format for multimedia files. It allows features such as adding additional subtitile tracks to existing mkv file.

Working with OBS Open Broadcaster Software

🚨 When saving files with OBS while recording, set the container format to mov as opposed to mp4 because mp4 files are more corruptible if the recording fails, ie. the entire file can become trashed whereas mov does a better job in preserving the file.

Twerking with OBS settings on a MBP Macbook Pro

The native resolution on my MBP is 2880 x 1800, so in order to make usable with YouTube I scale down to 1728 x 1080 which preserves the 2880 x 1800 aspect ratio of my mac's computer screen.

Also I scaled down the FPS from the native 60FPS to 30FPS to save on file size for outputting to YouTube.

Useful Links

ScreenStudio requires JRE >= 8.0 😬

TODOs

Frequent Flyers ✈️

❀️ ~/.πŸ› πŸˆ

Clone this wiki locally

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /