Skip to content

Commit

Permalink
Revert "[BDGR-168] Fix jobrunner under newer versions of ffmpeg (#469)"
Browse files Browse the repository at this point in the history
This reverts commit d009bc3.
  • Loading branch information
markspolakovs authored Jul 8, 2024
1 parent d009bc3 commit 33447fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:

- uses: FedericoCarboni/setup-ffmpeg@v3
with:
ffmpeg-version: "release"
ffmpeg-version: "5.1.1" # TODO: https://linear.app/ystv/issue/BDGR-168/jobrunner-broken-under-ffmpeg-60

- run: docker compose up -d

Expand Down Expand Up @@ -264,7 +264,7 @@ jobs:

- uses: FedericoCarboni/setup-ffmpeg@v3
with:
ffmpeg-version: "release"
ffmpeg-version: "5.1.1" # TODO: https://linear.app/ystv/issue/BDGR-168/jobrunner-broken-under-ffmpeg-60

- name: Build server
run: |
Expand Down
22 changes: 5 additions & 17 deletions jobrunner/src/jobs/ProcessMediaJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,28 +361,16 @@ export default class ProcessMediaJob extends MediaJobCommon {
const cmd1 = `${process.env.FFMPEG_PATH ?? "ffmpeg"} -hide_banner -nostats -loglevel info -i ${rawPath} -af loudnorm=print_format=json -f null -`;
this.logger.debug("Running: " + cmd1);
const output = await exec(cmd1);
// Find the loudnorm output. This is a bit hacky.
// Look for a line that starts with "{" followed by a newline
const loudnormStart = output.stderr.indexOf("\n{\n");

if (loudnormStart === -1) {
// Find the loudnorm output. It's a bit of JSON immediately after a line like `[Parsed_loudnorm_0 @ 0x600003670fd0]`
const loudnormJSON =
/(?<=\[Parsed_loudnorm_0 @ 0x[0-9a-f]+]\s*\n)[\s\S]*/.exec(output.stderr);
if (!loudnormJSON) {
this.logger.warn(output.stderr);
throw new Error(
"Could not find loudnorm output - file may have no or corrupt audio",
);
}
const loudnormEnd = output.stderr.indexOf("\n}\n", loudnormStart);
if (loudnormEnd === -1) {
this.logger.warn(output.stderr);
throw new Error(
"Could not find end of loudnorm output - file may have no or corrupt audio",
);
}
const loudnormJSON = output.stderr.slice(
loudnormStart + 1,
loudnormEnd + 2,
);
const loudnormData: LoudnormOutput = JSON.parse(loudnormJSON);
const loudnormData: LoudnormOutput = JSON.parse(loudnormJSON[0]);

// Ensure we don't fail if the file has no audio at all
if (loudnormData.input_i === "-inf") {
Expand Down

0 comments on commit 33447fe

Please sign in to comment.