Skip to content

Commit

Permalink
🐛 [Fix]: 썸네일 기본 이미지 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
g00hyun committed Dec 2, 2024
1 parent 31ccb9f commit 59607b0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/media-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ on:
push:
branches:
- develop
paths:
- 'apps/media/**'
- Fix/326
# paths:
# - 'apps/media/**'

jobs:
build-and-push:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/record-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- develop
- Fix/326
paths:
- 'apps/record/**'
jobs:
Expand Down
4 changes: 4 additions & 0 deletions apps/media/src/sfu/sfu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ClientService } from './services/client.service';
import { RecordService } from './services/record.service';
import { User } from '../types/user';
import { SetVideoQualityDto } from './dto/set-video-quality.dto';
// import axios from 'axios';

@Injectable()
export class SfuService {
Expand All @@ -31,6 +32,9 @@ export class SfuService {

async createRoom(clientId: string, user: User) {
const room = await this.roomService.createRoom();
// await axios.post(`${this.configService.get('RECORD_SERVER_URL')}/thumbnail`, {
// roomId: room.id,
// });
const thumbnail = `${this.configService.get('PUBLIC_RECORD_SERVER_URL')}/statics/thumbnails/${room.id}.jpg`;
await this.broadcasterService.createBroadcast(
CreateBroadcastDto.of(room.id, `${user.camperId}님의 방송`, thumbnail, user.id),
Expand Down
3 changes: 3 additions & 0 deletions apps/record/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ WORKDIR /app

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

COPY ./apps/record/public/default-thumbnail.jpg /app/assets/default-thumbnail.jpg
RUN chmod 644 /app/assets/default-thumbnail.jpg

# Environment variables
ARG RECORD_PORT
ARG NCLOUD_ACCESS_KEY
Expand Down
Binary file added apps/record/public/default-thumbnail.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions apps/record/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const app = express();
const assetsDirPath = path.join(__dirname, '../assets');
const thumbnailsDirPath = path.join(__dirname, '../assets/thumbnails');
const recordsDirPath = path.join(__dirname, '../assets/records');
const defaultThumbnailPath = path.join(__dirname, '../assets/default-thumbnail.jpg');

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

const createDefaultThumbnail = (roomId: string) => {
const newThumbnailPath = path.join(thumbnailsDirPath, `${roomId}.jpg`);
fs.copyFileSync(defaultThumbnailPath, newThumbnailPath);
return newThumbnailPath;
};

app.post('/thumbnail', (req, res) => {
const { roomId } = req.body;
try {
const thumbnailPath = createDefaultThumbnail(roomId);
res.send({ success: true, path: thumbnailPath });
} catch (error) {
res.status(500).send({ success: false, error: 'Failed to create thumbnail' });
}
});

app.post('/send', (req, res) => {
const { videoPort, roomId, type, audioPort } = req.body;
createFfmpegProcess(videoPort, assetsDirPath, roomId, type, audioPort);
Expand Down

0 comments on commit 59607b0

Please sign in to comment.