15

I'm trying to use FFmpeg to generate the following from a local mp4 file:

  • A copy of the original video with no audio
  • A copy of the original video with audio but without visuals (a black screen instead). This file also needs to be in mp4 format.

After reading through the documentation I am struggling to get the terminal commands right. To remove the audio I have tried this command without any success:

ffmpeg -i file.mp4 -map 0:0 -map 0:2 -acodec copy -vcodec copy

Could anyone guide me towards how to accomplish this?

2 Answers 2

30

Create black video and silent audio

Use the color and anullsrc filters. Example to make 10 second output, 1280x720, 25 frame rate, stereo audio, 44100 sample rate:

ffmpeg -f lavfi -i color=size=1280x720:rate=25:color=black -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 10 output.mp4

Remove audio

Only keep video:

ffmpeg -i input.mp4 -map 0:v -c copy output.mp4

Keep everything except audio:

ffmpeg -i input.mp4 -map 0 -map -0:a -c copy output.mp4

See FFmpeg Wiki: Map for more info on -map.

Make video black but keep the audio

Using the drawbox filter.

ffmpeg -i input.mp4 -vf drawbox=color=black:t=fill -c:a copy output.mp4

Generate silent audio

See How to add a new audio (not mixing) into a video using ffmpeg? and refer to the anullsrc example.

2
2

To remove the audio you can use this:

ffmpeg -i file.mp4 -c copy -an file-nosound.mp4

notice the -an option

-an (output) Disable audio recording.

To keep audio but "replace" the video with a black screen, you could do this:

ffmpeg -i file.mp4 -i image.png -filter_complex overlay out.mp4

image.png is a black wallpaper that is placed on top of the video, but there should be better ways of full removing the frames, you could either extract the audio and later create a new video with the audio as a background

1
  • Thanks for this. For any future readers, -filter_complex overlay was about 3 times faster for me than -vf geq=0:128:128
    – kooshi
    Commented Sep 6, 2019 at 21:39

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