'upload-script.sh' ändern
This commit is contained in:
parent
6f9d31c4d5
commit
61afceced4
1 changed files with 225 additions and 36 deletions
255
upload-script.sh
255
upload-script.sh
|
|
@ -1,49 +1,238 @@
|
||||||
#!/bin/bash
|
#!/bin/#!/usr/bin/env bash
|
||||||
|
# This bash script transcode automagical recorded files with OBS in record/ into smaller mp4 files with fade in and out in upload-files.
|
||||||
|
# The files would be renamed into same file names with counting numbers.
|
||||||
|
# In additional, it will create thumbnails which will be uploaded with youtube-upload.
|
||||||
|
# after the script is done, it will create a upload-$ folder with the videos, thumbnails, description and a upload script file.
|
||||||
|
|
||||||
# set your options here:
|
# Create infrastructure
|
||||||
# How many Videos do you want to upload in a row
|
|
||||||
Episoden='1'
|
|
||||||
|
|
||||||
# Start with episode number:
|
mkdir -p record
|
||||||
StartCount='16'
|
mkdir -p upload-files
|
||||||
|
|
||||||
# Release the video at date (YYYY-MM-DD):
|
touch last_upload_date.txt
|
||||||
StartDatum='2017-10-11'
|
|
||||||
|
# Create Discreption
|
||||||
|
|
||||||
|
echo '' > .source.tmp
|
||||||
|
echo '' > .desc.tmp
|
||||||
|
|
||||||
|
# Create YT infos
|
||||||
|
|
||||||
|
echo "Create YouTube Informations"
|
||||||
|
printf "Title:";
|
||||||
|
read -r TITLE
|
||||||
|
|
||||||
|
printf "Category (Default Gaming):"
|
||||||
|
read -r CATEGORY
|
||||||
|
|
||||||
|
printf "Playlist:"
|
||||||
|
read -r PLAYLIST
|
||||||
|
|
||||||
|
printf "TAGS (seperate with commas. If Empty then native linux gaming):"
|
||||||
|
read -r TAGS
|
||||||
|
|
||||||
|
# Create YT description file
|
||||||
|
|
||||||
|
printf "Developer Name:"
|
||||||
|
read -r DEVS
|
||||||
|
|
||||||
|
printf "Linux Kernel Version:"
|
||||||
|
read -r KERNEL
|
||||||
|
|
||||||
|
printf "CPU (Default i5 6500):"
|
||||||
|
read -r CPU
|
||||||
|
|
||||||
|
printf "RAM (Default 16 GB DDR4):"
|
||||||
|
read -r RAM
|
||||||
|
|
||||||
|
printf "Graphiccard (Default NVIDIA GTX 1060 6GB):"
|
||||||
|
read -r GRAPHIC
|
||||||
|
|
||||||
|
printf "Driver Version (Default Nvidia proprietary driver):"
|
||||||
|
read -r DRIVER
|
||||||
|
|
||||||
|
printf "Buy it on Steam:"
|
||||||
|
read -r STEAM
|
||||||
|
|
||||||
|
printf "Buy it on HumbleBUndle:"
|
||||||
|
read -r HB
|
||||||
|
|
||||||
|
printf "Buy it on GOG:"
|
||||||
|
read -r GOG
|
||||||
|
|
||||||
|
printf "Buy it on Itch.io:"
|
||||||
|
read -r ITCH
|
||||||
|
|
||||||
|
printf "Record Date:"
|
||||||
|
read -r RECORD
|
||||||
|
|
||||||
|
|
||||||
# Video Informations:
|
if [ -z $CATEGORY ]; then
|
||||||
# Replace the XXX with the titel how every episode should be called
|
CATEGORY="Gaming"
|
||||||
Titel='"XXX'
|
fi
|
||||||
# Replace the XXX with the name of the category you want to use
|
|
||||||
Kategorie='XXX'
|
if [ -z $TAGS ]; then
|
||||||
# Replace the XXX for the Name which playlist should be used
|
TAGS="Games, Gaming, Linux, Walktrought, Arch Linux, Lets Play, Native"
|
||||||
Playlist='"XXX"'
|
fi
|
||||||
# Set the time for the release
|
|
||||||
Release='12:00:00.000+02:00'
|
if [ -z $CPU ]; then
|
||||||
# Set the tags you want use for alle the clips. Seperate with ","
|
CPU="Intel i5 6500"
|
||||||
Tags='"XXX,YYY,ZZZ,..."'
|
fi
|
||||||
# Set a description for all the clips
|
|
||||||
Beschreibung='"South Park Stick of truth lets play"'
|
if [ -z $RAM ]; then
|
||||||
# Replace the XXX how all the files begin
|
RAM="16 GB DDR4"
|
||||||
File='"XXX '
|
fi
|
||||||
# Set path where te files are
|
|
||||||
Path='/path/to/the/files'
|
if [ -z $GRAPHIC ]; then
|
||||||
|
GRAPHIC="NVIDIA GTX 1060 6GB"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $DRIVER ]; then
|
||||||
|
DRIVER="Nvidia proprietary driver"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $STEAM ]; then
|
||||||
|
STEAM="-"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $HB ]; then
|
||||||
|
HB="-"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $GOG ]; then
|
||||||
|
GOG="-"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $ITCH ]; then
|
||||||
|
ITCH="-"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Title='\"$TITLE '" >>.source.tmp
|
||||||
|
echo "Kategorie='$CATEGORY'" >>.source.tmp
|
||||||
|
echo "Playlist='\"$PLAYLIST\"'" >>.source.tmp
|
||||||
|
echo "Tags='\"$TAGS\"'" >>.source.tmp
|
||||||
|
|
||||||
|
echo -e "$TITLE - Lets Play on Arch Linux\n\nEntiwckler: $DEVS\n\nAufgenommen mit: OBS Studio\nBetriebssystem: Arch Linux\nKernel: $KERNEL\n\nHardware\nCPU: $CPU\nRAM: $RAM\nGrafikkarte: $GRAPHIC\nTreiber: $DRIVER\n\nBuy it on Steam: $STEAM\nBuy it on Humblebundle: $HB\nBuy it on GOG: $GOG\nBuy it on Itch.io: $ITCH\n\nRecord date: $RECORD" > .desc.tmp
|
||||||
|
|
||||||
|
|
||||||
|
# Rename recorded file names
|
||||||
|
|
||||||
|
printf "Game Name?: "
|
||||||
|
read -r FILES
|
||||||
|
|
||||||
|
if [ -z $FILES ]; then
|
||||||
|
FILES=default-name
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd record
|
||||||
|
|
||||||
|
a=1
|
||||||
|
|
||||||
|
for i in *.mp4; do
|
||||||
|
new=$(printf "$FILES#%d.mp4" "$a")
|
||||||
|
mv -i -- "$i" "$new"
|
||||||
|
let a=a+1
|
||||||
|
done
|
||||||
|
|
||||||
|
# create thumbnails
|
||||||
|
|
||||||
|
for i in *.mp4; do
|
||||||
|
name=`echo "$i" | cut -d'.' -f1`
|
||||||
|
echo "$name"
|
||||||
|
ffmpeg -y -i "$i" -vframes 1 -an -filter:v scale=1920:-1 -ss 30 ../upload-files/"${name}.jpg"
|
||||||
|
done
|
||||||
|
|
||||||
|
# modify thumbnail with thumb.png
|
||||||
|
|
||||||
|
for i in ../upload-files/*.jpg; do
|
||||||
|
composite -gravity center thumb.png $i ../upload-files/$i
|
||||||
|
done
|
||||||
|
|
||||||
|
# Transcode the files into smaller ones
|
||||||
|
|
||||||
|
for i in *.mp4;
|
||||||
|
do name=`echo "$i" | cut -d'.' -f1`
|
||||||
|
echo "$name"
|
||||||
|
ffmpeg -y \
|
||||||
|
-i "$i" \
|
||||||
|
-sseof -1 \
|
||||||
|
-copyts \
|
||||||
|
-hwaccel_device 0 \
|
||||||
|
-hwaccel_output_format cuda \
|
||||||
|
-hwaccel cuvid \
|
||||||
|
-c:v h264_cuvid \
|
||||||
|
-i "$i" \
|
||||||
|
-b:v 5M \
|
||||||
|
-minrate 5M \
|
||||||
|
-maxrate 10M \
|
||||||
|
-bufsize 10M \
|
||||||
|
-profile:v high \
|
||||||
|
-pixel_format cuda \
|
||||||
|
-filter_complex \
|
||||||
|
"[1]hwdownload,format=nv12,fade=out:0:30[t];\
|
||||||
|
[0][t]overlay,fade=in:0:30[v];\
|
||||||
|
anullsrc,atrim=0:2[at];[0][at]acrossfade=d=1,afade=d=1[a]" \
|
||||||
|
-map "[v]" -map "[a]" \
|
||||||
|
-vcodec h264_nvenc \
|
||||||
|
../upload-files/"${name}.mp4"
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
# Modify Thumbnails With Numbers and Filename
|
||||||
|
|
||||||
|
cd upload-files
|
||||||
|
|
||||||
|
for i in *.jpg; do
|
||||||
|
convert "$i" \
|
||||||
|
-pointsize 240 \
|
||||||
|
-gravity south -stroke '#000C' -strokewidth 10 \
|
||||||
|
-annotate - "#$(echo $i| sed -e 's/^.*#//g' -e 's/.jpg//g')" \
|
||||||
|
-stroke none -fill white \
|
||||||
|
-annotate - "#$(echo $i| sed -e 's/^.*#//g' -e 's/.jpg//g')" \
|
||||||
|
"$i";
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
# Create Upload script
|
||||||
|
|
||||||
|
source .source.tmp
|
||||||
|
|
||||||
# Don't edit anything here
|
# Don't edit anything here
|
||||||
|
Path='upload-files/*.mp4'
|
||||||
|
Episoden=$(ls $Path | wc -l)
|
||||||
DayCount='0'
|
DayCount='0'
|
||||||
StopCount=$(expr $StartCount + $Episoden)
|
StartCount='1'
|
||||||
|
StopCount=$(expr $StartCount + $Episoden )
|
||||||
Sichtbarkeit='private'
|
Sichtbarkeit='private'
|
||||||
|
Release='12:00:00.000+02:00'
|
||||||
|
File=$(ls $Path| sed -e 's/#.*//g' -e 's/upload-files\///g'| uniq)
|
||||||
|
StartDatum=$(cat last_upload_date.txt)
|
||||||
|
|
||||||
# simple loop script. This part generate a upload.sh for every clip you want to upload to YouTube,
|
# simple loop script. This part generate a upload.sh for every clip you want to upload to YouTube,
|
||||||
# then it run the second script and after the upload the scond script will be deleted.
|
# then it run the second script and after the upload the scond script will be deleted.
|
||||||
echo "#!/bin/bash" > upload.sh
|
echo "#!/bin/bash" > upload-files/upload-$(echo $Playlist|sed -e 's/\"//g' -e 's/ /_/g').sh
|
||||||
|
|
||||||
while [ $StartCount -lt $StopCount ]; do
|
while [ $StartCount -lt $StopCount ]; do
|
||||||
echo youtube-upload --title $Titel $StartCount"\"" --category=$Kategorie --playlist=""$Playlist"" --privacy=$Sichtbarkeit --publish-at=$(date +%Y-%m-%d -d "$StartDatum + $DayCount day")T$Release --tags=""$Tags"" --description=""$Beschreibung"" $Path$File $StartCount.mp4"\""
|
echo youtube-upload \
|
||||||
|
--thumbnail=\"$File#$StartCount.jpg\" \
|
||||||
|
--title $Title\#$StartCount"\"" \
|
||||||
|
--category=$Kategorie \
|
||||||
|
--playlist=""$Playlist"" \
|
||||||
|
--privacy=$Sichtbarkeit \
|
||||||
|
--publish-at=$(date +%Y-%m-%d -d "$StartDatum + $DayCount day")T$Release \
|
||||||
|
--tags=""$Tags"" \
|
||||||
|
--description-file=desc-$(echo $Playlist|sed -e 's/\"//g' -e 's/ /_/g').txt \
|
||||||
|
\"$File#$StartCount.mp4\"
|
||||||
let StartCount=StartCount+1
|
let StartCount=StartCount+1
|
||||||
let DayCount=DayCount+1
|
let DayCount=DayCount+1
|
||||||
done >> upload.sh
|
done >> upload-files/upload-$(echo $Playlist|sed -e 's/\"//g' -e 's/ /_/g').sh
|
||||||
|
|
||||||
chmod +x upload.sh
|
sed -i -e 's/^youtube/sleep 21600;youtube/g' -e 's/$/;/g' upload-files/upload-$(echo $Playlist|sed -e 's/\"//g' -e 's/ /_/g').sh
|
||||||
./upload.sh
|
date +%Y-%m-%d -d "$(cat last_upload_date.txt) + $(ls $Path| wc -l) day" > last_upload_date.txt
|
||||||
rm upload.sh
|
mv upload-files/ upload-$(echo $Playlist|sed -e 's/\"//g' -e 's/ /_/g')
|
||||||
|
mkdir upload-files
|
||||||
|
cp .desc.tmp upload-$(echo $Playlist|sed -e 's/\"//g' -e 's/ /_/g')/desc-$(echo $Playlist|sed -e 's/\"//g' -e 's/ /_/g').txt
|
||||||
|
|
||||||
|
|
||||||
|
rm .source.tmp
|
||||||
|
rm .desc.tmp
|
||||||
Loading…
Add table
Add a link
Reference in a new issue