When I run the following command:
/snap/bin/ffmpeg -y -rtsp_transport udp -i 'rtsp://url' -vf scale=1024:-1 -ss 00:00:01 -vframes 1 /home/administrator/camera1/preview.jpg
It takes a snapshot of the rtsp stream like intended, the problem is that when I run it as root, I get the following error
[image2 @ 0x556426863040] Could not open file : /home/administrator/camera1/preview.jpg
av_interleaved_write_frame(): Input/output error
Which is strange because when I had ffmpeg installed using apt I didn't have this issue and because I thought running as root should have permission problems.
I confirmed that this is a problem with file ownership by creating another directory owned by root and didn't run into this problem.
I thought this could be related to this, but even after I added ffmpeg:removable-media snap connection, I didn't notice any changes.
Why is this happening? and what can I do to have it normally (I mean ffmpeg with sudo not having issues writing into other users directories)?
PS.I'm running Ubuntu