ffmpeg: download streams, trim video, concat files

Search for a command to run...

No comments yet. Be the first to comment.
Working in a large repo, with multiple forks, committing to a main repo

git log --follow --name-only -p <file>

Regex capture groups and bash positional arguments to replace text in VS Code I've been knee deep in OpenAPI specs in my current role as an API Product Manager. While the work is fulfilling, there are some very mundane aspects to onboarding a develop...

ffmpeg -i <input-file> -c <codec> <output-file>
Start with the ffmpeg command
-i = input file
<input-file> either a stream url or local file
-c = codec to be used
<codec>\= I always use copy to use the same codec as the stream, or you can specify any other codec you want
<output-file> = the filename you want to save
ffmpeg -ss <hh:mm:ss> -i <input-file> -to <hh:mm:ss> -c <codec> <output-file>
Start with the ffmpeg command
-ss = start time of the video to trim
<hh:mm:ss> = must be in the format of hours:minutes:seconds
-i = input file
<input-file> either a stream url or local file
-to = total length of clip time, this can be confusing at first because you need to calculate the elapsed time of the clip. e.g. If you want to trim a clip that begins at 01:23:33 (one hour, 23 minutes, 33 seconds) and you want the video trimmed to 01:23:55 (one hour, 23 minutes, 55 seconds), the value of to would be 00:00:22 (22 seconds elapsed time)
-c = codec to be used
<codec>\= I always use copy to use the same codec as the stream, or you can specify any other codec you want
<output-file> = the filename you want to save, make sure you create a copy and don't overwrite the original file you are trimming
for f in <pattern>; do echo "file '$f'" >> <output-file>; done
let's write a bash script to easily create a playlist of the files you want to concat
for <variable> in is a bash loop to find all instances of the pattern given
f is a variable name for "file", it could be anything
<pattern> is a regex pattern of the filename e.g. *title-mm-dd-yy*
do begins the looping process
echo "file '$f'" tells bash to write the text "file <filename>" from the variable f to stdout (the terminal)
>> is a direction operator in Linux to write a file. When two arrows are present, it signifies append to the existing file
<output-file> should be a text file e.g. files.txt
<semi-colon> is used to end the previous command
we need to finish with a done command to finish the loop
This will create a files.txt with a playlist of the matching files
file 'game-01-01-23_1.mp4'
file 'game-01-01-23_2.mp4'
file 'game-01-01-23_3.mp4'
file 'game-01-01-23_4.mp4'
ffmpeg -f concat -i <input-file> -safe 0 -c <codec> <output-file>
Start with the ffmpeg command
-f\= indicates to ffmpeg to list each file for concatenation
concat = concatenate command
-i = input file
<input-file> either a stream url or local file
-safe 0 = dictates unsafe file names should be ignored, this is mainly used to allow relative paths
-c = codec to be used
<codec>\= I always use copy to use the same codec as the stream, or you can specify any other codec you want
<output-file> = the filename you want to save, make sure you create a copy and don't overwrite the original files you are using to create the final version