0

What I did so far:

I learned with this answer that I can use negative mapping to remove unwanted streams (extra audio, subtitles) from my video files.

I them proceeded to apply it to a few dozen files in a folder using a simple for /r loop on Windows' cmd. Since I thought this process as some kind of trim, I didn't care about my original files and wanted ffmpeg to replace them, which of course it cannot.

I tried to search a bit further and find ways to work around this issue without simply using a new destination an manually replacing files afterwards, but had no luck.

However a lot of my findings seemed to indicate that ffmpeg has capabilities to use external temporary files for some of it's functions, even though I couldn't really find more onto it.

What I want to do:

So is there any way that I can make ffmpeg remove those extra streams and them replace the original file somehow. I'll also be needing to use this to multiple file, by I don't think this would be a big issue...

I really need this to be done with ffmpeg, as learning the tool to it's full extent is a long-therm goal of mine and I want to keep working on that curve, but as for batch/cmd, I prefer it because I haven't properly learned a programming language yet (even if I often meddle with a few), but I would be happy to use suggestions of any kind for handling ffmpeg!

Thank you!

Fabio Freitas
  • 71
  • 1
  • 9
  • 2
    As it is right now, your question is off topic. Please take the [tour]. Learn [ask] and please also read [mcve]. – Squashman Jun 15 '20 at 22:53
  • I reread those, but I still don't understand why it's off-topic. I didn't post what I'm currently using because it's not supposed to be even a partial solution, my question is centered about what is a central "limitation" of ffmpeg and ways to workaround it. Nevertheless, my previous writing may have been confusing, so please tell me if so. The code I currently use is `for /r %i in (*) do ffmpeg -i "%~fi" -map 0 -map -0:a:2 -c copy D:\Folder\%~i` – Fabio Freitas Jun 16 '20 at 14:15

1 Answers1

1

Not possible with ffmpeg alone

ffmpeg can't do in-place file changes.

The output must be a new file.

However, deleting/removing/replacing to original file with the new file should be trivial in your batch script.

I saw some vague references while searching and also stumbled upon the cache protocol and -hls_flags temp_file

The cache protocol allows some limited seeking during playback of live inputs. -hls_flags temp_file is only usable with the HLS muxer and creates a file named filename.tmp which is then renamed once the active segment completes. Neither are usable for what you want to do.

llogan
  • 121,796
  • 28
  • 232
  • 243
  • Well, that is what I wanted help with... And if ffmpeg's temp file functionality can be used for that, I believe it would be the most economic way of doing it. – Fabio Freitas Jun 16 '20 at 14:23
  • @FabioFreitas What do you mean by "ffmpeg's temp file functionality"? – llogan Jun 16 '20 at 21:13
  • If it doesn't ring a bell to you, it's very much likely I mistaken things. I saw some vague references while searching and also stumbled upon [these](https://ffmpeg.org/ffmpeg-all.html#cache) two [entries](https://ffmpeg.org/ffmpeg-all.html#Options-43) on the documentation. But I still don't understand ffmpeg if I don't find a perfectly explained answer here, that's why I made such a vague assumption. – Fabio Freitas Jun 17 '20 at 02:23
  • @FabioFreitas The cache protocol allows some limited seeking during playback of live inputs. `-hls_flags temp_file` is only usable with the HLS muxer and creates a file named `filename.tmp` which is then renamed once the active segment completes. Neither are usable for what you want to do. You're just going to have to output to a new file and then replace the old one. – llogan Jun 17 '20 at 19:02
  • Okay, that settles it, thank you. Could you add this info to your answer? – Fabio Freitas Jun 17 '20 at 23:00