VideoHelp Forum
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. Member
    Join Date
    Apr 2018
    Location
    Sunsari [Nepal]
    Search Comp PM
    Hello, I am trying to write a .bat File but Facing issue on output filename and trying to find solution about how to place input filename on output


    Code:
    set /p input=
    
    ffmpeg.exe -i %input% -vf "drawtext=fontsize=22:fontfile=C\\:/Windows/fonts/arial.ttf:fontcolor=white:text='NBMedia':bordercolor=black:borderw=2:x=w-tw-10:y=h-th-10, -vf crop=w=1920:h=808:x=0:y=132"  -c:v libx264 -b:v 1200k -maxrate 1200k -bufsize 1200k "inputfilename_New.mp4"
    Pause
    Simply I am Dragging file on Batch Script and Press enter and ffmpeg handle rest

    but I want to know Which Cmd can automatically place input file name on output filname


    if my input filename =123.mp4, Then I want "123_New.Mp4" on Output Filename

    But When i drag file on .bat file then my file will be added with Complete File Path and Name, So simply I Can't add "%input%_New.mp4" on Filename

    I had found a Code on another Forum"

    Code:
    %~dpn1%random%%~x1
    this code is Generating Randon Number Which is good and it won't overwrite My Previous encoded Video,

    But I Want input Filename, so it will easy to find or organize Media Files

    Thanks
    Quote Quote  
  2. Code:
    "%~dpn1_New.mp4"
    Quote Quote  
  3. Member
    Join Date
    Apr 2018
    Location
    Sunsari [Nepal]
    Search Comp PM
    Originally Posted by jagabo View Post
    Code:
    "%~dpn1_New.mp4"
    No Luck,

    it won't Placing input filename,

    Maybe due to I had Saved .bat file and Dragging Video, So My input Have full directory location and filename+extension
    Quote Quote  
  4. Member
    Join Date
    Apr 2018
    Location
    Sunsari [Nepal]
    Search Comp PM
    Hi, I had Created batch for encode single or Dropped file only,

    Open batch > Drop File, Then it will start encoding that file with pre-selected encoding setting,

    above code will work for auto scan and encode all selected Format Which is inside same folder,
    Quote Quote  
  5. ffm4b.bat in provided link can handle a single file input from a prompt: you paste in the input path (or drag and drop if you prefer).
    "%%~nf" is filename without extension in .bat

    if your issues persist use echo command to figure out what's wrong.
    Quote Quote  
  6. You're command line has many errors. You're not taking a filename via drag/drop, you're taking input from the keyboard. If you want drag/drop the input filename is %1 and the output file name is "%~dpn1_new.mp4".

    Another problem with your script is the second -vf. You need to chain all the video filters into one vf. If you do that in the order the fitlers appear you will add a watermark to the lower right of the 1920x1080 frame then crop it away. You should crop first, add the watermark after:

    Code:
    ffmpeg.exe -i %1 -vf "crop=w=1920:h=808:x=0:y=132,drawtext=fontsize=22:fontfile=C\\:/Windows/fonts/arial.ttf:fontcolor=white:text='NBMedia':bordercolor=black:borderw=2:x=w-tw-10:y=h-th-10"  -c:v libx264 -b:v 1200k -maxrate 1200k -bufsize 1200k "%~dpn1_new.mp4"
    That's suitable for drag/drop but you will run into problems if your source isn't 1920x1080.
    Quote Quote  
  7. Member
    Join Date
    Apr 2018
    Location
    Sunsari [Nepal]
    Search Comp PM
    Originally Posted by jagabo View Post
    You're command line has many errors. You're not taking a filename via drag/drop, you're taking input from the keyboard. If you want drag/drop the input filename is %1 and the output file name is "%~dpn1_new.mp4".

    Another problem with your script is the second -vf. You need to chain all the video filters into one vf. If you do that in the order the fitlers appear you will add a watermark to the lower right of the 1920x1080 frame then crop it away. You should crop first, add the watermark after:

    Code:
    ffmpeg.exe -i %1 -vf "crop=w=1920:h=808:x=0:y=132,drawtext=fontsize=22:fontfile=C\\:/Windows/fonts/arial.ttf:fontcolor=white:text='NBMedia':bordercolor=black:borderw=2:x=w-tw-10:y=h-th-10"  -c:v libx264 -b:v 1200k -maxrate 1200k -bufsize 1200k "%~dpn1_new.mp4"
    That's suitable for drag/drop but you will run into problems if your source isn't 1920x1080.
    Hi, Will you Please Write a Batch Script code, Which Can give option to support Drag and Drop File,

    This above cmd work When I Simply drop file on that batch script,

    But When I open that Batch, It won't have option to Drag File on Windows


    Something Like

    Code:
    @echo off
    
    {File Drag and Drop cmd Which Can Define input File as %1} : {Drag File Here : (as Text)}
    
    ffmpeg.exe -i %1 -vf "crop=w=1920:h=808:x=0:y=132,drawtext=fontsize=22:fontfile=C\\:/Windows/fonts/arial.ttf:fontcolor=white:text='NBMedia':bordercolor=black:borderw=2:x=w-tw-10:y=h-th-10"  -c:v libx264 -b:v 1200k -maxrate 1200k -bufsize 1200k "%~dpn1_new.mp4"
    I Want to open Batch Script Window First then drop Files There,

    Thanks
    Quote Quote  
  8. drag&Drop feature makes sense only to be performed on windows explorer Icon/text or desktop with icons, when Windows os can take over and pass path of dragging file as argument %1 and run script. Because windows software is in focus at that time.

    When you open that bat to edit, windows is out. When you have that bat file open for editing and it is in focus it is not run by Windows.

    But you can just have SHORTCUT for that BAT file on desktop at all times even if physically it is somewhere else, also a text editor opened to edit that BAT and also windows explorer opened with bunch of video files .
    Last edited by _Al_; 5th Dec 2020 at 23:40.
    Quote Quote  
  9. Originally Posted by butterw View Post
    ffm4b.bat in provided link can handle a single file input from a prompt: you paste in the input path (or drag and drop if you prefer).
    "%%~nf" is filename without extension in .bat

    if your issues persist use echo command to figure out what's wrong.
    When you drag&drop a file to an open cmd prompt (which can be opened by the .bat) it copies the filepath (tested in Win10). It's a different approach from the argument %1 one.
    Quote Quote  
  10. Originally Posted by Daringbaaz View Post
    I Want to open Batch Script Window First then drop Files There,
    Something like:

    Code:
    @echo off
    goto :loop
    
    :encode
    ffmpeg.exe -i %1 -vf "crop=w=1920:h=808:x=0:y=132,drawtext=fontsize=22:fontfile=C\\:/Windows/fonts/arial.ttf:fontcolor=white:text='NBMedia':bordercolor=black:borderw=2:x=w-tw-10:y=h-th-10"  -c:v libx264 -b:v 1200k -maxrate 1200k -bufsize 1200k "%~dpn1_new.mp4"
    return
    
    :loop
    
    cls
    echo Enter filename and press Enter
    set /p NAME=
    call :encode %NAME%
    
    goto :loop
    Quote Quote  



Similar Threads

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