Cheat Sheet
This is a quick “cheat sheet” for myself…
Python
- generate TOTP given seed:
python -c "import pyotp;print(pyotp.TOTP('seed').now())"
ffmpeg
- extract specific portions of video w/o re-encoding:
ffmpeg -i <input> -ss <seek timestamp> -t <duration> <output>
-ss <seek timestamp>
: the timestamp (inh:m:s.ss
format) to start from-t <duration>
: the duration of the extracted clip (inh:m:s.ss
format)- note that multiple
-ss <seek timestamp> -t <duration> <output>
can be appended to do multiple extractions in one pass
- remove embedded closed captions from video stream (e.g. example
ffprobe
output below):ffmpeg -i <input> -c copy -bsf:v 'filter_units=remove_types=6' <output>
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1072 [SAR 1:1 DAR 120:67], Closed Captions, 2150 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
- removing or re-ordering audio and subtitle tracks:
ffmpeg -i <input> -map 0:v:0 -map 0:a:<index> -map 0:s:<index> -c copy <output>
(assuming only single input and single video stream, all<source>
entries for the-map <source>:<type>:<index>
parameters is always0
)-map 0:a:<index>
: zero-based index of the audio track (i.e. even if multiple audio streams exist, and/or the first audio track isstream
#0:n
, the first audio track’s index is still “0
“); multiple entries can be used, with the new order based on the order the -map parameter appears-map 0:s:<index>
: zero-based index of the subtitle track (i.e.even if multiple subtitle streams exist, and/or the first subtitle track isstream
#0:n
, the first audio track’s index is still “0
“); multiple entries can be used, with the new order based on the order the-map
parameter appears- any un-mapped streams will be ommitted in the output (i.e. if you left out the
-map 0:v:0
, there will be no video stream)
- removing or switching default audio and subtitle tracks:
ffmpeg -i <input> -c copy <output> -dispositions:<type>:<index> 0 -dispositions:<type>:<index> default <output>
-dispositions:<type>:<index> 0
: remove stream<index>
as the default stream for<type>
-dispositions:<type>:<index> default
: set stream<index>
as the default stream for<type>
- note that the
<index>
is based on the output streams order (e.g. if placed after other-map
parameters)