Skip to content

Commit

Permalink
Bug fix on URL recording
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Feb 6, 2018
1 parent e9110c5 commit 5554933
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public Session createSession(SessionProperties properties) throws OpenViduExcept
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
}

Expand Down
2 changes: 1 addition & 1 deletion openvidu-node-client/src/ArchiveLayout.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions openvidu-node-client/src/OpenVidu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
57 changes: 41 additions & 16 deletions openvidu-server/docker/openvidu-recording/entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ public static void main(String[] args) throws Exception {
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();
}
Expand All @@ -195,6 +192,10 @@ public static void main(String[] args) throws Exception {
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) {
Expand Down Expand Up @@ -233,7 +234,7 @@ public static void main(String[] args) throws Exception {
}
}

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;

Expand Down Expand Up @@ -67,8 +68,10 @@ public void startRecording(Session session) {
} 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");
Expand Down

0 comments on commit 5554933

Please sign in to comment.