Skip to content

Commit

Permalink
final integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Glydric committed Feb 5, 2024
1 parent 6f7ab8a commit a968fee
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 49 deletions.
49 changes: 23 additions & 26 deletions Backend/src/cameraStream/transcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ export const transcode = async (
};

const performTranscoding = async () => {
const ffmpegOptions = [
'-i',
camera.rtspUri,
'-c:v',
'libx264',
'-crf',
'23',
'-preset',
'ultrafast',
'-an',
'-force_key_frames',
'expr:gte(t,n_forced*4)',
'-hls_time',
'2',
'-hls_list_size',
'5',
'-hls_flags',
'delete_segments',
'-start_number',
'1',
'index.m3u8',
];
const ffmpegOptions = [
'-i',
camera.rtspUri,
'-c:v',
'libx264',
'-crf',
'23',
'-preset',
'ultrafast',
'-an',
'-force_key_frames',
'expr:gte(t,n_forced*4)',
'-hls_time',
'2',
'-hls_list_size',
'5',
'-hls_flags',
'delete_segments',
'-start_number',
'1',
'index.m3u8',
];

const childProcess = spawn('ffmpeg', ffmpegOptions, workingDirectory);

Expand All @@ -53,18 +53,15 @@ export const transcode = async (
active = true;
trialCount = 0;
}
console.log(data.toString());
});

childProcess.on('close', (code) => {
active = false;
console.log(`closed and removed`);
console.log(camera.rtspUri);
console.log(`closed and removed ${camera.id}`);
exec('rm -f *', workingDirectory, (error, stdout, stderr) => {
if (error) {
console.error(`Clearning folder cam${camera.id} error`);
}
console.log(`Clearning folder cam${camera.id} successful`);
});
});
};
Expand Down
4 changes: 2 additions & 2 deletions Frontend/src/containers/video-stream-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export const VideoStreamContainer: FC<PropsType> = () => {
socket.on("inactive", (data) => {
const message = JSON.parse(data);
const currentCamera = cameras.find((camera) => camera.id === message.id);
if (currentCamera?.isActive) {
// if (currentCamera?.isActive) {
updateCameraStatus({ id: message.id, status: false });
}
// }
});

document.addEventListener("fullscreenchange", onExitFullScreenEscape);
Expand Down
44 changes: 23 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,29 @@ services:
env_file:
- .secrets.yml

backend:
container_name: backend
image: node:lts-bullseye
depends_on:
- mongo
restart: on-failure # always
ports:
- "8080:8080"
working_dir: /home/node
volumes:
- ./Backend:/home/node
env_file:
- .secrets.yml
command:
- /bin/sh
- -c
- |
apt update
apt install ffmpeg -y
npm run docker:start
# backend:
# container_name: backend
# platform: linux/amd64
# image: node:lts-bullseye
# depends_on:
# - mongo
# restart: on-failure # always
# ports:
# - "8080:8080"
# working_dir: /home/node
# volumes:
# - ./Backend:/home/node
# env_file:
# - .secrets.yml
# command:
# - /bin/sh
# - -c
# - |
# apt update
# apt install ffmpeg -y
# npm run docker:start
#
#
frontend:
container_name: frontend
image: node:21-alpine
Expand Down

0 comments on commit a968fee

Please sign in to comment.