Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding videos samples with different resolutions #18

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 91 additions & 26 deletions test/framefusion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,51 @@ const TEST_SERVER_PORT = 4242;
expect.extend({ toMatchImageSnapshot });

const TEST_VIDEO = './test/samples/bbb10m.mp4';
const TEST_VIDEO_WIDTH = 1920;
const TEST_VIDEO_HEIGHT = 1080;

const TEST_VIDEO_MEDIUM = './test/samples/bbb-medium.mp4';
const TEST_VIDEO_MEDIUM_WIDTH = 720;
const TEST_VIDEO_MEDIUM_HEIGHT = 406;

const TEST_VIDEO_SMALL = './test/samples/bbb-small.mp4';
const TEST_VIDEO_SMALL_WIDTH = 480;
const TEST_VIDEO_SMALL_HEIGHT = 270;

const TEST_VIDEO_SMALLER = './test/samples/bbb-smaller.mp4';
const TEST_VIDEO_SMALLER_WIDTH = 384
const TEST_VIDEO_SMALLER_HEIGHT = 216

const TEST_VIDEO_COUNT_TO_60 = './test/samples/countTo60.mp4';
const TEST_VIDEO_COUNT_TO_60_WIDTH = 24;
const TEST_VIDEO_COUNT_TO_60_HEIGHT = 24;

const TEST_VIDEO_LOW_FRAMERATE = './test/samples/bbb-low-fps.mp4';

const ALL_TEST_VIDEOS = [
TEST_VIDEO,
TEST_VIDEO_MEDIUM,
TEST_VIDEO_SMALL,
TEST_VIDEO_SMALLER,
TEST_VIDEO_COUNT_TO_60
]

const ALL_TEST_VIDEO_WIDTHS = [
TEST_VIDEO_WIDTH,
TEST_VIDEO_MEDIUM_WIDTH,
TEST_VIDEO_SMALL_WIDTH,
TEST_VIDEO_SMALLER_WIDTH,
TEST_VIDEO_COUNT_TO_60_WIDTH
]

const ALL_TEST_VIDEO_HEIGHTS = [
TEST_VIDEO_HEIGHT,
TEST_VIDEO_MEDIUM_HEIGHT,
TEST_VIDEO_SMALL_HEIGHT,
TEST_VIDEO_SMALLER_HEIGHT,
TEST_VIDEO_COUNT_TO_60_HEIGHT
]

// TODOS
// There are a few sleeps (timeouts) to probably remove

Expand Down Expand Up @@ -62,7 +104,7 @@ describe('framefusion', () => {
server.close();
});

it('Should get duration', async() => {
it('should get duration', async() => {
// Arrange
const extractor = await BeamcoderExtractor.create({
inputFileOrUrl: TEST_VIDEO,
Expand All @@ -79,40 +121,64 @@ describe('framefusion', () => {
extractor.dispose();
});

it('should get width', async() => {
// Arrange
const extractor = await BeamcoderExtractor.create({
inputFileOrUrl: TEST_VIDEO,
outputFile: './output/frame-%04d.png',
});
it('should get source width', async () => {
for (let i = 0; i < ALL_TEST_VIDEOS.length; i++) {
// Arrange
const extractor = await BeamcoderExtractor.create({
inputFileOrUrl: ALL_TEST_VIDEOS[i],
outputFile: './output/frame-%04d.png'
});

// Act
const width = extractor.width;
// Act
const width = extractor.width;

// Assert
expect(width).to.eq(1920);
// Assert
expect(width).to.eq(ALL_TEST_VIDEO_WIDTHS[i]);

// Cleanup
extractor.dispose();
// Cleanup
extractor.dispose();
}
});

it('Should get height', async() => {
// Arrange
const extractor = await BeamcoderExtractor.create({
inputFileOrUrl: TEST_VIDEO,
outputFile: './output/frame-%04d.png',
});
it('should get source height', async () => {
for (let i = 0; i < ALL_TEST_VIDEOS.length; i++) {
// Arrange
const extractor = await BeamcoderExtractor.create({
inputFileOrUrl: ALL_TEST_VIDEOS[i],
outputFile: './output/frame-%04d.png'
});

// Act
const height = extractor.height;
// Act
const height = extractor.height;

// Assert
expect(height).to.eq(1080);
// Assert
expect(height).to.eq(ALL_TEST_VIDEO_HEIGHTS[i]);

// Cleanup
extractor.dispose();
// Cleanup
extractor.dispose();
}
});

it('should get frame dimensions', async() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antoineMoPa, so this is very surprising since they all pass. Do you know of any sources which didn't match?

for (let i = 0; i < ALL_TEST_VIDEOS.length; i++) {
// Arrange
const extractor = await BeamcoderExtractor.create({
inputFileOrUrl: ALL_TEST_VIDEOS[i],
outputFile: './output/frame-%04d.png'
});

// Act
const frame = await extractor.getFrameAtTime(0);

// Assert
expect(frame.width).to.eq(ALL_TEST_VIDEO_WIDTHS[i]);
expect(frame.height).to.eq(ALL_TEST_VIDEO_HEIGHTS[i]);

// Cleanup
extractor.dispose();
}
})

describe('Continuous dumping', () => {
it('Should dump an entire mp4 [smaller video version]', async() => {
// Arrange
Expand Down Expand Up @@ -437,7 +503,6 @@ describe('framefusion', () => {
extractor.dispose();
}, 200000);


it('Should open a file from the network and dump all frames [smaller video version]', async() => {
// Arrange
const extractor = await BeamcoderExtractor.create({
Expand Down
Binary file added test/samples/bbb-medium.mp4
Binary file not shown.
Binary file added test/samples/bbb-small.mp4
Binary file not shown.