File extension에 관한 정리
.m3u8
: Segmented file에 관한 정보를 가지고 있는 인덱스 파일의 extension. 주요 내용으로는 다음과 같다
.ts
파일의 URL → m3u8을 클라이언트가 읽고 ts 파일에 관한 요청을 진행함으로 해당 내용은 필수적!!!.ts
: 나누어진 content를 각자 저장하는 파일
Express에서 필요한 패키지 정리
yarn install fluent-ffmpeg @ffmpeg-installer/ffmpeg
yarn install hls-server
ffmpeg
라는 라이브러리를 기반으로 HLS 형식으로 변환 및 index file 생성을 지원. ffmpeg
역할:
테스트 진행 목적
FfmpegService
async convertToHLS(inputPath: string, outputPath: string): Promise<void> {
return new Promise((resolve, reject) => {
ffmpeg(inputPath, { timeout: 432000 })
.addOptions([
'-c:a aac',
'-b:a 128k',
'-hls_time 10',
'-hls_list_size 0',
'-f hls',
])
.output(outputPath)
.on('progress', (progress) => {
console.log('Processing: ', progress.percent, '% done');
})
.on('start', (commandLine) => {
console.log('FFmpeg command:', commandLine);
})
.on('stderr', (stderrLine) => {
console.log('FFmpeg stderr:', stderrLine);
})
.on('end', () => {
console.log('Processing finished successfully');
resolve();
})
.on('error', (err, stdout, stderr) => {
console.error('FFmpeg Error:', err);
console.error('FFmpeg stdout:', stdout);
console.error('FFmpeg stderr:', stderr);
reject(err);
})
.run();
});
}