Search code examples
imageaudioffmpegslideshow

ffmpeg - Sync Audio with image position (Audio Slideshow)


How can i start the audio Files at the same position as the pictures? (This is for a Image slideShow with changing Audio)

 ffmpeg -loop 1 -t 19 -i  1.jpg -loop 1 -t 19 -i  2.jpg  -i  1.mp3  -i  2.mp3  
 -filter_complex "
[0:a]adelay=19s:all=1[1a];
[1:a]adelay=24s:all=1[2a];  

[0:v]scale=1280:720,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[0p];
[1:v]scale=1280:720,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[1p];

[0p][1p]xfade=transition=fade:duration=1:offset=19[1x];

-map [1x]  -c:v libx264 -c:a copy  -t 39 out.mp4

Solution

  • ok i found a solution to position audio files by seconds with Images. just use this structure and Paramter "adelay" for an audio offset

    ffmpeg -loop 1 -t 10 -i  "1.jpg" -loop 1 -t 10 
    -i  "2.jpg" -t  5 -ss  0 -i "audio1.mp3"
    -t 10 -ss 10 -i "audio2.mp3"
    -filter_complex "[2]adelay=1000:all=1[a1];
    [3]adelay=2000:all=1[a2];
    [0:v]scale=1280:720,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[0p];
    [1:v]scale=1280:720,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[1p];
    [0p][1p]xfade=transition=fade:duration=1:offset=5.485[1x];
    [a1][a2]amix=inputs=2[aout]" -map [1x] -map [aout] _out.mp4 -y 2>&1