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

What's the best approach for recording a single screenshot? #51

Open
ShetlandJ opened this issue Mar 26, 2021 · 1 comment
Open

What's the best approach for recording a single screenshot? #51

ShetlandJ opened this issue Mar 26, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@ShetlandJ
Copy link

ShetlandJ commented Mar 26, 2021

Hey Steve, I was wondering if you had a "best practice" timecut options screenshot example you could share with me? I'm using this for video render:


const render = (io, payload) => {
    const { mediaType, extension, duration } = payload.data.renderOptions;
    timecut({
        url: myUrlVariable,
        viewport: {
            width: 1920,
            height: 1080
        },
        fps: 25,
        duration,
        transparentBackground: true,
        pipeMode: true,
        outputOptions: ['-c:v', 'prores_ks', '-pix_fmt', 'yuva444p10le'],
        screenshotType: 'jpeg',
        output: `renders/${payload.fileId}.${extension ? extension : 'mov'}`,
        logger: (message) => {
            io.emit('timecut', {
                message: getMessage(message)
            });
        },
        preparePageForScreenshot: (page, num1, num2) => {
            console.log(page, num1, num2); // <--- What do I do here?
            return Promise.resolve();
        }
    }).then(function() {
        console.log('Done!');
    });
};

Do I just set the FPS to 1 and duration to 1? Just trying to see if I need to use a totally different function or if I can just reply on passed args.

@ShetlandJ ShetlandJ added the enhancement New feature or request label Mar 26, 2021
@tungs
Copy link
Owner

tungs commented Mar 28, 2021

Using timesnap (recommended)

timesnap would probably be the cleanest approach and is meant to take screenshots. In this case, you'd want to use the config.frames argument set to 1, and using the config.outputPattern to something like "screenshot.jpg", and omit duration. The API is pretty similar, so you can reuse most of the timecut config, but you should probably omit the timecut specific properties like pipeMode, outputOptions, and output. While they currently won't be used by timesnap, in the future they might be.

Using timecut (not recommended)

timecut is meant for videos and isn't really meant for taking screenshots (though you can probably do something with --keep-frames or keepFrames, though it doesn't work with pipeMode). It might be possible to save a particular frame while capturing the video if there would be some sort of function that would process frames, e.g. config.frameProcessor like in timesnap, but there currently isn't in timecut. Alternatively, you might be able to do something with preparePageForScreenshot by using the page.screenshot method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants