doufuhuang6981 2014-04-09 09:16
浏览 87
已采纳

将flv与mp3合并而不使用FFMPEG替换flv音频流

I would like to merge a flv with mp3 without touching / removing flv audio stream using ffmpeg in php. I tried many commands and none helps. Here is the command I am using now.

/usr/bin/ffmpeg -i "4bpCRRV82x.flv"-i "Someday.mp3" -vcodec libx264  -shortest "output.mp4"

But it replaces flv audio with the mp3 inputting. Any help and suggestions will be highly appreciable. Thanks.

  • 写回答

3条回答 默认 最新

  • doushi8187 2014-04-10 22:53
    关注

    Assuming both inputs contain stereo audio you can use the amerge audio filter to merge both stereo streams into a single four channel stream, then use the pan audio filter to combine the appropriate channels into a single stereo stream:

    ffmpeg -i video.flv -i audio.mp3 -filter_complex \
    "[0:a][1:a]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[a]" \
    -map 0:v -map "[a]" -c:v copy -c:a aac -strict experimental -shortest out.mp4
    
    • The video can be stream copied (depending on the input video format) as shown in the example if you do not need to re-encode it, but if you must re-encode then see the FFmpeg and x264 Encoding Guide.

    • The example uses the native FFmpeg AAC encoder which requires -strict experimental (or the alias -strict -2). See the FFmpeg and AAC Encoding Guide for information on other encoders.

    • The option -shortest will finish encoding when the shortest input stream ends.

    • See Manipulating audio channels with ffmpeg for more examples.

    • Make sure you're using a recent version of ffmpeg. See the FFmpeg Download page for builds for Windows, OS X, and Linux.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?