Add libfdk_aac support
This commit is contained in:
parent
c0b98b4645
commit
8db285fe89
102
src/misc/coders/Encoders/audio/aac_libfdk.js
Normal file
102
src/misc/coders/Encoders/audio/aac_libfdk.js
Normal file
@ -0,0 +1,102 @@
|
||||
import React from 'react';
|
||||
|
||||
import Grid from '@mui/material/Grid';
|
||||
|
||||
import Audio from '../../settings/Audio';
|
||||
import Helper from '../../helper';
|
||||
|
||||
function init(initialState) {
|
||||
const state = {
|
||||
bitrate: '64',
|
||||
...initialState,
|
||||
};
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function createMapping(settings, stream, skills) {
|
||||
stream = Helper.InitStream(stream);
|
||||
skills = Helper.InitSkills(skills);
|
||||
|
||||
const local = ['-codec:a', 'libfdk_aac', '-b:a', `${settings.bitrate}k`, '-shortest'];
|
||||
|
||||
if (stream.codec === 'aac') {
|
||||
local.push('-bsf:a', 'aac_adtstoasc');
|
||||
}
|
||||
|
||||
const mapping = {
|
||||
global: [],
|
||||
local: local,
|
||||
filter: [],
|
||||
};
|
||||
|
||||
return mapping;
|
||||
}
|
||||
|
||||
function Coder(props) {
|
||||
const settings = init(props.settings);
|
||||
const stream = Helper.InitStream(props.stream);
|
||||
const skills = Helper.InitSkills(props.skills);
|
||||
|
||||
const handleChange = (newSettings) => {
|
||||
let automatic = false;
|
||||
if (!newSettings) {
|
||||
newSettings = settings;
|
||||
automatic = true;
|
||||
}
|
||||
|
||||
props.onChange(newSettings, createMapping(newSettings, stream, skills), automatic);
|
||||
};
|
||||
|
||||
const update = (what) => (event) => {
|
||||
const value = event.target.value;
|
||||
|
||||
const newSettings = {
|
||||
...settings,
|
||||
[what]: value,
|
||||
};
|
||||
|
||||
handleChange(newSettings);
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
handleChange(null);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12}>
|
||||
<Audio.Bitrate value={settings.bitrate} onChange={update('bitrate')} allowCustom />
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
|
||||
Coder.defaultProps = {
|
||||
stream: {},
|
||||
settings: {},
|
||||
skills: {},
|
||||
onChange: function (settings, mapping) {},
|
||||
};
|
||||
|
||||
const coder = 'libfdk_aac';
|
||||
const name = 'AAC (libfdk)';
|
||||
const codec = 'aac';
|
||||
const type = 'audio';
|
||||
const hwaccel = false;
|
||||
|
||||
function summarize(settings) {
|
||||
return `${name}, ${settings.bitrate} kbit/s`;
|
||||
}
|
||||
|
||||
function defaults(stream, skills) {
|
||||
const settings = init({});
|
||||
|
||||
return {
|
||||
settings: settings,
|
||||
mapping: createMapping(settings, stream, skills),
|
||||
};
|
||||
}
|
||||
|
||||
export { coder, name, codec, type, hwaccel, summarize, defaults, Coder as component };
|
||||
@ -2,6 +2,7 @@ import * as AudioCopy from './audio/copy';
|
||||
import * as AudioNone from './audio/none';
|
||||
import * as AAC from './audio/aac';
|
||||
import * as AACAudioToolbox from './audio/aac_audiotoolbox';
|
||||
import * as AACFDK from './audio/aac_libfdk';
|
||||
import * as Libopus from './audio/opus_libopus';
|
||||
import * as Libvorbis from './audio/vorbis_libvorbis';
|
||||
import * as MP3 from './audio/mp3_libmp3lame';
|
||||
@ -115,6 +116,7 @@ audioRegistry.Register(AudioCopy);
|
||||
audioRegistry.Register(AudioNone);
|
||||
audioRegistry.Register(AAC);
|
||||
audioRegistry.Register(AACAudioToolbox);
|
||||
audioRegistry.Register(AACFDK);
|
||||
audioRegistry.Register(MP3);
|
||||
audioRegistry.Register(Opus);
|
||||
audioRegistry.Register(Libopus);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user