VideoHelp Forum




+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 31 to 41 of 41
  1. @ pcspeak & davexnet ,
    I could not get the batch script videoAI posted in #17 to work.
    It did not create a file & I could not get it to pause so I could see if there is an error.
    I added the "pause" command in various places in the script.
    Does this #17 batch script work for either of you ?

    @ videoAI.
    I'm a novice at using batch script.
    Does the # 17 batch script work for you?
    Maybe the failure is because I use Windows 7 32-bit.

    I do not need to do this like Ygramu does.I'm just trying to learn something.
    The batch script posted by pcspeak & davexnet do work for me.
    To get those batch scripts to do what I want or close I have to change the seconds of the cuts.

    Since I have the path set in Environment Variables I can remove or leave the "set path" locations.
    Quote Quote  
  2. I think there are now too many cooks in the kitchen.
    pcspeak or davexnet can help you tweak a working
    script.

    Disconnecting .. good luck to ya all

    Originally Posted by cholla View Post
    @ pcspeak & davexnet

    @ videoAI.
    I'm a novice at using batch script.
    Does the # 17 batch script work for you?
    Maybe the failure is because I use Windows 7 32-bit.

    I do not need to do this like Ygramu does.I'm just trying to learn something.
    The batch script posted by pcspeak & davexnet do work for me.
    To get those batch scripts to do what I want or close I have to change the seconds of the cuts.

    Since I have the path set in Environment Variables I can remove or leave the "set path" locations.
    As always .. there is nothing wrong with my environment
    Quote Quote  
  3. Member Ygramul's Avatar
    Join Date
    Jan 2007
    Location
    Poland
    Search Comp PM
    Just to be clear, the files I want to process are the standard AVC/AAC fare, downloaded from Youtube. Nothing out of the ordinary.

    Example MediaInfo
    Quote Quote  
  4. @ Ygramul ,
    The batch script that davexnet posted works for me.
    To get it to do the example of what you wanted in post #1.
    30 seconds removed from the beginning & 10 seconds removed from the end.
    I only made a slight modification.
    To work the bat file has to be in the C:\Program Files\MediaInfo\MediaInfo_CLI folder.(For my Windows 7 32-bit)
    If you are using Windows 64-bit probably it is similar to this:
    C:\Program Files (x86)\C:\Program Files\MediaInfo\MediaInfo_CLI folder
    This is davexnet's batch script with the modifications I made:
    Code:
    rem @echo off
    set ffmpeg_path1=ffmpeg.exe
    set ffprobe_path1=ffprobe.exe
    
    rem md trimmed
    
    for %%a in ("*.mp4") do (
    for /f "tokens=* usebackq" %%b in (`%ffprobe_path1% -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) do (
    call :Process "%%a" %%b
    )
    )
    pause
    goto :eof
    
    :Process
    setlocal
    set file=%~1
    set duration=%~2
    
    rem Remove fractional seconds
    for /f "tokens=1 delims=." %%d in ("%duration%") do set /a new_end=%%d - 10
    
    rem Format the new duration in HH:MM:SS
    set /a hh=new_end / 3600
    set /a mm=(new_end %% 3600) / 60
    set /a ss=new_end %% 60
    
    rem Pad with zeros
    if %hh% lss 10 set hh=0%hh%
    if %mm% lss 10 set mm=0%mm%
    if %ss% lss 10 set ss=0%ss%
    
    set end_time=%hh%:%mm%:%ss%
    
    echo Trimming %file% from 00:00:00 to %end_time%
    %ffmpeg_path1% -i "%file%" -ss 00:00:30 -to %end_time% -c:v copy -c:a copy "trimmed\%file%"
    endlocal
    goto :eof
    set ffmpeg_path1=ffmpeg.exe
    set ffprobe_path1=ffprobe.exe
    Worked for me but I have this setup with "Environment Variables".
    It does not work unless you have this setup with "Environment Variables".
    Last edited by cholla; 29th Jun 2025 at 12:49.
    Quote Quote  
  5. Member Ygramul's Avatar
    Join Date
    Jan 2007
    Location
    Poland
    Search Comp PM
    Originally Posted by cholla View Post
    @ Ygramul ,
    The batch script that davexnet posted works for me.
    To get it to do the example of what you wanted in post #1.
    30 seconds removed from the beginning & 10 seconds removed from the end.
    I only made a slight modification.
    To work the bat file has to be in the C:\Program Files\MediaInfo\MediaInfo_CLI folder.(For my Windows 7 32-bit)
    If you are using Windows 64-bit probably it is similar to this:
    C:\Program Files (x86)\C:\Program Files\MediaInfo\MediaInfo_CLI folder
    This is davexnet's batch script with the modifications I made:
    Thanks again. I now realize that I can't possibly avoid copying the .exes to the input folder. It looks like that was the culprit all along. Now everything works fine. I can just change the number of seconds to trim and it's nice and fast
    Quote Quote  
  6. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Originally Posted by Ygramul View Post
    Originally Posted by cholla View Post
    @ Ygramul ,
    The batch script that davexnet posted works for me.
    To get it to do the example of what you wanted in post #1.
    30 seconds removed from the beginning & 10 seconds removed from the end.
    I only made a slight modification.
    To work the bat file has to be in the C:\Program Files\MediaInfo\MediaInfo_CLI folder.(For my Windows 7 32-bit)
    If you are using Windows 64-bit probably it is similar to this:
    C:\Program Files (x86)\C:\Program Files\MediaInfo\MediaInfo_CLI folder
    This is davexnet's batch script with the modifications I made:
    Thanks again. I now realize that I can't possibly avoid copying the .exes to the input folder. It looks like that was the culprit all along. Now everything works fine. I can just change the number of seconds to trim and it's nice and fast
    Well not necessarily. Just because we didn't get it working doesn't mean it cant be done.
    For example,
    Code:
    rem @echo off
    set ffmpeg_path1=m:\bin64\ffmpeg.exe
    set ffprobe_path1=m:\bin64\ffprobe.exe
    
    md trimmed
    
    for %%a in ("*.mp4") do (
    for /f "tokens=* usebackq" %%b in (`%ffprobe_path1% -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) do (
    call :Process "%%a" %%b
    )
    )
    pause
    goto :eof
    
    :Process
    setlocal
    set file=%~1
    set duration=%~2
    
    rem Remove fractional seconds
    for /f "tokens=1 delims=." %%d in ("%duration%") do set /a new_end=%%d - 10
    
    rem Format the new duration in HH:MM:SS
    set /a hh=new_end / 3600
    set /a mm=(new_end %% 3600) / 60
    set /a ss=new_end %% 60
    
    rem Pad with zeros
    if %hh% lss 10 set hh=0%hh%
    if %mm% lss 10 set mm=0%mm%
    if %ss% lss 10 set ss=0%ss%
    
    set end_time=%hh%:%mm%:%ss%
    
    echo Trimming %file% from 00:03:00 to %end_time%
    %ffmpeg_path1% -i "%file%" -ss 00:00:03 -to %end_time% -c:v copy -c:a copy "trimmed\%file%"
    endlocal
    goto :eof
    Quote Quote  
  7. maybe there was a problem because of a space in a windows path, example:
    Code:
    set ffmpeg_path1=m:\bin 64\ffmpeg.exe
    I think above example would not work, if I remember correctly, it would need to be coded like this:
    Code:
    set "ffmpeg_path1=m:\bin 64\ffmpeg.exe"
    it is a good habit to always put a quotes like that when setting a variable for windows batch code
    Quote Quote  
  8. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Hi _AL_ - yes, the script as I gave only works if there are no spaces in the path to ffmpeg/ffprobe.
    However, I wasn't able to find the right syntax in the short time I looked at it earlier today.

    Unfortunately your suggestion doesn't work either
    Code:
    M:\copies>rem @echo off
    
    M:\copies>set "ffmpeg_path1=m:\bin 64\ffmpeg.exe"
    
    M:\copies>set "ffprobe_path1=m:\bin 64\ffprobe.exe"
    
    M:\copies>md trimmed
    A subdirectory or file trimmed already exists.
    
    M:\copies>for %a in ("*.mp4") do (for /F "tokens=* usebackq" %b in (`m:\bin 64\ffprobe.exe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "%a"`) do (call :Process "%a" %b ) )
    
    M:\copies>(for /F "tokens=* usebackq" %b in (`m:\bin 64\ffprobe.exe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "mech_human_trials (2014 short).mp4"`) do (call :Process "mech_human_trials (2014 short).mp4" %b ) )
    'm:\bin' is not recognized as an internal or external command,
    operable program or batch file.
    Quote Quote  
  9. ok, maybe it was like this, not sure now:
    Code:
    set ffmpeg_path1="m:\bin 64\ffmpeg.exe"
    this might work,
    echo prints that variable always ok, anyway, but if running that variable as in a cmd with those quotes, it should work
    Quote Quote  
  10. or actually revisiting all scripts, perhaps the best is to do this:
    Code:
    set "ffmpeg_path1=m:\bin 64\ffmpeg.exe"
    and then just using variable in cmd line:
    Code:
    "%ffmpeg_path1%" -i "%file%" -ss 00:00:03 ...
    You actually did it already, wrapping quotes around %file%, so that executable needs that as well.
    Quote Quote  
  11. Originally Posted by Ygramul View Post
    Thanks again. I now realize that I can't possibly avoid copying the .exes to the input folder. It looks like that was the culprit all along. Now everything works fine. I can just change the number of seconds to trim and it's nice and fast
    @ Ygramul,
    It is working for you this way. So you might want to leave everything as you have it.

    This is to inform on how I have this on my Windows 7 32-bit.
    There is only one .exe in my C:\Program Files\MediaInfo\MediaInfo_CLI. It is: MediaInfo.exe

    I have ffmpeg.exe & ffprobe.exe in this folder: C:\Program Files\ffmpeg\bin

    I have this location in Environment Variables.
    Select the button on the lower right.
    Image
    [Attachment 87697 - Click to enlarge]


    Highlight Path & select Edit.
    Image
    [Attachment 87698 - Click to enlarge]


    In Edit add: C:\Program Files\ffmpeg\bin;
    Be sure to use the semicolon at the end.
    Then select OK , OK , & OK again.

    Image
    [Attachment 87699 - Click to enlarge]


    This is why my OS finds ffmpeg.exe & ffprobe.exe with this part of davexnet's batch script.Post# 25
    Code:
    set ffmpeg_path1=ffmpeg.exe
    set ffprobe_path1=ffprobe.exe
    Quote Quote  



Similar Threads

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