Skip to content

[from SO|kesh] inquiry #1

Description

@tikuma-lsuhsc

Hey @antortjim, this is kesh from SO,

This is a solicitation message, but if you find it useful, I'd be thrilled.

I've been developing a Python FFmpeg package called ffmpegio mostly for my research use (analyses of human voice disorders), but I'm hoping to find others who would use it. It seems like your FFmpeg use case with camera recording matches up well. Below is a quick take on how it could be used with pypylon

from pypylon import pylon
import ffmpegio

camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
camera.Open()

# camera setup goes here

with ffmpegio.open(
    "output.mp4", # output file
    "wv",           # mode: video write
    rate_in=45,  # input video framerate
    vsync_in=0, # not sure you need this, but specify input FFmpeg options with '_in' appendix (drop '-' prefix )
    extra_hw_frames_in=2,
    overwrite=True, # sets '-y' flag
    vcodec="h264_nvenc", # output option, just drop '-' prefix.
) as mp4:
    while camera.IsGrabbing():
        grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)
        if grabResult.GrabSucceeded():
            img = (
                grabResult.GetArrayZeroCopy()
            )  # or GetArray() ?
            # Make sure img shape is [nframes x h x w x ncomp] If grayscale, could be [nframes x h x w]

            mp4.write(img)
            # `-s` and `-pix_fmt` FFmpeg options will be set according to the first frame written

        grabResult.Release()
camera.Close()

Thanks for reading! -Kesh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions