[FFmpeg-devel] [PATCH] ffmpeg: block output == input for files

Michael Niedermayer michael at niedermayer.cc
Wed Aug 29 00:13:31 EEST 2018


On Tue, Aug 28, 2018 at 08:31:51AM +0200, Marton Balint wrote:
> 
> 
> On Tue, 28 Aug 2018, Gyan Doshi wrote:
> 
> >
> >With some regularity, we have users trying to update input files using
> >ffmpeg, usually for the purposes of tagging, but occasionally for changing
> >the encoding or something else. Other apps like mp4box or taggers edit the
> >files in-place i.e. destination file is same as the source. FFmpeg cannot
> >do this. But since these users don't realize that, they will answer Yes to
> >the overwrite prompt and then discover their source has been destroyed.
> >
> >Attached patch checks the URL for file protocol outputs against inputs and
> >aborts upon a match. An option is provided for the user to force the
> >operation.
> >
> >The check isn't robust. In particular, it looks for exact url string
> >matches, so a command like
> >
> >   ffmpeg -i file:somefile -some_op somefile
> >
> >will still pass through. But I consider such invocations rare. Most times
> >I've seen users trying this (on Stackexchange or other support forums),
> >the command is typically of the form,
> >
> >   for i; do ffmpeg -i $i -some_op -y $i
> >
> >Such a scenario was filed as a bug in #4655 but it was marked as wontfix
> >since some protocols/services can manage bidir ops to the same endpoint.
> >For that reason, everything other than file protocol sources/sinks are
> >exempt i.e. http, pipes, devices..etc.
> >
> >This patch doesn't affect the semantics of '-y' and adds the check after it.
> 
> Instead of this, maybe we should add support to write lock the files when
> opening them for reading. Then ffmpeg can request this. That would be an
> useful option, and not just for unexperienced users.

depending on how this is done, it could interfere with reading a file while
it is being written/appeneded to by another process

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180828/e9c34ec4/attachment.sig>


More information about the ffmpeg-devel mailing list