Skip to content

Instantly share code, notes, and snippets.

View Cygon's full-sized avatar

Markus Ewald Cygon

View GitHub Profile
@Cygon
Cygon / transcode-svt-hevc.sh
Last active May 31, 2023 09:56
Shell script that encodes a movie to HEVC using Intel's lesser known SVT-HEVC encoder
#!/bin/sh
# File from which the video is taken
inputFile=$1
# File to which the HEVC-encoded video bitstream will be written
hevcFile=${inputFile%.*}.hevctranscoded.hevc
# File to which the final generated output video will be written
outputFile=${inputFile%.*}.hevctranscoded.mkv
@Cygon
Cygon / transcode-av1.sh
Last active May 24, 2023 09:13
Shell script that encodes a movie to the free AV1 video codec using the highest possible quality
#!/bin/sh
# Helper script to transcode to high-quality AV1 clips via ffmpeg
#
# Uses best possible settings with two-pass encode.
# Encoding a full will take months or years!
#
# File from which the video is taken
inputFile=$1
@Cygon
Cygon / transcode-audio.sh
Last active May 24, 2023 09:14
Shell script that downmixes and transcodes audio into high-quality AAC tracks
#!/bin/sh
# Converts audio from BluRay or lossless source into high quality
# AAC files with custom stereo downmix parameters
#
# Use like this:
# ./transcode-audio my_movie.mkv ger51 eng51 skip jpn20
#
# Each parameter after the movie name tells the script which kind
# of audio channel to handle.
@Cygon
Cygon / transcode-x265.sh
Last active May 31, 2023 09:53
Shell script that encodes an HEVC / H.265 `.mkv` movie with the highest possible quality
#!/bin/sh
# Helper script to transcode to high-quality x265 clips via ffmpeg
#
# Uses best possible settings with two-pass encode
# See below for additional options.
#
# File from which the video is taken
inputFile=$1
@Cygon
Cygon / rebox-mkv-to-mp4.md
Last active August 16, 2020 17:55
Turning `.mkv` into `.mp4` without transcoding

Turning .mkv into .mp4 without transcoding

Obviously, don't do this unless you have a pressing reason. Matroska (.mkv) is the better and free-er format and this only works if the video was in an .mp4 supporting format from the start (i.e. H.264 / H.265 with AC3 / AAC).

Requires mkvtoolnix (for mkvextract) and gpac (for MP4Box)

Step 1 - Unbox the Matroska Container

@Cygon
Cygon / transcode-vp9.sh
Last active May 5, 2023 12:30
Shell script that encodes a VP9 `.webm` movie with the highest possible quality
#!/bin/sh
# Helper script to transcode movies using the free VP9 codec
# in very high quality (a full movie will take several days!)
#
# File from which the video is taken
inputFile=$1
# File to which the final generated output video will be written
@Cygon
Cygon / take-sequential-screenshot.sh
Last active March 28, 2018 16:21
Takes a screenshot of a predefined area of the desktop
#!/bin/bash
# Takes a screenshot of a predefined area of your desktop
# Good for comparison images and making animations where FPS is too low for OBS
#
# Dependencies:
# - scrot
# - graphicsmagick
# Change these values to match your preferences
@Cygon
Cygon / preventing-too-large-code-units.md
Created March 12, 2018 16:11
Thoughts on Preventing Large Code Units

If you've ever ended up in the unlucky position of maintaining a poorly maintained codebase, you may know why experienced programmers generally advocate for smaller units of code.

Uncontrolled Growth

The amount of code (or design) a human being can keep in active memory is limited, thus, if a unit of code is allowed to grow until the mental limit of the average team member is exceeded, code just gets /piled/ on top of what already existed. The capacity for suffering through this is sometimes astounding and a single unit of code can spiral into thousands of lines of features piled on top of each other with no knowledge of the assumptions and patterns that were once present in the rest of the code.

Of course, the solution is to break it down into smaller units a single mind can pick up and understand.

@Cygon
Cygon / prefer-static-methods-for-nonmutating-operations.md
Last active November 11, 2017 17:50
Prefer Static Methods for Non-Mutating Operations

Prefer Static Methods for Non-Mutating Operations

When writing instance methods that do not change the state of their instance but rather return a modified copy of the instance, it is often better to implement these methods as static methods accepting an instance as an argument rather as a argument-less instance method.

DO NOT Return Mutated State from Instance Methods

@Cygon
Cygon / document-conditions-with-local-variables.md
Last active October 26, 2017 14:44
Document Conditions with Local Variables

Document Conditions with Local Variables

When many factors weigh into a condition, the condition statement can become unreadable, especially if combined with a poor line wrapping technique. This is a very basic technique that achieve much better readability when writing conditions.

DO NOT: Write complex conditions directly in if statements