Bug fix on URL recording

pull/30/head v1.7.0
pabloFuente 2018-02-06 10:09:14 +01:00
parent e9110c5a12
commit 555493389c
7 changed files with 56 additions and 27 deletions

View File

@ -1,7 +1,7 @@
package io.openvidu.java.client;
public enum ArchiveLayout {
BEST_FIT,
BEST_FIT, // All the videos are evenly distributed, taking up as much space as possible
PICTURE_IN_PICTURE,
VERTICAL_PRESENTATION,
HORIZONTAL_PRESENTATION

View File

@ -59,11 +59,11 @@ public class OpenVidu {
return s;
}
public void startArchive(String sessionId) {
public void startRecording(String sessionId) {
// TODO: REST POST to start recording in OpenVidu Server
}
public void stopArchive(String sessionId) {
public void stopRecording(String sessionId) {
// TODO: REST POST to end recording in OpenVidu Server
}

View File

@ -1,5 +1,5 @@
export enum ArchiveLayout {
BEST_FIT = 'BEST_FIT',
BEST_FIT = 'BEST_FIT', // All the videos are evenly distributed, taking up as much space as possible
PICTURE_IN_PICTURE = 'PICTURE_IN_PICTURE',
VERTICAL_PRESENTATION = 'VERTICAL_PRESENTATION',
HORIZONTAL_PRESENTATION = 'VERTICAL_PRESENTATION'

View File

@ -9,11 +9,11 @@ export class OpenVidu {
return new Session(this.urlOpenViduServer, this.secret, properties);
}
public startArchive(sessionId: string) {
public startRecording(sessionId: string) {
// TODO: REST POST to start recording in OpenVidu Server
}
public stopArchive(sessionId: string) {
public stopRecording(sessionId: string) {
// TODO: REST POST to end recording in OpenVidu Server
}

57
openvidu-server/docker/openvidu-recording/entrypoint.sh Normal file → Executable file
View File

@ -1,10 +1,14 @@
#!/bin/bash
adduser --uid $USER_ID --disabled-password --gecos "" myuser
CURRENT_UID="$(id -u $USER)"
if [[ $CURRENT_UID != $USER_ID ]]; then
adduser --uid $USER_ID --disabled-password --gecos "" myuser
fi
URL="${URL:-https://www.youtube.com/watch?v=JMuzlEQz3uo}"
RESOLUTION="${RESOLUTION:-1920x1080}"
FRAMERATE="${FRAMERATE:-30}"
FRAMERATE="${FRAMERATE:-24}"
VIDEO_SIZE="$RESOLUTION"
ARRAY=(${VIDEO_SIZE//x/ })
VIDEO_NAME="${VIDEO_NAME:-video}"
@ -19,29 +23,50 @@ DONE="no"
while [ "$DONE" == "no" ]
do
out=$(xdpyinfo -display :$DISPLAY_NUM 2>&1)
if [[ "$out" == name* ]] || [[ "$out" == Invalid* ]]
then
# command succeeded; or failed with access error; display exists
(( DISPLAY_NUM+=1 ))
else
# display doesn't exist
DONE="yes"
fi
out=$(xdpyinfo -display :$DISPLAY_NUM 2>&1)
if [[ "$out" == name* ]] || [[ "$out" == Invalid* ]]
then
# Command succeeded; or failed with access error; display exists
(( DISPLAY_NUM+=1 ))
else
# Display doesn't exist
DONE="yes"
fi
done
echo "First available display -> :$DISPLAY_NUM"
echo "----------------------------------------"
su myuser -c "pulseaudio -D"
if [[ $CURRENT_UID != $USER_ID ]]; then
su myuser -c "pulseaudio -D"
else
pulseaudio -D
fi
touch xvfb.log
chmod 777 xvfb.log
su myuser -c "xvfb-run --server-num=${DISPLAY_NUM} --server-args='-ac -screen 0 ${RESOLUTION}x24 -noreset' google-chrome -no-sandbox -disable-infobars -window-size=${ARRAY[0]},${ARRAY[1]} -start-fullscreen -no-first-run -ignore-certificate-errors $URL &> xvfb.log &"
sleep 3
if [[ $CURRENT_UID != $USER_ID ]]; then
su myuser -c "xvfb-run --server-num=${DISPLAY_NUM} --server-args='-ac -screen 0 ${RESOLUTION}x24 -noreset' google-chrome -no-sandbox -disable-infobars -window-size=${ARRAY[0]},${ARRAY[1]} -no-first-run -ignore-certificate-errors --kiosk $URL &> xvfb.log &"
else
xvfb-run --server-num=${DISPLAY_NUM} --server-args="-ac -screen 0 ${RESOLUTION}x24 -noreset" google-chrome -no-sandbox -disable-infobars -window-size=${ARRAY[0]},${ARRAY[1]} -no-first-run -ignore-certificate-errors --kiosk $URL &> xvfb.log &
fi
touch stop
chmod 777 /recordings
su myuser -c "<./stop ffmpeg -y -video_size $RESOLUTION -framerate $FRAMERATE -f x11grab -i :${DISPLAY_NUM} -f pulse -ac 2 -i default /recordings/${VIDEO_NAME}.${VIDEO_FORMAT}"
sleep 3
#su myuser -c "<./stop ffmpeg -y -video_size $RESOLUTION -framerate $FRAMERATE -f x11grab -i :${DISPLAY_NUM} -f pulse -ac 2 -i default /recordings/${VIDEO_NAME}.${VIDEO_FORMAT}"
#su myuser -c "<./stop ffmpeg -f alsa -ac 2 -i pulse -async 1 -f x11grab -i :${DISPLAY_NUM} -framerate $FRAMERATE -s $RESOLUTION -acodec copy -vcodec libx264 -preset medium -y /recordings/${VIDEO_NAME}.mkv"
#su myuser -c "<./stop ffmpeg -y -video_size $RESOLUTION -s $RESOLUTION -framerate $FRAMERATE -f x11grab -i :${DISPLAY_NUM} -f alsa -ac 2 -i pulse -async 1 -acodec copy -vcodec libx264 -preset medium -crf 0 -threads 0 -y /recordings/${VIDEO_NAME}.mkv"
#su myuser -c "<./stop ffmpeg -y -f alsa -i pulse -video_size $RESOLUTION -f x11grab -i :${DISPLAY_NUM} -r 24 -c:a libmp3lame -b:a 32k -c:v libx264 -b:v 500k /recordings/${VIDEO_NAME}.mkv"
if [[ $CURRENT_UID != $USER_ID ]]; then
su myuser -c "<./stop ffmpeg -y -f alsa -i pulse -f x11grab -framerate 25 -video_size $RESOLUTION -i :${DISPLAY_NUM} -c:a libfdk_aac -c:v libx264 -preset ultrafast -crf 28 -refs 4 -qmin 4 -pix_fmt yuv420p -filter:v fps=25 '/recordings/${VIDEO_NAME}.mkv'"
else
<./stop ffmpeg -y -f alsa -i pulse -f x11grab -framerate 25 -video_size $RESOLUTION -i :${DISPLAY_NUM} -c:a libfdk_aac -c:v libx264 -preset ultrafast -crf 28 -refs 4 -qmin 4 -pix_fmt yuv420p -filter:v fps=25 "/recordings/${VIDEO_NAME}.mkv"
fi

View File

@ -181,9 +181,6 @@ public class OpenViduServer implements JsonRpcConfigurer {
if (!OpenViduServer.publicUrl.startsWith("wss://")) {
OpenViduServer.publicUrl = "wss://" + OpenViduServer.publicUrl;
}
if (OpenViduServer.publicUrl.endsWith("/")) {
OpenViduServer.publicUrl = OpenViduServer.publicUrl.substring(0, OpenViduServer.publicUrl.length() - 1);
}
if (port == -1) {
OpenViduServer.publicUrl += ":" + openviduConf.getServerPort();
}
@ -195,6 +192,10 @@ public class OpenViduServer implements JsonRpcConfigurer {
type = "local";
OpenViduServer.publicUrl = "wss://localhost:" + openviduConf.getServerPort();
}
if (OpenViduServer.publicUrl.endsWith("/")) {
OpenViduServer.publicUrl = OpenViduServer.publicUrl.substring(0, OpenViduServer.publicUrl.length() - 1);
}
boolean recordingModuleEnabled = openviduConf.isRecordingModuleEnabled();
if (recordingModuleEnabled) {
@ -233,7 +234,7 @@ public class OpenViduServer implements JsonRpcConfigurer {
}
}
System.out.println("OpenVidu Server using " + type + " URL: " + OpenViduServer.publicUrl);
System.out.println("OpenVidu Server using " + type + " URL: [" + OpenViduServer.publicUrl + "]");
}
private static String getContainerIp() throws IOException, InterruptedException {

View File

@ -30,6 +30,7 @@ import com.github.dockerjava.core.command.ExecStartResultCallback;
import com.github.dockerjava.core.command.PullImageResultCallback;
import io.openvidu.server.CommandExecutor;
import io.openvidu.server.OpenViduServer;
import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.core.Session;
@ -67,8 +68,10 @@ public class RecordingService {
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
String location = OpenViduServer.publicUrl.replaceFirst("wss://", "");
envs.add("URL=https://OPENVIDUAPP:" + secret + "@localhost:8443/#/layout-best-fit/" + shortSessionId + "/"
envs.add("URL=https://OPENVIDUAPP:" + secret + "@" + location + "/#/layout-best-fit/" + shortSessionId + "/"
+ secret);
envs.add("RESOLUTION=1920x1080");
envs.add("FRAMERATE=30");