VideoHelp Forum




+ Reply to Thread
Results 1 to 5 of 5
  1. I have a ffmpeg batch crop command that handles all files located in one folder and exports them to a folder named "cropped". Everything works well, however I cannot get ffmpeg to handle videos with blank spaces in the title, for example: "this great video.mpeg". Can someone please let me know what I need to add to this command?

    Code:
    for %%a in ("*.mp4") do "C:\FFmpeg\bin\ffmpeg.exe" -i %%a -vf crop=1280:680:0:0 -c:v libx264 -level 40 -pix_fmt yuv420p -preset medium -crf 20 -threads 8 -c:a aac -strict experimental -ar 48000 -ab 256k -f mp4 "cropped\%%~na.mp4"
    
    pause
    Quote Quote  
  2. put quotes around the second %%a
    Quote Quote  
  3. IMHO even quotation not work 100% - this is cmd nature (it will work if you escape every space in name but i don't know if this is possible within cmd) - safer is to not use blank spaces in a files names. You can substitute blank space with underscore - some multirenamer can be useful - i always recommend total commander, alternatively you may use short (DOS) names.
    Quote Quote  
  4. "%%a" is the way to go and as I always stress it is better to call it like call :my_function "%%a" and it becomes %1 within that function, then call it "%~1"
    That seems to always work, I could not find a scenario it would not.
    Code:
    for %%a in ("*.mp4") do call :my_function "%%a"
    pause
    exit
    
    :my_function
    "C:\FFmpeg\bin\ffmpeg.exe" -i "%~1" -vf crop=1280:680:0:0 -c:v libx264 -level 40 -pix_fmt yuv420p -preset medium -crf 20 -threads 8 -c:a aac -strict experimental -ar 48000 -ab 256k -f mp4 "cropped\%~n1.mp4"
    goto :eof
    windows batch adds quotes if there are gaps in %1, but like in Avisynth you cannot tolerate it or there might be other scenarios , because you have to put quotes there always, so it would double the quotes. So why not to ALWAYS manually put quotes there and forbid batch script to add quotes there in ANY CASE. "%~1" just does that.
    Quote Quote  
  5. Originally Posted by sneaker View Post
    put quotes around the second %%a
    Wow! That was simple and quick. This little solution worked! Thank you sneaker!
    Quote Quote  



Similar Threads

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