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

Commit

Permalink
Plex Encode v0.4
Browse files Browse the repository at this point in the history
Base build and encode scripts.
  • Loading branch information
Robert Thomas committed Jun 25, 2018
1 parent 2c10916 commit 651bcf7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
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
10 changes: 10 additions & 0 deletions build.sh
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
26 changes: 26 additions & 0 deletions encode.sh
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

0 comments on commit 651bcf7

Please sign in to comment.