1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need some help with FFMPEG

Discussion in 'General Scripting Chat' started by domkis30, Jun 14, 2014.

  1. domkis30

    domkis30 Regular Member

    Joined:
    Aug 18, 2010
    Messages:
    240
    Likes Received:
    61
    Hello,

    I need to convert bulk convert images to video (one image --> one video) and keep same file name for e.x if image is named bluewidgets video also should be name the same. One guy a script for me to do that, however there is problem because all images are random size and sometimes I get error "width/height not divisible by 2". I tried to add this argument but without any luck.

    Code:
    -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"

    This is how my ffmpeg batch script looks:

    Code:
    @echo off
    
    set /a county=0 
    for /f "tokens=* delims= " %%a in ('dir/s/b/a-d "C:\Users\domkis\Desktop\Images Converted\*.jpg"') do ( 
    set /a county+=1 
    ) 
    
    SET /a i=0
    
    :loop
    IF %i%==%county% GOTO END
    echo This is iteration %i%.
    
    
    setlocal EnableDelayedExpansion
    set count=0
    for /f "delims=" %%a in ('dir /b *.jpg') do @(
        set filename[!count!]=%%a
        set /a count = count + 1
    )
    set /a choose = (%random% * 32768 + %random%) %% count
    set chosen=!filename[%choose%]!
    
    ffmpeg -vf "scale=320:trunc(ow/a/2)*2" -loop 1 -f image2 -i %chosen% -r 20 -t 60 -y %chosen%.mp4
    del %chosen%
    
    SET /a i=%i%+1
    GOTO LOOP
    
    :end