0
  • I have a folder containing a lot of 2-10 min videos ....(30 video in folder)
  • How to process multiple videos in a folder and cut videos into small videos 55s.
  1. This is the line of code to process the entire folder containing videos

@ECHO OFF Setlocal EnableDelayedExpansion set INPUT=C:\Users\ABC\Desktop\in set OUTPUT=C:\Users\ABC\Desktop\out : encode video for %%a in ("%INPUT%*.mp4") DO ffmpeg -i "%%a" -vcodec libx264 -pix_fmt yuv420p -g 60 -r 30 -b:v 1000k -acodec libmp3lame -b:a 128k -ar 48000 -metadata title="" -metadata artist="" -metadata album_artist="" -metadata album="" -metadata date="" -metadata track="" -metadata genre="" -metadata publisher="" -metadata encoded_by="" -metadata copyright="" -metadata composer="" -metadata performer="" -metadata TIT1="" -metadata TIT3="" -metadata disc="" -metadata TKEY="" -metadata TBPM="" -metadata language="eng" -metadata encoder="" -preset superfast "%OUTPUT%/%%~na.mp4"

  1. This is the code to cut 55s video

ffmpeg -i 11.mp4 -filter_complex "crop=ih*(9/16):ih" -crf 21 -c:a copy -f segment -segment_time 55 -reset_timestamps 1 -preset ultrafast chep49_%03d.mp4

  1. Error command to process multiple Video Files using batch file

enter image description here ====>>> The question is how to combine the above 2 sentences into 1 ====>>> Can you help me please?

2
  • Relating to the output names would that be correct: If the original filename is Chep.mp4. The 55 second movies should be Chep_001.mp4, Chep_002.mp4, Chep_003.mp4, Chep_004.mp4 and so on and do this for a whole folder of movies? Commented Apr 2, 2022 at 9:41
  • you're right, that's obvious
    – alexdo
    Commented Apr 2, 2022 at 13:09

1 Answer 1

1

See if it is this that you want:

enter image description here

@ECHO OFF
Setlocal EnableDelayedExpansion
set INPUT=C:\users\ABC\Desktop\in
set OUTPUT=C:\users\ABC\desktop\out

:: encode video:

for %%a in ("%INPUT%\*.*") DO ffmpeg -i "%%a" -vcodec libx264 -pix_fmt yuv420p -g 60 -r 30 -b:v 1000k -acodec libmp3lame -b:a 128k -ar 48000 -metadata title="" -metadata artist="" -metadata album_artist="" -metadata album="" -metadata date="" -metadata track="" -metadata genre="" -metadata publisher="" -metadata encoded_by="" -metadata copyright="" -metadata composer="" -metadata performer="" -metadata TIT1="" -metadata TIT3="" -metadata disc="" -metadata TKEY="" -metadata TBPM="" -metadata language="eng" -metadata encoder="" -preset superfast -filter_complex "crop=ih*(9/16):ih" -crf 21 -c:a copy -f segment -segment_time 55 -reset_timestamps 1 -preset ultrafast "%output%\%%~na_%%03d.mp4"

Update 12/04/2022:

@ECHO OFF
Setlocal EnableDelayedExpansion
set INPUT=%userprofile%\Desktop\in
set OUTPUT=%userprofile%\desktop\out

:: encode video:

for %%a in ("%INPUT%\*.*") DO ffmpeg -i "%%a" -vcodec libx264 -pix_fmt yuv420p -g 60 -r 30 -b:v 1000k -acodec libmp3lame -b:a 128k -ar 48000 -metadata title="" -metadata artist="" -metadata album_artist="" -metadata album="" -metadata date="" -metadata track="" -metadata genre="" -metadata publisher="" -metadata encoded_by="" -metadata copyright="" -metadata composer="" -metadata performer="" -metadata TIT1="" -metadata TIT3="" -metadata disc="" -metadata TKEY="" -metadata TBPM="" -metadata language="eng" -metadata encoder="" -preset superfast -filter_complex "crop=ih*(9/16):ih,drawtext=text='Centered Text':font=Arial:x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" -crf 21 -c:a copy -f segment -segment_time 12 -reset_timestamps 1 -preset ultrafast "%output%\%%~na_%%03d.mp4"
11
  • Thank you very much, the command line works perfectly
    – alexdo
    Commented Apr 3, 2022 at 1:39
  • 1
    Look at the update part in my answer, for me I got something like this on one of the 12 sec segments: i.imgur.com/MEiA2le.png is that the intention? Commented Apr 12, 2022 at 11:47
  • 1
    For me it worked just by putting the font name font=Arial, maybe try: fontfile=c\:/windows/fonts/arial.ttf or check if that font is actually installed in your system. Commented Apr 12, 2022 at 12:47
  • 1
    Or try another font like 'Times New' courier new, calibri, georgia Commented Apr 12, 2022 at 12:50
  • 1
    maybe you just need a newer ffmpeg version..... Commented Apr 12, 2022 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .