VideoHelp Forum
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. Hello,

    I would like to join clips with ffmpeg that are of different characteristics (resolution, codec, frame-rate, GOP composition, etc.) The problem is that since they have different characteristics, the output video file is buggy and lags all over the place.
    Can you tell me how I can batch uniform these clips' characteristics with ffmeg, so I can join them (still with ffmpeg) without these lags. (I precise that all the clips should be at 1920x1080p 24fps.)

    Thank you!
    Quote Quote  
  2. iirc. something like:
    Code:
    ffmpeg -i "path to input" -vf "scale=w=1920:h=1080:force_original_aspect_ratio=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,fps=fps=24" -c:v libx264 -preset slow -crf 22 -c:a copy "path to output"
    should take a single file and convert it to 1920x1080 with 24fps H.264 content.
    Combining that with your batch should do the job. ('Yes', reencoding is necessary.)

    Cu Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. Thank you, Selur! Can you tell me how I can perform this task in batch for all the files of a specific folder?
    I can prepare a list of all the videos' filepaths in a txt if it's necessary.
    Last edited by vmackey; 17th Feb 2024 at 05:10.
    Quote Quote  
  4. Without even knowing what OS you are using: no.
    Also there have been multipe threads on how to use ffmpeg in batches, so you should be able to find a solution for this.
    for Windows read: https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg
    Also since you want to concatenate your files, using a loop to perfome this on all the files of a specific folder seems like the wrong approach to me.
    You instead should create a contatenation file as source.
    (there have been other threads how to concatenate stuff with ffmpeg, so with the forum search you should be able to figure this out)

    Cu Selur

    Ps.: maybe one of the ffmpeg GUIs already supports this.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  5. Originally Posted by vmackey View Post
    Thank you, Selur! Can you tell me how I can perform this task in batch for all the files of a specific folder?
    I can prepare a list of all the videos' filepaths in a txt if it's necessary.
    See your other thread:
    https://forum.videohelp.com/threads/413448-How-to-batch-convert-files-with-ffmpeg
    Quote Quote  
  6. It creates a temp directory to put newly encoded files into, with the same name, and creates file list for concat that could be used after. Trying to use standalone functions for everything, it is a good practice. It looks seemingly complicated but it only looks that way.
    Code:
    @echo off
    rem do not use already existing directory name, because it will be deleted!
    set "temp_dir_name=converted_files"
    set "filelist=filelist.txt"
    
    set "temp_folder=%~dp0%temp_dir_name%"
    type NUL > %filelist%
    call :TEMP_FOLDER_MANAGMENT "%temp_folder%"
    for %%x in (*.mp4) do call :PROCESS "%%x"
    echo done
    ENDLOCAL&echo press any key to exit&pause>nul&exit
    
    :PROCESS <input filepath>
    set "output=%temp_folder%\%~nx1"
    call :ENCODE "%~1" "%output%"
    call :APPEND_TO_LIST "%output%" %filelist%
    goto :eof
    
    :APPEND_TO_LIST <filepath> <text file>
    if exist "%~1" if %~z1 gtr 0 echo file '%~1' >> %2
    goto :eof
    
    :ENCODE <input filepath> <output filepath>
    rem just grabbing selurs line
    ffmpeg -i "%~1" -vf "scale=w=1920:h=1080:force_original_aspect_ratio=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,fps=fps=24" -c:v libx264 -preset slow -crf 22 -c:a copy "%~2"
    goto :eof
    
    :TEMP_FOLDER_MANAGMENT <directory>
    rem this creates directory or deletes what is inside if that directory exists
    if exist "%~1" DEL /F /Q "%~1"\*.*
    if not exist "%~1" echo creating temp folder: "%~1"& MD "%~1"
    if not exist "%~1" (
      echo    ERROR, temp directory name has illegal characters or could not be created
      echo.
      endlocal & echo press any key to exit ... & pause>nul & goto :eof
    )
    goto :eof
    Again, there might be some ffmpeg shortcut, like in that other thread where ffmpeg encoded from a filelist, so here maybe ffmpeg can create a file list, not sure.
    Last edited by _Al_; 17th Feb 2024 at 12:30.
    Quote Quote  
  7. Originally Posted by _Al_ View Post
    It creates a temp directory to put newly encoded files into, with the same name, and creates file list for concat that could be used after. Trying to use standalone functions for everything, it is a good practice. It looks seemingly complicated but it only looks that way.
    Code:
    @echo off
    rem do not use already existing directory name, because it will be deleted!
    set "temp_dir_name=converted_files"
    set "filelist=filelist.txt"
    
    set "temp_folder=%~dp0%temp_dir_name%"
    type NUL > %filelist%
    call :TEMP_FOLDER_MANAGMENT "%temp_folder%"
    for %%x in (*.mp4) do call :PROCESS "%%x"
    echo done
    ENDLOCAL&echo press any key to exit&pause>nul&exit
    
    :PROCESS <input filepath>
    set "output=%temp_folder%\%~nx1"
    call :ENCODE "%~1" "%output%"
    call :APPEND_TO_LIST "%output%" %filelist%
    goto :eof
    
    :APPEND_TO_LIST <filepath> <text file>
    if exist "%~1" if %~z1 gtr 0 echo file '%~1' >> %2
    goto :eof
    
    :ENCODE <input filepath> <output filepath>
    rem just grabbing selurs line
    ffmpeg -i "%~1" -vf "scale=w=1920:h=1080:force_original_aspect_ratio=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,fps=fps=24" -c:v libx264 -preset slow -crf 22 -c:a copy "%~2"
    goto :eof
    
    :TEMP_FOLDER_MANAGMENT <directory>
    rem this creates directory or deletes what is inside if that directory exists
    if exist "%~1" DEL /F /Q "%~1"\*.*
    if not exist "%~1" echo creating temp folder: "%~1"& MD "%~1"
    if not exist "%~1" (
      echo    ERROR, temp directory name has illegal characters or could not be created
      echo.
      endlocal & echo press any key to exit ... & pause>nul & goto :eof
    )
    goto :eof
    Again, there might be some ffmpeg shortcut, like in that other thread where ffmpeg encoded from a filelist, so here maybe ffmpeg can create a file list, not sure.
    It works great! Thank you very much, Al.
    Quote Quote  
  8. Together with hydra3333 there was recently a long topic, how to actually take all media-files (including images, rotate them, box them, possibly use transitions, respecting color spaces etc.) from a directory (and or subdirectories) and create a long video out of it. We ended up both having results. Both solutions kind of ended up in a crude form I think, working but needing to be oriented in it a bit. I never ended up forging it into a gui , maybe some other time revisiting it. I used python and I did not have to use intermediate files, creating video on the fly, frame by frame. Audio was constructed using second pass though (following text file instructions from the first pass), but that was much faster.
    https://forum.videohelp.com/threads/408230-ffmpeg-avc-from-jpgs-of-arbitrary-dimension...g-aspect-ratio
    Quote Quote  



Similar Threads

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