forked from kenmingwang/azusa-player
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from lovegaoshi/dev-noxplayer
feat: ffmpeg
- Loading branch information
Showing
9 changed files
with
57 additions
and
114 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
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
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
Submodule azusa-player-mobile
updated
from eda71e to 52b35c
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
import { FFmpeg } from '@ffmpeg/ffmpeg'; | ||
import { fetchFile } from '@ffmpeg/util'; | ||
|
||
const ffmpeg = new FFmpeg(); | ||
let r128gain = 0; | ||
|
||
ffmpeg.on('log', ({ message }) => { | ||
const parseTrackGain = /track_gain = (-?\d+\.\d+) dB/.exec(message); | ||
if (parseTrackGain !== null) { | ||
// eslint-disable-next-line prefer-destructuring | ||
r128gain = Number(parseTrackGain[1]!); | ||
} | ||
console.debug(message); | ||
}); | ||
await ffmpeg.load({ | ||
coreURL: chrome.runtime.getURL('js/ffmpeg-core.js'), | ||
}); | ||
|
||
export default async (url: string) => { | ||
await ffmpeg.writeFile('temp.m4a', await fetchFile(url)); | ||
await ffmpeg.exec([ | ||
'-nostats', | ||
'-i', | ||
'temp.m4a', | ||
'-filter_complex', | ||
'replaygain', | ||
'-f', | ||
'null', | ||
'-', | ||
]); | ||
console.log(`[r128gain] found r128gain: ${r128gain}`); | ||
return r128gain; | ||
}; |
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
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