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

Extracting frames from a specific offset using go-media API #37

Open
itallix opened this issue Aug 2, 2024 · 3 comments
Open

Extracting frames from a specific offset using go-media API #37

itallix opened this issue Aug 2, 2024 · 3 comments
Labels
question Further information is requested

Comments

@itallix
Copy link

itallix commented Aug 2, 2024

Hi,

I need to extract frames from a video starting at a specific offset. In the command line, this is typically done using the ss parameter in ffmpeg, e. g.: ffmpeg -ss 333300ms ...
I am wondering if there is an easy way to achieve this using the go-media API available in pkg, or if this functionality is only accessible using the bindings from the sys package?

If possible, could you provide any sample code or guidance on how to implement this using go-media?

Thank you for your assistance!

@djthorpe
Copy link
Member

djthorpe commented Aug 2, 2024 via email

@djthorpe djthorpe added the question Further information is requested label Aug 2, 2024
@itallix
Copy link
Author

itallix commented Aug 2, 2024

Hi Vitalii Sure the example you want is this one: https://github.com/mutablelogic/go-media/blob/main/cmd/examples/decode/main.go The decode method returns a frame from the media file and that has a method Ts() which returns the current timestamp in seconds so you can ignore frames up to that point. It would be more efficient to add a Seek() method to the media file but I didn't implement that yet. Let me know if you have any other questions

@djthorpe thank you for your response.

I reviewed the sample you highlighted, but it's not going to work efficiently for my use case, where I need to capture sets of frames with a specific offset in batches (e.g., from frame N to N + 200, skipping every X frames).

I will likely reuse your bindings for now. Do you have any plans to support ffmpeg7?

@djthorpe
Copy link
Member

djthorpe commented Aug 5, 2024

Hi not sure the ffmoeg7 API is tons different so it may work. If there are significant differences when you try let me know. When I have some time I can create a seek method for file-based media that objects. In the meantime there might be a packet-based decode function (or I can easily add it) which allows you to skip forward quickly, but otherwise there should be enough sample code in the repo to allow you to use the bindings directly.

Let me know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants