forked from Chocobozzz/PeerTube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: validate video files after transcoding
closes Chocobozzz#3407
- Loading branch information
1 parent
5357ce9
commit b12cdff
Showing
2 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import ffmpeg from 'fluent-ffmpeg' | ||
import { Job } from 'bull' | ||
import { lTags } from '@server/lib/object-storage/shared' | ||
import { logger } from '../logger' | ||
import { runCommand } from './ffmpeg-commons' | ||
|
||
async function validateVideoFile (options: { | ||
job?: Job | ||
path: string | ||
}) { | ||
logger.debug('Will validate video file.', { options, ...lTags() }) | ||
|
||
let validationFailed = false | ||
|
||
const command = ffmpeg(options.path) | ||
.addOption('-loglevel', 'error') | ||
.addOption('-f', 'null') | ||
.output('/dev/null') | ||
.on('stderr', () => { | ||
if (validationFailed) { | ||
return command.kill('SIGKILL') | ||
} | ||
validationFailed = true | ||
}) | ||
|
||
await runCommand({ command, job: options.job }) | ||
|
||
if (validationFailed) { | ||
throw Error(`Video validation failed for file ${options.path}`) | ||
} | ||
} | ||
|
||
export { | ||
validateVideoFile | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters