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!

2
  • 2
    As it is right now, your question is off topic. Please take the tour. Learn How to Ask and please also read minimal reproducible example. Commented Jun 15, 2020 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 Commented Jun 16, 2020 at 14:15

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

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.
@FabioFreitas What do you mean by "ffmpeg's temp file functionality"?
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 two entries 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.
@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.
Okay, that settles it, thank you. Could you add this info to your answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.