adding silent audio in ffmpeg

后端 未结 4 1060
天涯浪人
天涯浪人 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.

    0 讨论(0)
  • 2020-12-04 09:51

    Here's a command for the latest ffmpeg, works with MP4 (H264/AVC):

    ffmpeg -f lavfi -i aevalsrc=0 -i input.mp4 -c:v copy -c:a aac -map 0 -map 1:v -shortest output.mp4
    
    0 讨论(0)
  • 2020-12-04 09:52

    Order matters. I have tried the sox command above and the ffmpeg command below and it works

    ffmpeg -shortest -i silence.wav -acodec pcm_s16le -i out.mov -vcodec copy -strict -2 vid_with_sound.mov
    
    0 讨论(0)
  • 2020-12-04 10:00

    Create video from image or convert image into video then add slient audio using ffmpeg.

    You can use the anullsrc audio source filter in ffmpeg. Example to make a 5.1 channel, 48000 Hz sample rate, 10 seconds silent video file from image:

    ffmpeg -loop 1 -i img002.jpg -f lavfi -i anullsrc=channel_layout=5.1:sample_rate=48000 -t 10 -c:v libx264 -t 10 -pix_fmt yuv420p -vf scale=480:320 -y output.mp4
    

    img002.jpg: Input image file

    -i anullsrc: Add silent audio

    -t 10: Number of seconds

    scale=480:320: Video resolution width=420 and height=320

    -y: Overwrite existing output file

    output.mp4: Output file

    0 讨论(0)
提交回复
热议问题