diff --git a/README.md b/README.md index ea0ec7e..5033331 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,10 @@ ## Install * Prepare a Linux server, set its timezone to the users' timezone (on deb-based systems: `dpkg-reconfigure tzdata`). -* On the server, `cd` to the place where you want the files. +* On the server, `cd` to the place where you want the files (make sure that + the webserver user (often `www-data`) has access to the location!). +* Make sure the packages `git php-fpm ffmpeg` are installed (on deb-based + systems: `apt install git php-fpm ffmpeg`). * Clone repo: `git clone https://gitlab.com/pepa65/streamupload`. * `cd streamupload`. Now the output of `pwd` is the value for `$repopath`. * Copy `_mailvars` to `mailvars` and set the variables diff --git a/encode b/encode index 25097e9..e67cac5 100755 --- a/encode +++ b/encode @@ -37,7 +37,7 @@ Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:email,name, # Rename upload and check type file=${upload%.upload} video=$file.mp4 name=${file##*/} key=${name%%.*} rest=${name#*.} date=${rest:0:15} _=${rest:15} email=${_%@*} -# If email embedded, strip the '=' +# If email embedded, strip the '_' [[ $email ]] && email=${email:1} /usr/bin/mv "$upload" "$file" @@ -45,15 +45,15 @@ type=$(file -bL --mime-type "$file") [[ ! ${type:0:5} = video ]] && Mail 1 "File $name is of type $type" # Encode video -start=$(date +'%Y-%m-%d at %H:%M') error=0 +start=$(date +'%Y-%m-%d at %H:%M:%S') error=0 ## Single pass #/usr/bin/ffmpeg -y -i "$file" -c:v libx264 -x264opts no-scenecut -b:v 6M -force_key_frames 'expr:gte(t,n_forced*2)' -c:a copy -tune zerolatency -f mp4 "$video" || # Double pass -/usr/bin/ffmpeg -y -i "$file" -c:v libx264 -x264opts no-scenecut -b:v 6M -maxrate 6M -bufsize 1M -force_key_frames 'expr:gte(t,n_forced*2)' -movflags faststart -c:a copy -tune zerolatency -pass 1 -f mp4 "$video" && - /usr/bin/ffmpeg -y -i "$file" -c:v libx264 -x264opts no-scenecut -b:v 6M -maxrate 6M -bufsize 1M -force_key_frames 'expr:gte(t,n_forced*2)' -movflags faststart -c:a copy -tune zerolatency -pass 2 -f mp4 "$video" || +/usr/bin/ffmpeg -y -i "$file" -c:v libx264 -x264opts no-scenecut -b:v 6M -maxrate 6M -bufsize 12M -force_key_frames 'expr:gte(t,n_forced*2)' -movflags faststart -c:a copy -tune zerolatency -pass 1 -f mp4 "$video" && + /usr/bin/ffmpeg -y -i "$file" -c:v libx264 -x264opts no-scenecut -b:v 6M -maxrate 6M -bufsize 12M -force_key_frames 'expr:gte(t,n_forced*2)' -movflags faststart -c:a copy -tune zerolatency -pass 2 -f mp4 "$video" || error=1 -finish=$(date +'%Y-%m-%d at %H:%M') +finish=$(date +'%Y-%m-%d at %H:%M:%S') ((error)) && Mail 2 "Error encoding $name" # Schedule cron job diff --git a/uploadpage/streams/.gitkeep b/uploadpage/streams/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/uploadpage/upload.php b/uploadpage/upload.php index bef25c0..41b7e0b 100644 --- a/uploadpage/upload.php +++ b/uploadpage/upload.php @@ -19,7 +19,7 @@ $key=$_POST['streamkey']; $datetime=$_POST['datetime']; $email=$_POST['email']; if($email){ - $email='='.$email; + $email='_'.$email; } $date=substr($datetime, 0, 10); $hour=substr($datetime, 11, 2);