@ 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.
+ Reply to Thread
Results 31 to 41 of 41
-
-
As always .. there is nothing wrong with my environment
-
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 -
@ 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
It does not work unless you have this setup with "Environment Variables".Last edited by cholla; 29th Jun 2025 at 12:49.
-
-
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
-
maybe there was a problem because of a space in a windows path, example:
Code:set ffmpeg_path1=m:\bin 64\ffmpeg.exe
Code:set "ffmpeg_path1=m:\bin 64\ffmpeg.exe"
-
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.
-
ok, maybe it was like this, not sure now:
Code:set ffmpeg_path1="m:\bin 64\ffmpeg.exe"
echo prints that variable always ok, anyway, but if running that variable as in a cmd with those quotes, it should work -
or actually revisiting all scripts, perhaps the best is to do this:
Code:set "ffmpeg_path1=m:\bin 64\ffmpeg.exe"
Code:"%ffmpeg_path1%" -i "%file%" -ss 00:00:03 ...
-
@ 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.
[Attachment 87697 - Click to enlarge]
Highlight Path & select Edit.
[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.
[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
Similar Threads
-
Video Freezing Issue at the Start of Clips Cut with ffmpeg
By doganjr in forum EditingReplies: 16Last Post: 5th Dec 2024, 04:32 -
Ffmpeg add images to MP4 video, one in front, one in end
By zydjohn in forum Newbie / General discussionsReplies: 1Last Post: 23rd Dec 2021, 02:45 -
FFMPEG transcoded MPEG-TS files are lagging to start video
By dogmydog in forum Video ConversionReplies: 19Last Post: 12th Apr 2021, 09:01 -
How to add/save 'start' and 'end' points on multiple parts of video (VLC) ?
By aaajan in forum Software PlayingReplies: 2Last Post: 7th Mar 2021, 06:10 -
ffmpeg cut off first 10 seconds of video then add intro 15 seconds in
By PeterWall in forum Newbie / General discussionsReplies: 2Last Post: 30th Jul 2020, 06:18