VideoHelp Forum
+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. I've been making image videos with FFmpeg using the following:

    Code:
    ffmpeg -loop 1 -i Image01.jpg -i Aud01.mp3 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest Vid01.mp4
    I want to make about 60 of them using sequential image and audio files:

    ffmpeg -loop 1 -i Image01.jpg -i Aud01.mp3 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest Vid01.mp4
    ffmpeg -loop 1 -i Image02.jpg -i Aud02.mp3 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest Vid02.mp4
    ffmpeg -loop 1 -i Image03.jpg -i Aud03.mp3 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest Vid03.mp4

    Is there an simple way of joining the commands so I don't have to repeat the process 60 times. I've tried && but it only outputs the final vid file.
    Quote Quote  
  2. Here's a batch file I came up with:

    Code:
    @echo off
    SetLocal EnableDelayedExpansion
    
    :START
    Set /a COUNTER=0
    
    :Cycle
    
    SET COUNTER=0%COUNTER%
    
    set PICNAME=Image%COUNTER%.jpg
    set VIDNAME=Vid%COUNTER%.mp4
    set AUDNAME=Aud%COUNTER%.mp3
    
    @echo on
    ffmpeg -loop 1 -i %PICNAME% -i %AUDNAME% -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest %VIDNAME%
    @echo off
    if errorlevel 1 goto Done
    
    set /A COUNTER=COUNTER+1
    if %COUNTER% GTR 60 goto Done
    goto Cycle
    
    :Done
    pause
    That will handle up to 60 files but will stop at the first missing file (or other ffmpeg error).

    I found this site helpful: https://www.robvanderwoude.com/battech_leadingzero.php
    Quote Quote  
  3. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Here is a batch that is a little shorter that works for me. I didn't have mp3 available on short notice so I used mp2 audio. Shouldn't make a difference. Since your request was with Images starting with 1 with leading 0, I added the 'If LSS...' script to decide whether to add a zero to the filename or not.

    I added the %%dpa in case the images are in a different folder than this CMD file.

    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    set count=1
    for %%a in (*.jpg) do (
    IF !count! LSS 10 (
    ffmpeg -loop 1 -i "%%~dpaimage0!count!.jpg" -i Aud0!count!.mp2 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest Vid0!count!.mp4
    ) ELSE (
    ffmpeg -loop 1 -i "%%~dpaimage!count!.jpg" -i Aud!count!.mp2 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest Vid!count!.mp4
    )
    set /a count+=1
    )
    Quote Quote  
  4. Many thanks for these. They'll make it a lot easier.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!