.bat file command

marlon241982

Established
Mga master... ano kaya mali dito? mag kahiwalay na bat yan pang video at yung isa pang merge ng music. tapos ginawa ko pinaayos ko kay pareng gpt eto ang binigay nya kaso ayaw tumalab.

command

echo off
setlocal

set "INPUT=input.mp4"
set "MUSIC=music.mp3"
set "OUTPUT=output.mp4"

:: Get video duration
for /f %%a in ('
ffprobe -v error -show_entries format^=duration ^
-of default^=nokey^=1:noprint_wrappers^=1 "%INPUT%"
') do set DURATION=%%a

:: Calculate music start time (45 seconds before end)
for /f %%a in ('
powershell -NoProfile -Command "[math]::Max(0,[double]('%DURATION%')-45)"
') do set START=%%a

echo Video Duration: %DURATION%
echo Background Music Starts At: %START% seconds

ffmpeg -i "%INPUT%" -i "%MUSIC%" ^
-filter_complex ^
"[0:v]scale=iw*0.98:ih*0.98,scale=iw:ih,eq=contrast=0.92:brightness=-0.01:saturation=0.78,noise=alls=10:allf=t+u,gblur=sigma=0.4,curves=vintage[v]; ^
[0:a]highpass=f=80,lowpass=f=7000,volume=0.95[main]; ^
[1:a]volume=0.30,adelay=%START%s:all=1[music]; ^
[main][music]amix=inputs=2:duration=first:dropout_transition=2[a]" ^
-map "[v]" ^
-map "[a]" ^
-c:v libx264 ^
-crf 22 ^
-preset slow ^
-c:a aac ^
-b:a 160k ^
-map_metadata -1 ^
-map_chapters -1 ^
-shortest ^
"%OUTPUT%"

echo.
echo Done!
pause

Eto naman ang error

[AVFormatContext @ 000001e9a921ecc0] Unable to choose an output format for '^'; use a standard extension for the filename or specify the format manually.
[out#0 @ 000001e9a70b8ec0] Error initializing the muxer for ^: Invalid argument
Error opening output file ^.
Error opening output files: Invalid argument
'-map' is not recognized as an internal or external command,
operable program or batch file.


sana may makatulong para isang execute na lang ako salamat po...
 
echo off
setlocal enabledelayedexpansion

:: Get the input video from drag & drop
set "input=%~1"

if "%input%"=="" (
echo Drag and drop a video file onto this .bat
pause
exit /b
)

:: Get base name (without extension)
for %%F in ("%input%") do set "basename=%%~nF"

:: Output name
set "output=%basename%_out.mp4"

echo === Step 1: Get durations ===
for /f "tokens=*" %%a in ('ffprobe -v error -show_entries format^=duration -of default^=nk^=1:nw^=1 "%input%"') do set "vdur=%%a"
for /f "tokens=*" %%a in ('ffprobe -v error -show_entries format^=duration -of default^=nk^=1:nw^=1 "music.mp3"') do set "adur=%%a"

set /a cutpoint=%vdur% - %adur%
echo Video duration: %vdur% sec
echo Music duration: %adur% sec
echo Music will replace starting at: %cutpoint% sec

echo === Step 2: Process ===
ffmpeg -y -i "%input%" -i "music.mp3" -filter_complex "[0:a]atrim=0:%cutpoint%,asetpts=PTS-STARTPTS[main];[1:a]asetpts=PTS-STARTPTS[music];[main][music]concat=n=2:v=0:a=1[aout]" -map 0:v -c:v copy -map "[aout]" -c:a aac -map_metadata -1 -map_chapters -1 "%output%"

echo === Done! Output: %output% ===
pause
 
try this


echo off
setlocal

set "INPUT=input.mp4"
set "MUSIC=music.mp3"
set "OUTPUT=output.mp4"

for /f %%a in ('
ffprobe -v error -show_entries format^=duration ^
-of default^=nokey^=1:noprint_wrappers^=1 "%INPUT%"
') do set DURATION=%%a

for /f %%a in ('
powershell -NoProfile -Command "[math]::Max(0,[double]('%DURATION%')-45)*1000"
') do set START_MS=%%a

echo Video Duration: %DURATION% seconds
echo Background Music Starts At: %START_MS% ms

ffmpeg -i "%INPUT%" -i "%MUSIC%" ^
-filter_complex ^
"[0:v]scale=iw*0.98:ih*0.98,eq=contrast=0.92:brightness=-0.01:saturation=0.78,noise=alls=10:allf=t+u,gblur=sigma=0.4,curves=vintage[v]; ^
[0:a]highpass=f=80,lowpass=f=7000,volume=0.95[main]; ^
[1:a]volume=0.30,adelay=%START_MS%:all=1[music]; ^
[main][music]amix=inputs=2:duration=first:dropout_transition=2[a]" ^
-map "[v]" ^
-map "[a]" ^
-c:v libx264 -crf 22 -preset slow ^
-c:a aac -b:a 160k ^
-map_metadata -1 -map_chapters -1 ^
-shortest ^
"%OUTPUT%"

echo.
echo Done!
pause
 

About this Thread

  • 3
    Replies
  • 202
    Views
  • 3
    Participants
Last reply from:
Undisturbed

Trending Topics

Online now

Members online
411
Guests online
3,709
Total visitors
4,120

Forum statistics

Threads
2,310,609
Posts
29,157,513
Members
1,188,159
Latest member
pwoul
Back
Top