adding silent audio in ffmpeg

后端 未结 4 1063
天涯浪人
天涯浪人 2020-12-04 09:15

I\'m trying to use ffmpeg to add a silent audio track to a MOV file.

I created a silent audio track longer than the video, and intend to use the -shortest option wit

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 09:48

    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:

    ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i video.mov -c:v copy -c:a aac -shortest output.mov
    
    • channel_layout=stereo:sample_rate=44100 is the default, but I included it just as an example of how to use these options.

    Ignoring existing audio

    If your video input file has audio that you want to ignore then use the -map option to override the default stream selection behavior:

    ffmpeg -f lavfi -i anullsrc -i video.mov -c:v copy -c:a aac -map 0:a -map 1:v -shortest output.mp4
    
    • -map 0:a -map 1:v can be translated as: from the first input (0) use the audio (a), and from the second input (1) use the video (v).

    Notes

    • These examples will stream copy the video so it does not get re-encoded (like a "copy and paste").

    • It is always recommended to use a recent ffmpeg. Links to recent builds are on the FFmpeg Download page or you can refer to a step-by-step guide to compile ffmpeg.

提交回复
热议问题