I want to mix audio on a video. The video already has audio stream in it. I'm adding another one.
The new audio I'm adding is shorter than the video. So, I want to loop it as long as the video lasts.
So far, I'm doing this:
ffmpeg -y -i test.mp4 -stream_loop -1 -i bg_sound.mp3 -filter_complex "[0:a][1:a]amix=inputs=2:duration=longest[out]" -map 0:v -map [out] output.mp4
This adds the audio on the video, but does not loop it. I've also tried stream_loop with other integer options with no luck. The audio I'm adding ends and the rest of the video continues.
I need to loop my audio.
Here is the ffprobe result of my video:
ffprobe version N-76452-ga97f1e7 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --prefix=/home/alfanso/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/alfanso/ffmpeg_build/include --extra-ldflags=-L/home/alfanso/ffmpeg_build/lib --bindir=/home/alfanso/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 55. 5.100 / 55. 5.100
libavcodec 57. 14.100 / 57. 14.100
libavformat 57. 14.100 / 57. 14.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 14.101 / 6. 14.101
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'localtest.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:06:53.97, start: 0.033333, bitrate: 179 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1280x720, 45 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
I've also tried using different video and audio sources with the same result.
stream_loop 5. Just tried that along with shortest in amix. That caused the original audio (already in video) to stop along with the video being added. I hope this makes sense :P