Reputation: 609
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.
Upvotes: 0
Views: 907
Reputation: 133703
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.
Upvotes: 1
Reputation: 31101
FLV does not support multiple audio streams. Technically is is possible in the binary format by incrementing the stream id. However the FLV documentation says the stream id should always be 0. so even if you did create this file, most players would not play it.
Upvotes: 0
Reputation: 839
As of the ffmpeg documentation you may use the amerge filter
http://www.ffmpeg.org/ffmpeg-filters.html#amerge
ffmpeg -i input.mkv -filter_complex "[0:1][0:2][0:3][0:4][0:5][0:6] amerge=inputs=6" -c:a pcm_s16le output.mkv
Upvotes: 1