Skip to content

Instantly share code, notes, and snippets.

@rduttshukla
Created November 27, 2022 17:13
Show Gist options
  • Save rduttshukla/cc5ee67bd7234b1e18104a375a039c2e to your computer and use it in GitHub Desktop.
Save rduttshukla/cc5ee67bd7234b1e18104a375a039c2e to your computer and use it in GitHub Desktop.
Convert Videos To Jellyfin Supported Format

Hi, this is a bash script that I am writing by taking inspiration from the internet to make conversion of video files to Jellyfin format easier.

Sure, we can use transcoding, but that often requires purchasing specific hardware for this purpose, which is okay if you have it. But still you may want to save some CPU cycles by not using transcoding.

Please note the below script is a work in progress and I will update it as soon as I learn better ways.

#!/usr/bin/env bash
# Get audio bitrate
AUDIO_BITRATE=`ffprobe -v error -select_streams a:0  -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 "$1"`

# Get audio channels count
AUDIO_CHANNELS=`ffprobe -show_entries stream=channels -of compact=p=0:nk=1 -v 0 -i "$1" | grep -o -E '[0-9]+' | head -1 | sed -e 's/^0\+//'`

# Convert
ffmpeg -i "$1" -map 0:a -map 0:v -map 0:s -use_wallclock_as_timestamps 1 -scodec copy -acodec aac -b:a $AUDIO_BITRATE  -ac $AUDIO_CHANNELS -vcodec copy "${1%.mkv}-copy.mkv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment