[FFmpeg-user] watch a folder for new images

Michael Koch astroelectronic at t-online.de
Sun Jan 30 15:32:29 EET 2022


Am 30.01.2022 um 14:06 schrieb Michael Koch:
> Am 30.01.2022 um 09:49 schrieb Michael Koch:
>> Am 30.01.2022 um 05:28 schrieb Gyan Doshi:
>>>
>>>
>>> On 2022-01-30 02:11 am, Michael Koch wrote:
>>>> Am 29.01.2022 um 20:36 schrieb Michael Koch:
>>>>> Hello,
>>>>>
>>>>> is it possible to watch a folder for new images (like 
>>>>> fileSystemWatcher in C#), and if a new image appears, then load it 
>>>>> in FFmpeg? The question is for Windows.
>>>>> Very large PNG images (about 30 Megapixels) are written to the 
>>>>> folder every 5 seconds. I want to load these images, extract the 
>>>>> four corners, enlarge them by a factor 10, stack the four images 
>>>>> together and show the result on the screen, until the next image 
>>>>> appears. The filtering is no problem, the question is only how to 
>>>>> watch the folder for new images.
>>>>
>>>> I did try to read the same image again and again with this command 
>>>> line:
>>>>
>>>> ffmpeg -loop 1 -i input.png -window_x 0 -window_y 0 -f sdl2 -
>>>>
>>>> I was hoping that I could overwrite the input image by another 
>>>> image, but that doesn't work. Access denied, because the file is 
>>>> open in FFmpeg.
>>>
>>> Use -stream_loop -1 instead of loop.  Update the image atomically 
>>> i.e. not during a read window.. Best way to update is to create a 
>>> symlink and use that as input. Repoint the symlink when the new 
>>> image file is ready.
>>>
>>
>> I did create a symlink which is pointing to a PNG image. When I 
>> double click on the symlink, the image is shown.
>> But something must be wrong in my FFmpeg command line.
>>
>> ffmpeg -framerate 1 -stream_loop -1 -i symlink.lnk -window_x 0 
>> -window_y 0 -f sdl2 -
>>
>> I get this error message:
>> symlink.lnk: Invalid data found when processing input
>>
>
> In the meantime I found out that the symlink has to be created with 
> administrator rights and mklink.
> Now FFmpeg does read the symlink and show the image.
> I found your answer here:
> https://stackoverflow.com/questions/11296491/change-target-for-symbolic-link-in-windows 
>
>
> The problem is that FFmpeg seems to read the link only one time. When 
> I change the link target (while FFmpeg is running) with the copy 
> command, the link is actually changed but FFmpeg is still showing the 
> first image.
> When I stop and restart FFmpeg, then it shows the new image.

The problem is solved. It works after I added  -f image2 to the command 
line:
ffmpeg -framerate 1 -stream_loop -1 -f image2 -i symlink.lnk -window_x 0 
-window_y 0 -f sdl2 -

Now it's possible to change the symlink in realtime.

Michael



More information about the ffmpeg-user mailing list