Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg: How to assign an empty soundtrack to a video?

I'm using ffmpeg to build a short hunk of video from a machine-generated png. This is working, but the video now needs to have a soundtrack (an [audio] field) for some of the other things I'm doing with it. I don't actually want any sound in the video, so: is there a way to get ffmpeg to simply set up an empty soundtrack property in the video, perhaps as part of the call that creates the video? I guess I could make an n-second long silent mp3 and bash it in, but is there a simpler / more direct way? Thanks!

like image 472
Jim Miller Avatar asked Sep 26 '13 00:09

Jim Miller


People also ask

How to make silent audio using FFmpeg?

anullsrc audio filter. You can use ffmpeg to create the silent audio and combine it with a video in one step. This example will use the anullsrc audio filter to generate stereo silent audio with a sample rate of 44100:

How do I make a video CD using FFmpeg?

To create a video CD or DVD, FFmpeg makes it simple by letting you specify a target type and the format options required automatically. You can set a target type as follows: add -target type; type can of the following be vcd, svcd, dvd, dv, pal-vcd or ntsc-svcd on the command line.

What version of FFmpeg do I need to add filters?

Relatively new filters: use FFmpeg 4.2 or newer, or even better use a build from the current git master branch. If you want it at the beginning instead use start_duration instead of stop_duration.

How to extract audio from a video file in Linux?

Extract audio from video file. To extract sound from a video file, and save it as Mp3 file, use the following command: $ ffmpeg -i video1.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio3.mp3. Explanation about the options used in above command. Source video : video.avi. Audio bitrate : 192kb/s. output format : mp3.


1 Answers

Thanks to @Alvaro for the links; one of these worked after a bit of massaging. It does seem to be a two-step process: First make the soundtrack-less video and then do:

ffmpeg -ar 44100 -acodec pcm_s16le -f s16le -ac 2 -channel_layout 2.1 
       -i /dev/zero -i in.mp4 -vcodec copy -acodec libfaac -shortest out.mp4

The silence comes from /dev/zero and -shortest makes the process stop at the end of the video. Argument order is significant here; -shortest needs to be down near the output file spec.

This assumes that your ffmpeg installation has libfaac installed, which it might not. But, otherwise, this seems to be working.

like image 94
Jim Miller Avatar answered Sep 26 '22 16:09

Jim Miller