ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ffmpeg-options.ts 1.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { logger } from '@server/helpers/logger.js'
  2. import { CONFIG } from '@server/initializers/config.js'
  3. import { FFMPEG_NICE } from '@server/initializers/constants.js'
  4. import { FFmpegCommandWrapperOptions } from '@peertube/peertube-ffmpeg'
  5. import { AvailableEncoders } from '@peertube/peertube-models'
  6. type CommandType = 'live' | 'vod' | 'thumbnail'
  7. export function getFFmpegCommandWrapperOptions (type: CommandType, availableEncoders?: AvailableEncoders): FFmpegCommandWrapperOptions {
  8. return {
  9. availableEncoders,
  10. profile: getProfile(type),
  11. niceness: FFMPEG_NICE[type.toUpperCase()],
  12. tmpDirectory: CONFIG.STORAGE.TMP_DIR,
  13. threads: getThreads(type),
  14. logger: {
  15. debug: logger.debug.bind(logger),
  16. info: logger.info.bind(logger),
  17. warn: logger.warn.bind(logger),
  18. error: logger.error.bind(logger)
  19. },
  20. lTags: { tags: [ 'ffmpeg' ] }
  21. }
  22. }
  23. // ---------------------------------------------------------------------------
  24. // Private
  25. // ---------------------------------------------------------------------------
  26. function getThreads (type: CommandType) {
  27. if (type === 'live') return CONFIG.LIVE.TRANSCODING.THREADS
  28. if (type === 'vod') return CONFIG.TRANSCODING.THREADS
  29. // Auto
  30. return 0
  31. }
  32. function getProfile (type: CommandType) {
  33. if (type === 'live') return CONFIG.LIVE.TRANSCODING.PROFILE
  34. if (type === 'vod') return CONFIG.TRANSCODING.PROFILE
  35. return undefined
  36. }