Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit 651bcf7

Browse files
author
Robert Thomas
committed
Plex Encode v0.4
Base build and encode scripts.
1 parent 2c10916 commit 651bcf7

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
# Plexus
2-
A suite of tools to help manage your media collection.
1+
# Plex Encode
2+
This script will create a list of media from your Plex server that needs to be re-encoded.
3+
4+
## Install
5+
6+
First, install required dependencies:
7+
``` bash
8+
sudo apt-get install ffmpeg mediainfo -y
9+
```
10+
Then, create the required directories:
11+
``` bash
12+
sudo mkdir /root/plex-encode /tmp/plex-encode /tmp/plex-encode/convert /tmp/plex-encode/converted
13+
```
14+
Next, run the build-list.sh script

build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
for f in /mnt/plex-encode/*.*; do
2+
echo "Looking at: $f"
3+
audio_codec=$(mediainfo --Inform="Audio;%Format%" "$f")
4+
video_codec=$(mediainfo --Inform="Video;%Format%" "$f")
5+
6+
if [ $audio_codec != "AAC" ]
7+
then
8+
echo "$f" >> /root/files.txt
9+
fi
10+
done

encode.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
while read line; do
3+
#!/bin/bash
4+
PATH=${line%/*}
5+
FILE=${line##*/}
6+
NAME=${FILE%.*}
7+
echo "Downloading: " $FILE
8+
/usr/bin/rclone copy "GDrive:$line" /tmp/plex-encode/convert --stats-log-level NOTICE --stats 30s
9+
echo "File downloaded."
10+
video_codec=$(/usr/bin/mediainfo --Inform="Video;%Format%" "/tmp/plex-encode/convert/$FILE")
11+
if [ $video_codec == "AVC" ]
12+
then
13+
echo "Codec is x264"
14+
/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"
15+
else
16+
echo "Codec isn't x264"
17+
/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"
18+
fi
19+
echo "File successfully converted."
20+
/usr/bin/rclone delete "GDrive:$line" --stats-log-level NOTICE --stats 30s
21+
echo "Original file deleted from GDrive"
22+
/usr/bin/rclone move "/tmp/plex-encode/convert/done/$NAME.mkv" "GDrive:$PATH" --stats-log-level NOTICE --stats 30s
23+
echo "File successfully uploaded."
24+
/bin/rm "/tmp/plex-encode/convert/$FILE"
25+
/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
26+
done < /root/plex-encode/list.txt

0 commit comments

Comments
 (0)