Commit 8c4cf7f6 authored by Jerome Wu's avatar Jerome Wu

Refactor wasm/tests

parent 2811f758
......@@ -4,7 +4,7 @@ const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'audio-1s.wav';
const OUT_FILE_NAME = 'audio.aac';
const AAC_SIZE = 4239;
const FILE_SIZE = 4239;
let wavData = null;
beforeAll(() => {
......@@ -14,5 +14,5 @@ beforeAll(() => {
test('convert wav to aac', async () => {
const args = ['-i', IN_FILE_NAME, '-c:a', 'libfdk_aac', OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, wavData, args, OUT_FILE_NAME);
expect(fileSize).toBe(AAC_SIZE);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
......@@ -4,7 +4,7 @@ const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'audio-1s.wav';
const OUT_FILE_NAME = 'audio.mp3';
const MP3_SIZE = 4039;
const FILE_SIZE = 4039;
let wavData = null;
beforeAll(() => {
......@@ -14,5 +14,5 @@ beforeAll(() => {
test('convert wav to mp3', async () => {
const args = ['-i', IN_FILE_NAME, OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, wavData, args, OUT_FILE_NAME);
expect(fileSize).toBe(MP3_SIZE);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
......@@ -5,8 +5,8 @@ const { runFFmpeg } = require('./utils');
const aviFilePath = path.join(__dirname, 'data', 'video-1s.avi');
const IN_FILE_NAME = 'video-1s.avi';
const OUT_FILE_NAME = 'video.webm';
const WEBM_SIZE = 41904;
const WEBM_SIZE_MT = 41878;
const FILE_SIZE = 41904;
const FILE_MT_SIZE = 41878;
let aviData = null;
let BASELINE_TIME = 0;
......@@ -19,7 +19,7 @@ test('transcode avi to vp9 webm', async () => {
const start = Date.now();
const { fileSize } = await runFFmpeg(IN_FILE_NAME, aviData, args, OUT_FILE_NAME);
BASELINE_TIME = Date.now() - start;
expect(fileSize).toBe(WEBM_SIZE);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
test('transcode avi to vp9 webm with multithread', async () => {
......@@ -27,6 +27,6 @@ test('transcode avi to vp9 webm with multithread', async () => {
const start = Date.now();
const { fileSize } = await runFFmpeg(IN_FILE_NAME, aviData, args, OUT_FILE_NAME);
const timediff = Date.now() - start;
expect(fileSize).toBe(WEBM_SIZE_MT);
expect(fileSize).toBe(FILE_MT_SIZE);
expect(timediff < BASELINE_TIME).toBe(true);
}, TIMEOUT);
......@@ -4,7 +4,7 @@ const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'video-1s.avi';
const OUT_FILE_NAME = 'video.ogv';
const OGV_SIZE = 29561;
const FILE_SIZE = 29561;
let aviData = null;
beforeAll(() => {
......@@ -14,5 +14,5 @@ beforeAll(() => {
test('convert avi to ogv', async () => {
const args = ['-i', IN_FILE_NAME, '-c:v', 'libtheora', OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, aviData, args, OUT_FILE_NAME);
expect(fileSize).toBe(OGV_SIZE);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
......@@ -4,7 +4,7 @@ const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'audio-1s.wav';
const OUT_FILE_NAME = 'audio.ogg';
const OGG_SIZE = 7712;
const FILE_SIZE = 7712;
let wavData = null;
beforeAll(() => {
......@@ -14,5 +14,5 @@ beforeAll(() => {
test('convert wav to aac', async () => {
const args = ['-i', IN_FILE_NAME, '-c:a', 'libvorbis', OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, wavData, args, OUT_FILE_NAME);
expect(fileSize).toBe(OGG_SIZE);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
......@@ -4,7 +4,7 @@ const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'audio-1s.wav';
const OUT_FILE_NAME = 'audio.wv';
const WV_SIZE = 23502;
const FILE_SIZE = 23502;
let wavData = null;
beforeAll(() => {
......@@ -14,5 +14,5 @@ beforeAll(() => {
test('convert wav to wv', async () => {
const args = ['-i', IN_FILE_NAME, OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, wavData, args, OUT_FILE_NAME);
expect(fileSize).toBe(WV_SIZE);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
......@@ -4,7 +4,7 @@ const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'video-1s.avi';
const OUT_FILE_NAME = 'video.mp4';
const MP4_SIZE = 38372;
const FILE_SIZE = 38372;
let aviData = null;
beforeAll(() => {
......@@ -14,5 +14,5 @@ beforeAll(() => {
test('transcode avi to x264 mp4', async () => {
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);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
......@@ -4,9 +4,8 @@ const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'video-1s.avi';
const OUT_FILE_NAME = 'video.mp4';
const MP4_10BIT_SIZE1 = 22507;
const MP4_10BIT_SIZE2 = 22520;
const MP4_12BIT_SIZE = 22718;
const FILE_10BIT_SIZES = [22507, 22520];
const FILE_12BIT_SIZE = 22718;
let aviData = null;
beforeAll(() => {
......@@ -16,11 +15,11 @@ beforeAll(() => {
test('transcode avi to x265 10bit mp4', async () => {
const args = ['-i', IN_FILE_NAME, '-c:v', 'libx265', '-pix_fmt', 'yuv420p10le', OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, aviData, args, OUT_FILE_NAME);
expect(fileSize === MP4_10BIT_SIZE1 || fileSize === MP4_10BIT_SIZE2).toBe(true);
expect(FILE_10BIT_SIZES.includes(fileSize)).toBe(true);
}, TIMEOUT);
test('transcode avi to x265 12bit mp4', async () => {
const args = ['-i', IN_FILE_NAME, '-c:v', 'libx265', '-pix_fmt', 'yuv420p12le', OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, aviData, args, OUT_FILE_NAME);
expect(fileSize).toBe(MP4_12BIT_SIZE);
expect(fileSize).toBe(FILE_12BIT_SIZE);
}, TIMEOUT);
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