This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base build and encode scripts.
- Loading branch information
Robert Thomas
committed
Jun 25, 2018
1 parent
2c10916
commit 651bcf7
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
# Plexus | ||
A suite of tools to help manage your media collection. | ||
# Plex Encode | ||
This script will create a list of media from your Plex server that needs to be re-encoded. | ||
|
||
## Install | ||
|
||
First, install required dependencies: | ||
``` bash | ||
sudo apt-get install ffmpeg mediainfo -y | ||
``` | ||
Then, create the required directories: | ||
``` bash | ||
sudo mkdir /root/plex-encode /tmp/plex-encode /tmp/plex-encode/convert /tmp/plex-encode/converted | ||
``` | ||
Next, run the build-list.sh script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
for f in /mnt/plex-encode/*.*; do | ||
echo "Looking at: $f" | ||
audio_codec=$(mediainfo --Inform="Audio;%Format%" "$f") | ||
video_codec=$(mediainfo --Inform="Video;%Format%" "$f") | ||
|
||
if [ $audio_codec != "AAC" ] | ||
then | ||
echo "$f" >> /root/files.txt | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
while read line; do | ||
#!/bin/bash | ||
PATH=${line%/*} | ||
FILE=${line##*/} | ||
NAME=${FILE%.*} | ||
echo "Downloading: " $FILE | ||
/usr/bin/rclone copy "GDrive:$line" /tmp/plex-encode/convert --stats-log-level NOTICE --stats 30s | ||
echo "File downloaded." | ||
video_codec=$(/usr/bin/mediainfo --Inform="Video;%Format%" "/tmp/plex-encode/convert/$FILE") | ||
if [ $video_codec == "AVC" ] | ||
then | ||
echo "Codec is x264" | ||
/usr/bin/ffmpeg -i "/tmp/convert/$FILE" -c:v copy -c:a aac -q:a 100 -preset veryfast -strict -2 -movflags faststart -threads 2 -loglevel quiet -stats "/tmp/convert/done/$NAME.mkv" | ||
else | ||
echo "Codec isn't x264" | ||
/usr/bin/ffmpeg -i "/tmp/convert/$FILE" -c:v libx264 -c:a aac -q:a 100 -preset veryfast -strict -2 -movflags faststart -threads 2 -loglevel quiet -stats "/tmp/convert/done/$NAME.mkv" | ||
fi | ||
echo "File successfully converted." | ||
/usr/bin/rclone delete "GDrive:$line" --stats-log-level NOTICE --stats 30s | ||
echo "Original file deleted from GDrive" | ||
/usr/bin/rclone move "/tmp/plex-encode/convert/done/$NAME.mkv" "GDrive:$PATH" --stats-log-level NOTICE --stats 30s | ||
echo "File successfully uploaded." | ||
/bin/rm "/tmp/plex-encode/convert/$FILE" | ||
/bin/grep -v "$line" /root/plex-encode/list.txt > /tmp/plex-encode/list.txt; /bin/mv /tmp/plex-encode/list.txt /root/plex-encode/list.txt | ||
done < /root/plex-encode/list.txt |