Fix bufsize

Enhance readme
This commit is contained in:
gitlab.com/pepa65 2022-09-01 13:57:06 +07:00
parent 00cffa7b06
commit 040f6caab3
4 changed files with 10 additions and 7 deletions

View File

@ -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

10
encode
View File

@ -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

View File

View File

@ -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);