set bitrate to input if lower than target bitrate
This commit is contained in:
		
							
								
								
									
										16
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -165,11 +165,15 @@ function buildInitOptions() { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function vodBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> { | async function vodBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> { | ||||||
|     const { resolution, fps, streamNum } = params |     const { resolution, fps, streamNum, inputBitrate } = params | ||||||
|     const streamSuffix = streamNum == undefined ? '' : `:${streamNum}` |     const streamSuffix = streamNum == undefined ? '' : `:${streamNum}` | ||||||
|     const targetBitrate = getTargetBitrate(resolution, fps) |     let targetBitrate = getTargetBitrate(resolution, fps) | ||||||
|     let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum) |     let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum) | ||||||
|  |  | ||||||
|  |     if (targetBitrate > inputBitrate) { | ||||||
|  |         targetBitrate = inputBitrate | ||||||
|  |     } | ||||||
|  |  | ||||||
|     logger.info(`Building encoder options, received ${JSON.stringify(params)}`) |     logger.info(`Building encoder options, received ${JSON.stringify(params)}`) | ||||||
|      |      | ||||||
|     if (shouldInitVaapi && streamNum != undefined) { |     if (shouldInitVaapi && streamNum != undefined) { | ||||||
| @ -194,11 +198,15 @@ async function vodBuilder(params: EncoderOptionsBuilderParams) : Promise<Encoder | |||||||
|  |  | ||||||
|  |  | ||||||
| async function liveBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> { | async function liveBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> { | ||||||
|     const { resolution, fps, streamNum } = params |     const { resolution, fps, streamNum, inputBitrate } = params | ||||||
|     const streamSuffix = streamNum == undefined ? '' : `:${streamNum}` |     const streamSuffix = streamNum == undefined ? '' : `:${streamNum}` | ||||||
|     const targetBitrate = getTargetBitrate(resolution, fps) |     let targetBitrate = getTargetBitrate(resolution, fps) | ||||||
|     let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum) |     let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum) | ||||||
|  |  | ||||||
|  |     if (targetBitrate > inputBitrate) { | ||||||
|  |         targetBitrate = inputBitrate | ||||||
|  |     } | ||||||
|  |  | ||||||
|     logger.info(`Building encoder options, received ${JSON.stringify(params)}`) |     logger.info(`Building encoder options, received ${JSON.stringify(params)}`) | ||||||
|  |  | ||||||
|     if (shouldInitVaapi && streamNum != undefined) { |     if (shouldInitVaapi && streamNum != undefined) { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user