2

I would like to mute a video for very specific sections.

For example, for a video that is 3 minutes long, i want to mute 5-10 seconds, and 33-36 seconds.

Now,

I know how to apply an audio filter.

ffmpeg -i input.mp4 -af "volume=enable='between(t,5,10)':volume=0, volume=enable='between(t,33,36)':volume=0" output.mp4

But it seems that ffmpeg tries to re-encode the entire video! The video and audio has been completely transcoded.

I only need to mute the specific sections, i would like to keep everything else the same.

Is there a quick way to run it?

Thanks

4

What you are missing here is the specification of what codecs you want to use for the transcoding of the audio and video streams.

  • to specify the audio codec, use: -c:a
  • to specify the video codec, use: -c:v

If you want to simply rewrap the data, and not perform any transcoding, you can use "copy" as the video/audio codecs (i.e. "-c:a copy" "-c:v copy").

However, it is not possible to "copy" the video or audio streams when ANY filters are being used on that stream. Think - if you are literally making a "copy" of the 1s and 0s that make up the original audio and video, and creating an output with those same 1s and 0s, you cannot change anything about the data. Filters change the actual bytes that make up the data, so it is not possible to apply a filter and also "copy" the data at the same time.

In your case, you will be forced to transcode the audio stream because you are using an audio filter on that stream. You could however leave the video stream alone by using the "-c:v copy" argument.

For your audio stream, if it is quality you are concerned with, you can specify an uncompressed audio codec using "-c:a pcm_s16le". However, IIRC that codec is not compatible with the MP4 container.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.