美文网首页FFmpeg与音视频流媒体工程开发相关
[FFmpeg Cmd]填白调研 + overlay + aud

[FFmpeg Cmd]填白调研 + overlay + aud

作者: _小老虎_ | 来源:发表于2023-03-04 13:31 被阅读0次

    关于amix

    inputs

    The number of inputs. If unspecified, it defaults to 2.//输入的数量,如果没有指明,默认为2.

    duration

    How to determine the end-of-stream.//决定了流的结束

    longest

    The duration of the longest input. (default)//最长输入的持续时间

    shortest

    The duration of the shortest input.//最短输入的持续时间

    first

    The duration of the first input.//第一个输入的持续时间

    dropout_transition

    The transition time, in seconds, for volume renormalization when an input stream ends. The default value is 2 seconds.

    //输入流结束时(音频)容量重整化的转换时间(以秒为单位)。 默认值为2秒。

    Video

    // 黑色背景视频
    time ./bin/ffmpeg-cli -v level+error \
    -filter_complex "color=s=1280x720:c=black,trim=0:100[blankV]" -map "[blankV]" -vcodec libx264 -y bg.mp4
     
    // overlay logo
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.mp4 \
    -i "image-1280x720.jpeg" \
    -filter_complex "[1:v]scale=480:360[logo1];[0:v][logo1]overlay=x='if(between(t,0,5),10,NAN)':10[videologo1]" \
    -map "[videologo1]" \
    -vcodec libx264 -pix_fmt yuv420p -an -y resultblank.mp4
     
     
    // overlay logo + set show start time
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.mp4 \
    -ss 10 -t 10 -i 1080p.mp4 \
    -filter_complex "[1:v]scale=480:360,setpts=PTS+10/TB[logo1];[0:v][logo1]overlay=x='if(between(t,10,20),10,NAN)':10[videologo1]" \
    -map "[videologo1]" \
    -vcodec libx264 -pix_fmt yuv420p -an -y resultblank.mp4
    

    Audio

    // 静音帧 STEP 01
    time ./bin/ffmpeg-cli -f lavfi -t 60 -i anullsrc -acodec mp3 -y bg.mp3
    time ./bin/ffmpeg-cli -re -f lavfi -i abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo -acodec aac -y bg1.aac
     
    // test STEP 02
    // Summer [---30----]play---> -f lavfi -t 30 -i anullsrc=channel_layout=stereo:sample_rate=44100
    // -f lavfi -t 1 -i anullsrc=channel_layout=stereo:sample_rate=44100 \
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.mp3 \
    -i "summer.mp3" \
    -i "drum.mp3" \
    -filter_complex "[1:a]volume=1,atrim=0:10[audio1];[2:a]volume=1,atrim=0:10[audio2];[audio1][0:a][audio2]concat=n=3:v=0:a=1,atrim=0:30[result]" \
    -map "[result]" -acodec aac -ar 44100 -y tmp.aac
    real    0m0.973s
    user    0m0.567s
    sys 0m0.050s
     
    // 重要
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.mp3 \
    -i "summer.mp3" \
    -i "drum.mp3" \
    -filter_complex "[0:a]volume=1,aloop=loop=-1:size=2e+09,atrim=0:10[bgm];[1:a]volume=1,atrim=0:10[audio1];[2:a]volume=1,atrim=0:10[audio2];[audio1][bgm][audio2]concat=n=3:v=0:a=1,atrim=0:30[result]" \
    -map "[result]" -acodec mp3 -y tmp.mp3
    real    0m2.996s
    user    0m2.287s
    sys 0m0.054s
    

    Audio 2

    // 静音帧 STEP 01
    time ./bin/ffmpeg-cli -f lavfi -t 60 -i anullsrc -acodec mp3 -y bg.mp3
    time ./bin/ffmpeg-cli -re -f lavfi -i abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo -acodec aac -y bg1.aac
     
    // test STEP 02
    // Summer [---30----]play---> -f lavfi -t 30 -i anullsrc=channel_layout=stereo:sample_rate=44100
    // -f lavfi -t 1 -i anullsrc=channel_layout=stereo:sample_rate=44100 \
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.mp3 \
    -i "summer.mp3" \
    -i "drum.mp3" \
    -filter_complex "[1:a]volume=1,atrim=0:10[audio1];[2:a]volume=1,atrim=0:10[audio2];[audio1][0:a][audio2]concat=n=3:v=0:a=1,atrim=0:30[result]" \
    -map "[result]" -acodec aac -ar 44100 -y tmp.aac
    real    0m0.973s
    user    0m0.567s
    sys 0m0.050s
     
    // 重要
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.mp3 \
    -i "summer.mp3" \
    -i "drum.mp3" \
    -filter_complex "[0:a]volume=1,aloop=loop=-1:size=2e+09,atrim=0:10[bgm];[1:a]volume=1,atrim=0:10[audio1];[2:a]volume=1,atrim=0:10[audio2];[audio1][bgm][audio2]concat=n=3:v=0:a=1,atrim=0:30[result]" \
    -map "[result]" -acodec mp3 -y tmp.mp3
    real    0m2.996s
    user    0m2.287s
    sys 0m0.054s
     
    ,aloop=loop=-1:size=2e+09,atrim=0:30
     
    > time ./bin/ffmpeg-cli -v level+error \
    > -i "summer.mp3" \
    > -i "drum.mp3" \
    > -i bg.aac \
    > -filter_complex "[0:0][1:0]concat=n=2:v=0:a=1,volume=1dB,aformat=fltp,pan=stereo|c0=c0|c1=c1[a0];[2]volume=0.5dB,aformat=fltp,pan=stereo|c0=c0|c1=c1[a1];[a0][a1]amerge,aformat=fltp[a]" \
    > -map "[a]" \
    > -acodec aac -strict -2 -y final.aac
    // ,afade=t=out:st=38.000000:d=2
     
    // overlay aac
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.aac \
    -i "summer.mp3" \f
    
    -i drum.mp3 \
    -filter_complex "[0:a]volume=1[BG1];[1:a]volume=0.8,atrim=0:10[Speech];[2:a]volume=1,atrim=0:10,afade=t=in:st=0:d=3[Bgm];[BG1][Bgm][Speech]amix=inputs=3:duration=first[Audio]" \
    -map "[Audio]" \
    -acodec aac \
    -strict experimental \
    -y resultblank.aac
     
    // overlay test2 aac mp4
    time ./bin/ffmpeg-cli -v level+error \
    -i bgaac.mp4 \
    -i "summer.mp3" \
    -i drum.mp3 \
    -filter_complex "[0:a]volume=1[BG1];[1:a]volume=0.8,atrim=0:10[Speech];[2:a]volume=1,atrim=0:10,afade=t=in:st=0:d=3[Bgm];[BG1][Bgm][Speech]amix=inputs=3:duration=first[Audio]" \
    -map "[Audio]" \
    -acodec aac \
    -strict experimental \
    -y resultblank.aac
    
    time ./bin/ffmpeg-cli -v level+error \
    -i bg.mp4 -t 30 \
    -i tmp.mp3 \
    -map 0:v -map 1:a -vcodec copy -acodec copy \
    -y result.mp4
    

    相关文章

      网友评论

        本文标题:[FFmpeg Cmd]填白调研 + overlay + aud

        本文链接:https://www.haomeiwen.com/subject/kxxnxdtx.html