Skip to content

Commit

Permalink
Implement nvidia ffmpeg config (#20)
Browse files Browse the repository at this point in the history
* add config
  • Loading branch information
Dzmitry92 authored May 9, 2024
1 parent c85e65e commit 962982d
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions packages/db-populator/src/service/ffmpeg-query-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,28 @@ export class FfmpegQueryService {
const name = file.name.split('.')
const nameWithoutExtension = name.slice(0, name.length - 1).join('.')

const ffmpegNvidiaConfig = [
'-hwaccel',
'cuda',
'-hwaccel_output_format',
'cuda',
'-c:v',
'h264_cuvid',
'-i',
`${file.path}/${file.name}`,
'-c:v',
'h264_nvenc',
'-preset',
'medium',
'-crf',
'18',
'-c:a',
'copy',
`${FILE_ROOT_DIR}/${nameWithoutExtension}.mp4`,
]

// the fastest option
spent(() =>
execFileSync('ffmpeg', [
'-i',
`${file.path}/${file.name}`,
'-c:v',
'libx264',
'-preset',
'medium',
'-crf',
'23',
'-c:a',
'aac',
'-b:a',
'128k',
`${FILE_ROOT_DIR}/${nameWithoutExtension}.mp4`,
])
)
spent(() => execFileSync('ffmpeg', ffmpegNvidiaConfig))
} catch (err) {
console.log('------ convertVideoFile catch error', err)
throw err
Expand All @@ -97,8 +101,8 @@ export class FfmpegQueryService {
)
return result.toString()
} catch (err) {
console.log('------ getLength catch error', err);
throw err;
console.log('------ getLength catch error', err)
throw err
}
}
}

0 comments on commit 962982d

Please sign in to comment.