Skip to content

Commit a7aa01b

Browse files
committed
🐛 [Fix]: 썸네일 기본 이미지 설정
1 parent 31ccb9f commit a7aa01b

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

.github/workflows/media-deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ on:
33
push:
44
branches:
55
- develop
6-
paths:
7-
- 'apps/media/**'
6+
- Fix/326
7+
# paths:
8+
# - 'apps/media/**'
89

910
jobs:
1011
build-and-push:

.github/workflows/record-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- develop
6+
- Fix/326
67
paths:
78
- 'apps/record/**'
89
jobs:

apps/media/src/sfu/sfu.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ClientService } from './services/client.service';
1515
import { RecordService } from './services/record.service';
1616
import { User } from '../types/user';
1717
import { SetVideoQualityDto } from './dto/set-video-quality.dto';
18+
import axios from 'axios';
1819

1920
@Injectable()
2021
export class SfuService {
@@ -31,6 +32,9 @@ export class SfuService {
3132

3233
async createRoom(clientId: string, user: User) {
3334
const room = await this.roomService.createRoom();
35+
await axios.post(`${this.configService.get('RECORD_SERVER_URL')}/thumbnail`, {
36+
roomId: room.id,
37+
});
3438
const thumbnail = `${this.configService.get('PUBLIC_RECORD_SERVER_URL')}/statics/thumbnails/${room.id}.jpg`;
3539
await this.broadcasterService.createBroadcast(
3640
CreateBroadcastDto.of(room.id, `${user.camperId}님의 방송`, thumbnail, user.id),

apps/record/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ WORKDIR /app
1010

1111
RUN mkdir -p /app/assets/records /app/assets/thumbnails && chmod -R 777 /app/assets
1212

13+
COPY ./apps/record/public/default-thumbnail.jpg /app/assets/default-thumbnail.jpg
14+
RUN chmod 644 /app/assets/default-thumbnail.jpg
15+
1316
# Environment variables
1417
ARG RECORD_PORT
1518
ARG NCLOUD_ACCESS_KEY
235 KB
Loading

apps/record/src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const app = express();
1212
const assetsDirPath = path.join(__dirname, '../assets');
1313
const thumbnailsDirPath = path.join(__dirname, '../assets/thumbnails');
1414
const recordsDirPath = path.join(__dirname, '../assets/records');
15+
const defaultThumbnailPath = path.join(__dirname, '../assets/default-thumbnail.jpg');
1516

1617
app.use(express.json());
1718
app.use(cors());
@@ -29,6 +30,22 @@ if (!fs.existsSync(recordsDirPath)) {
2930
fs.mkdirSync(recordsDirPath, { recursive: true });
3031
}
3132

33+
const createDefaultThumbnail = (roomId: string) => {
34+
const newThumbnailPath = path.join(thumbnailsDirPath, `${roomId}.jpg`);
35+
fs.copyFileSync(defaultThumbnailPath, newThumbnailPath);
36+
return newThumbnailPath;
37+
};
38+
39+
app.post('/thumbnail', (req, res) => {
40+
const { roomId } = req.body;
41+
try {
42+
const thumbnailPath = createDefaultThumbnail(roomId);
43+
res.send({ success: true, path: thumbnailPath });
44+
} catch (error) {
45+
res.status(500).send({ success: false, error: 'Failed to create thumbnail' });
46+
}
47+
});
48+
3249
app.post('/send', (req, res) => {
3350
const { videoPort, roomId, type, audioPort } = req.body;
3451
createFfmpegProcess(videoPort, assetsDirPath, roomId, type, audioPort);

0 commit comments

Comments
 (0)