feature proposal - avoid overwriting the input file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

feature proposal - avoid overwriting the input file

Mikhail V
James Girotti wrote:

> On Tue, Oct 10, 2017 at 4:40 PM, Mikhail V <mikhailwas at gmail.com> wrote:
>
> > Currently it is possible to delete the input file if I specify same
> > filename in output,
> > for example:
> >
> > ffmpeg -y -i input input
> >
>
> Aren't you specifying that with '-y' you want to "overwrite output file
> without asking"

Sure, I am. But anybody can miss the typo, and its not so easy to
notice in console or text editor, its just two chars
in a pile of chars.

>
>
> > or simply:
> > ffmpeg -i input input
> > (this will promt y/n)
> >
>
> I believe this is the default behavior for any output file that is present
> whether it matches input or not (in my example both foo.mkv and bar.mkv
> file present):

I see your point, yes I can do it with any existing file so there is no
fool-proof for general case.
But you know, if I delete some wrong output file, then still I have some
consolation because I don't lose the input file :)
Losing some random output file is not so bad usually from my
experience because I probably notice somthing gone wrong within short time
 and sources for that file still (hopefully) exist.


> > Was quite funny actually :) Funniest thing that I could not recover the
> > file
> > because it is same name.
> >
>
> That reminds me of when I accidentally did 'rm -rf /*'

Yeh, wrong batch renaming can cause  a lot of interesting
situations.

> >
> > So, it would be nice if ffmpeg compare the output path with all input paths
> > and exit with an error.
> >
>
> Is it possible for you to run your command without '-y' or if you're using
> a script, then to compare your input and output before passing them to
> ffmpeg?

Actually this happened to me without '-y'. That time I have
just reflexively typed 'y' and enter when prompted [Y/N].
And I can understand because this reflex of mine was trained by
doing a lot of trial-and error encodings in the past. In batch scripts
I never use '-y'
options.
Probability of such accident raises when copy-pasting file paths
from a file manager into ready full command line strings.

And what I am wondering, what can be really *against* such
feature.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: feature proposal - avoid overwriting the input file

Douglas Marsh
On 2017-10-10 18:18, Mikhail V wrote:
> James Girotti wrote:
> Sure, I am. But anybody can miss the typo, and its not so easy to
> notice in console or text editor, its just two chars
> in a pile of chars.


Perhaps then add a new switch.. something *like*

$ ffmpeg -i input.mp4 [...] -yo output.mov


(for "Yes Output/Overwrite" where the parameter that MUST come next is
the filename)

and the following example would NOT work:

$ ffmpeg -yo -i input/mp4 [...] output.mov

as -yo has no parameter [the filename to overwrite] and assuming
"output.mov" exist so it would not overwrite without prompt. The order
shouldn't overly matter as the following COULD work:

$ ffmpeg -yo output.mov -i input.mp4 [...]


Just an idea.


--Doug (dx9s)
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: feature proposal - avoid overwriting the input file

DopeLabs
ffmpeg commands are all structured in a specific and standardized way

a few bits from the description on the man page

ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...

ffmpeg reads from an arbitrary number of input "files" (which can be regular files, pipes, network streams, grabbing devices, etc.), specified by the "-i" option, and writes to an arbitrary number of output
"files", which are specified by a plain output url. Anything found on the command line which cannot be interpreted as an option is considered to be an output url.

Each input or output url can, in principle, contain any number of streams of different types (video/audio/subtitle/attachment/data). The allowed number and/or types of streams may be limited by the container
format. Selecting which streams from which inputs will go into which output is either done automatically or with the "-map" option (see the Stream selection chapter).

To refer to input files in options, you must use their indices (0-based). E.g.  the first input file is 0, the second is 1, etc. Similarly, streams within a file are referred to by their indices. E.g. "2:3"
refers to the fourth stream in the third input file. Also see the Stream specifiers chapter.

As a general rule, options are applied to the next specified file. Therefore, order is important, and you can have the same option on the command line multiple times. Each occurrence is then applied to the
next input or output file.  Exceptions from this rule are the global options (e.g. verbosity level), which should be specified first.

Do not mix input and output files -- first specify all input files, then all output files. Also do not mix options which belong to different files. All options apply ONLY to the next input or output file and
are reset between files.


in your example

> $ ffmpeg -i input.mp4 [...] -yo output.mov

ffmpeg -i input.mp4 [..] output.mov

works just fine no need to add -y because .mov is a different filename

> $ ffmpeg -yo output.mov -i input.mp4 [...]

is incorrect structure for ffmpeg...

> The order shouldn't overly matter

it matters... see above



> On Oct 11, 2017, at 8:39 06AM, Douglas Marsh <[hidden email]> wrote:
>
> On 2017-10-10 18:18, Mikhail V wrote:
>> James Girotti wrote:
>> Sure, I am. But anybody can miss the typo, and its not so easy to
>> notice in console or text editor, its just two chars
>> in a pile of chars.
>
>
> Perhaps then add a new switch.. something *like*
>
> $ ffmpeg -i input.mp4 [...] -yo output.mov
>
>
> (for "Yes Output/Overwrite" where the parameter that MUST come next is the filename)
>
> and the following example would NOT work:
>
> $ ffmpeg -yo -i input/mp4 [...] output.mov
>
> as -yo has no parameter [the filename to overwrite] and assuming "output.mov" exist so it would not overwrite without prompt. The order shouldn't overly matter as the following COULD work:
>
> $ ffmpeg -yo output.mov -i input.mp4 [...]
>
>
> Just an idea.
>
>
> --Doug (dx9s)
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: feature proposal - avoid overwriting the input file

Douglas Marsh
On 2017-10-11 11:01, DopeLabs wrote:

> ffmpeg commands are all structured in a specific and standardized way
>
> [...]
>
> in your example
>
>> $ ffmpeg -i input.mp4 [...] -yo output.mov
>
> ffmpeg -i input.mp4 [..] output.mov
>
> works just fine no need to add -y because .mov is a different filename
>

I think you missed the point, but I see your point as well. I guess the
question should have been worded differently. Should the "-y (global)
Overwrite output files without asking." be enough? Or would there be a
market for specifying single files? (-yo [explicitly state a single
file]) ... Most people are not outputting more than one file (I am
guessing) but for those that do output to several files, is it easier to
just delete the files previous to encoding multiple outputs? Edge case
would be two-pass (or more) encoding where first pass output is
something like "-f mp4 /dev/null" where you get "do you want to
overwrite /dev/null" (something to that effect).

Perhaps this is such a weird edge case that a global option and/or
simply removing files previous to encoding is preferred. The
'overwriting' /dev/null thing is a bit of an odd-duck (really
edge-case).


--Doug (dx9s)



_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: feature proposal - avoid overwriting the input file

Carl Eugen Hoyos-2
2017-10-16 23:34 GMT+02:00 Douglas Marsh <[hidden email]>:
> Should the "-y (global)
> Overwrite output files without asking." be enough?

Definitely.

Discussing this further here makes no sense, feel
free to send a patch to the development mailing
list that changes the current behaviour.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".