Fables Alive
Fables Alive

Reputation: 2808

ffmpeg: How to loop audio wave file into a video which has no any audio channel

How can I loop audio wave or mp3 file into a video which has no any audio channel using ffmpeg?

that is my code already working for video files which has already audio channel.

ffmpeg -i somevideoinput.mp4 -stream_loop -1 
       -i will_be_looped.wav 
 -vcodec copy  
-max_muxing_queue_size 9999
-shortest
-fflags +shortest -max_interleave_delta 200M
-map 0:0 -map 1:0
 output.mp4

that replaces the video's auido channel with looped input wave file. but it does not work if video has no any audio channel already.

do you any idea? maybe some filter_complex parameters I gotto add?

Upvotes: 0

Views: 598

Answers (1)

llogan
llogan

Reputation: 133713

-stream_loop is an input option, so it has to be used before -i:

ffmpeg -i somevideoinput.mp4 -stream_loop -1 -i will_be_looped.wav 
-vcodec copy 
-max_muxing_queue_size 9999
-shortest
-fflags +shortest -max_interleave_delta 200M
-map 0:v -map 1:a
 output.mp4

I also changed the -map options to use stream specifiers to ensure that it selects the proper streams.

Upvotes: 1

Related Questions