mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Add pixel size to tooltip and gif support with FFmpeg for avatar upload (#3329)
* Add avatar pixel size upload in tooltip * Add gif support for avatar * Add ffmpeg GIF process Co-authored-by: kimsible <kimsible@users.noreply.github.com>
This commit is contained in:
parent
c07fac202d
commit
123f619336
5 changed files with 52 additions and 8 deletions
|
@ -355,6 +355,40 @@ function convertWebPToJPG (path: string, destination: string): Promise<void> {
|
|||
})
|
||||
}
|
||||
|
||||
function processGIF (
|
||||
path: string,
|
||||
destination: string,
|
||||
newSize: { width: number, height: number },
|
||||
keepOriginal = false
|
||||
): Promise<void> {
|
||||
return new Promise<void>(async (res, rej) => {
|
||||
if (path === destination) {
|
||||
throw new Error('FFmpeg needs an input path different that the output path.')
|
||||
}
|
||||
|
||||
logger.debug('Processing gif %s to %s.', path, destination)
|
||||
|
||||
try {
|
||||
const command = ffmpeg(path)
|
||||
.fps(20)
|
||||
.size(`${newSize.width}x${newSize.height}`)
|
||||
.output(destination)
|
||||
|
||||
command.on('error', (err, stdout, stderr) => {
|
||||
logger.error('Error in ffmpeg gif resizing process.', { stdout, stderr })
|
||||
return rej(err)
|
||||
})
|
||||
.on('end', async () => {
|
||||
if (keepOriginal !== true) await remove(path)
|
||||
res()
|
||||
})
|
||||
.run()
|
||||
} catch (err) {
|
||||
return rej(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], fps, deleteSegments: boolean) {
|
||||
const command = getFFmpeg(rtmpUrl)
|
||||
command.inputOption('-fflags nobuffer')
|
||||
|
@ -474,6 +508,7 @@ export {
|
|||
getAudioStreamCodec,
|
||||
runLiveMuxing,
|
||||
convertWebPToJPG,
|
||||
processGIF,
|
||||
getVideoStreamSize,
|
||||
getVideoFileResolution,
|
||||
getMetadataFromFile,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue