From 7254a4aad5f1c5e4cf1adc87e4654462f30be240 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 15 Oct 2020 17:30:19 -0700 Subject: [PATCH] Fix transcoding errors in readonly docker containers ffmpeg seems to create some temporary files in the cwd. When PeerTube is run in a read-only docker container, this causes all transcoding to fail. As a workaround, we set the cwd to the configured tmp dir. --- package.json | 2 +- server/helpers/ffmpeg-utils.ts | 3 ++- yarn.lock | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5feb9e8f93bf..c2dd24170c87 100644 --- a/package.json +++ b/package.json @@ -166,7 +166,7 @@ "@types/config": "^0.0.36", "@types/express": "^4.0.35", "@types/express-rate-limit": "^5.0.0", - "@types/fluent-ffmpeg": "^2.1.8", + "@types/fluent-ffmpeg": "2.1.14", "@types/fs-extra": "^9.0.1", "@types/libxmljs": "^0.18.0", "@types/lodash": "^4.14.64", diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 7bfd5d44acce..02c66cd014cc 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -270,7 +270,8 @@ type TranscodeOptions = function transcode (options: TranscodeOptions) { return new Promise(async (res, rej) => { try { - let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING }) + // we set cwd explicitly because ffmpeg appears to create temporary files when trancoding which fails in read-only file systems + let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING, cwd: CONFIG.STORAGE.TMP_DIR }) .output(options.outputPath) if (options.type === 'quick-transcode') { diff --git a/yarn.lock b/yarn.lock index e04a94a95725..3c0fc3b006a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -591,7 +591,7 @@ "@types/qs" "*" "@types/serve-static" "*" -"@types/fluent-ffmpeg@^2.1.8": +"@types/fluent-ffmpeg@2.1.14": version "2.1.14" resolved "https://registry.yarnpkg.com/@types/fluent-ffmpeg/-/fluent-ffmpeg-2.1.14.tgz#b21d60267fe269c2ea81fa3238a36a8349f8f2f3" integrity sha512-nJrAX9ODNI7mUB0b7Y0Stx1a6dOpV3zXsOnWoBuEd9/woQhepBNCMeCyOL6SLJD3jn5sLw5ciDGH0RwJenCoag==