diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/ArchiveLayout.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/ArchiveLayout.java index c5e37dc9..02b944e1 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/ArchiveLayout.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/ArchiveLayout.java @@ -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 diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java index 0509879d..9bed7c42 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java @@ -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 } diff --git a/openvidu-node-client/src/ArchiveLayout.ts b/openvidu-node-client/src/ArchiveLayout.ts index 78ec4278..0b2525d1 100644 --- a/openvidu-node-client/src/ArchiveLayout.ts +++ b/openvidu-node-client/src/ArchiveLayout.ts @@ -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' diff --git a/openvidu-node-client/src/OpenVidu.ts b/openvidu-node-client/src/OpenVidu.ts index 4223fe18..1134eeae 100644 --- a/openvidu-node-client/src/OpenVidu.ts +++ b/openvidu-node-client/src/OpenVidu.ts @@ -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 } diff --git a/openvidu-server/docker/openvidu-recording/entrypoint.sh b/openvidu-server/docker/openvidu-recording/entrypoint.sh old mode 100644 new mode 100755 index 83027ad1..742c9831 --- a/openvidu-server/docker/openvidu-recording/entrypoint.sh +++ b/openvidu-server/docker/openvidu-recording/entrypoint.sh @@ -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 diff --git a/openvidu-server/src/main/java/io/openvidu/server/OpenViduServer.java b/openvidu-server/src/main/java/io/openvidu/server/OpenViduServer.java index d83cb892..78bbea0b 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/OpenViduServer.java +++ b/openvidu-server/src/main/java/io/openvidu/server/OpenViduServer.java @@ -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 { diff --git a/openvidu-server/src/main/java/io/openvidu/server/recording/RecordingService.java b/openvidu-server/src/main/java/io/openvidu/server/recording/RecordingService.java index d632afdb..88a9a3ab 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/recording/RecordingService.java +++ b/openvidu-server/src/main/java/io/openvidu/server/recording/RecordingService.java @@ -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");