Commit 3011d509 authored by Jerome Wu's avatar Jerome Wu

Enable one core multiple run capabilities

parent d3499d95
......@@ -4816,11 +4816,26 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
{
}
static void init_variables() {
input_streams = NULL;
nb_input_streams = 0;
input_files = NULL;
nb_input_files = 0;
output_streams = NULL;
nb_output_streams = 0;
output_files = NULL;
nb_output_files = 0;
filtergraphs = NULL;
nb_filtergraphs = 0;
ffmpeg_exited = 0;
}
int main(int argc, char **argv)
{
int i, ret;
BenchmarkTimeStamps ti;
init_variables();
init_dynload();
register_exit(ffmpeg_cleanup);
......
const fs = require('fs');
const path = require('path');
const createFFmpegCore = require('../dist/ffmpeg-core');
const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const { runFFmpeg, ffmpeg } = require('./utils');
const IN_FILE_NAME = 'video-1s.avi';
const OUT_FILE_NAME = 'video.mp4';
const MP4_SIZE = 38372;
let aviData = null;
let resolve = null;
let Core = null;
beforeAll(() => {
beforeAll(async () => {
aviData = Uint8Array.from(fs.readFileSync(path.join(__dirname, 'data', IN_FILE_NAME)));
});
Core = await createFFmpegCore({
printErr: (m) => {
},
print: (m) => {
if (m.startsWith('FFMPEG_END')) {
resolve();
}
}
});
}, TIMEOUT);
test('should transcode to mp4 twice', async () => {
for (let i = 0 ; i < 2; i++) {
const args = ['-i', IN_FILE_NAME, OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, aviData, args, OUT_FILE_NAME);
expect(fileSize).toBe(MP4_SIZE);
Core.FS.writeFile(IN_FILE_NAME, aviData);
for (let i = 0; i < 2; i++) {
ffmpeg(Core, args);
await new Promise((_resolve) => { resolve = _resolve });
expect(Core.FS.readFile(OUT_FILE_NAME).length).toBe(MP4_SIZE);
Core.FS.unlink(OUT_FILE_NAME);
}
}, TIMEOUT);
......@@ -15,7 +15,7 @@ const ffmpeg = (Core, args) => {
'proxy_main',
'number',
['number', 'number'],
parseArgs(Core, ['ffmpeg', '-nostdin', ...args]),
parseArgs(Core, ['ffmpeg', '-hide_banner', '-nostdin', ...args]),
);
};
......@@ -44,4 +44,5 @@ const runFFmpeg = async (ifilename, data, args, ofilename) => {
module.exports = {
runFFmpeg,
ffmpeg,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment