Skip to content

video production Notes

Chris Jones edited this page Dec 27, 2018 · 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 great tool for this task, and does not transcode the video.

ffmpeg

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

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

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 -acoded copy output.mp3

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

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.

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}

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

9 or 0

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

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.

Useful Links

ScreenStudio requires JRE >= 8.0 😬

TODOs

Clone this wiki locally