[FFmpeg-user] Converting a video to a set of images from specific frames while cropping each frame differently
Matt Groth
mgroth49 at gmail.com
Tue Jun 6 18:24:21 EEST 2023
@Media Mouth, thanks for the idea. I actually would prefer python if that is possible. I just don’t know how to do it. My understanding is that the python package for ffmpeg is just a wrapper for the command line. So any limitations from the command line I thought would also exist in python.
I’m just like you, I actually avoid shells whenever possible. I started by trying the java bindings for ffmpeg since kotlin is my preferred language but the ffmpeg java library was problematic. And like I said above, I figured python was just a thin wrapper.
> On Jun 6, 2023, at 12:15 AM, Media Mouth <communque at gmail.com> wrote:
>
> I have in mind a pipeline driven by, say NodeJS or Python, running both ffmpeg & sips or imagemagick -- as opposed to a single CLI command.
> That approach more involved to the extent you have to do actual coding, but you get a lot of granular control, the ability test, iterate, and trouble-shoot quickly.
> An interesting side benefit, if you end up doing a lot of it, you can spawn the processes, making better/controlled use of your CPU/GPU.
> I'm always wowed by the 1-line CLI solutions posted here, but personally get a lot more mileage out of a coded approach.
>
>
>> On Jun 5, 2023, at 08:04, Matt Groth <mgroth49 at gmail.com> wrote:
>>
>> Thanks for the responses.
>>
>> The reason I’m eager to do it all in ffmpeg is because I am assuming that it would be most performant to both filter and crop the frames while they are held in memory before writing to any files. I understand that there are many ways I could break this down into multiple steps if I am writing intermediate steps to files. For example, I could just use select in ffmpeg but then do the cropping after with another tool such as imagemagick. However, then there is lots of excessive IO with the filesystem.
>>
>> If it cannot be done purely within ffmpeg, I wonder if there is any way this can be done with piping? I’m assuming piping a full PNG to another program to crop is faster than writing it to a file and then reading it. Would it boost performance if somehow the PNGs were piped directly into a program like imagemagick? Does anyone know what this command might look like?
>>
>>
>>> On Jun 5, 2023, at 3:06 AM, MediaMouth <communque at gmail.com> wrote:
>>>
>>>
>>>
>>>> On Jun 4, 2023, at 23:58, Michael Koch <astroelectronic at t-online.de> wrote:
>>>>
>>>> Am 05.06.2023 um 00:35 schrieb Matt Groth:
>>>>> 2) Am I facing an XY issue? Is there a more elegant/performant way to apply a separate crop per frame (while excluding some frames altogether) when there are thousands of such frames per video?
>>>>
>>>> The crop filter supports commands. That means you can write all the x and y values in a file and the use sendcmd to send these values to the crop filter.
>>>> The problem is how to select the frames, because the select filter doesn't support commands. I have no idea for this part.
>>>>
>>>> Michael
>>>
>>> Maybe consider FFmpeg to create the image files, Sips or Imagemagick to do the cropping?
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>>
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list