2

I am trying to get an audio stream to loop over a slide in the background of a slideshow I've made with ffmpeg. I currently have the following:

ffmpeg -loop 1 -t 15 -i img_1.jpg \
-loop 1 -t 15 -i img_2.jpg \
-loop 1 -t 15 -i img_3.jpg \
-stream_loop -1 -t 45 -i audio.mp3 \
-filter_complex \
"[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=out:st=4:d=1[v0]; \
[1:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
[2:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
[v0][v1][v2]concat=n=3:v=1:a=0,format=yuv420p[v]" \
-map "[v]" -map 3:a output.mp4

Now the solution is built up from Create video with 5 images with fadeIn/out effect in ffmpeg and https://video.stackexchange.com/questions/23390/ffmpeg-loop-video-to-the-length-of-audio as well as reading through the ffmpeg docs.

My main issue is that this method seems prone to high memory overhead since I'm forcing the audio stream to loop indefinitely and although I'm only getting the first 45 seconds of that loop, an assumption I would have is that it could still use up resources looping beyond the 45 seconds on a seperate thread.

In a nutshell, is there a better way to have the same behaviour?

1
  • 1
    Have you checked memory use? stream_loop rewinds the demuxer, but only till the duration limit is reached. It does not take up more memory than reading a 45 second MP3 once.
    – Gyan
    Commented Oct 4, 2018 at 9:35

0

You must log in to answer this question.

Browse other questions tagged .