[FFmpeg-user] watch a folder for new images

Michael Koch astroelectronic at t-online.de
Mon Jan 31 13:04:19 EET 2022

Am 31.01.2022 um 11:22 schrieb Adam Nielsen via ffmpeg-user:
>> The best solution would be if something like fileSystemWatcher could be
>> added to FFmpeg.
>> Below is a C# example for fileSystemWatcher.
> FFmpeg is written in C++.  Windows, Mac and Linux each have a different
> method for watching the filesystem change.  Do you have any example C++
> code that works across each operating system FFmpeg runs on?

sorry, I don't have a C++ example. I agree that it's difficult to find a 
solution that works with all operating systems.

> Instead of trying to repurpose FFmpeg to make it your whole application,
> you could try making your application work with FFmpeg.  You could watch
> the filesystem in your own code and when a new file appears, launch
> ffmpeg as needed.

That's an option, but then there is no continuous output visible.

> Failing that, another option is to use two instances of ffmpeg.  One
> (which your program calls when each new file appears) encodes the frame
> and sends it over a UDP socket, and the second ffmpeg instance simply
> streams video from the UDP socket.  This should work well in your case
> because if no UDP traffic is coming in, the second ffmpeg instance will
> simply continue to display the last frame.

Yes, I agree that's an option.

> However I do wonder whether FFmpeg is the best choice here for
> displaying the final video.  It almost seems like it would be better to
> have ffmpeg launch when a new file appears, write the result of the
> transformation out to another new image file, then use some kind of
> image viewer to pick up and display those second sets of images.  I
> wouldn't be surprised if some image viewers already supported watching
> the filesystem and reloading the image if the file changed, which would
> greatly simplify your problem and wouldn't require any changes to
> FFmpeg.

Yes, there are image viewers which automatically reload a file when it 
has been changed. For example "FastStone Image Viewer".

Well, the easiest solution seems to make all in C#. FileSystemWatcher, 
load the image, extract the corners, enlarge them, show the result on 
the screen.


More information about the ffmpeg-user mailing list