I have recorded some videos with the same length of 40 seconds. I have old videos with the same name but the length varies between 28-38 seconds. I want the new videos to be cut to the same length as the old ones. The new and old has the same names. It's only the end of the video that has to be cut. Is it possible with a script using ffmpeg?
Anyone could please provide script for doing this?
I'd have to get the length of the old video then cut the new video with same name to the same length as the old. Currently I use this script for cutting a video to 30 seconds.
@echo off
for %%a in ("*.mp4") do ffmpeg -ss 0 -to 30 -i "%%a" "converted\%%~na.mp4"
Need to replace 30 seconds with a parameter.
Thanks
+ Reply to Thread
Results 1 to 3 of 3
-
-
You can get the length of a video into an environment variable with ffprobe and the following:
Code:ffprobe.exe -v quiet -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 >duration.txt set /p duration=<duration.txt del duration.txt
Code:ffmpeg -i input.mp4 -ss 0 -to %duration% output.mp4
Similar Threads
-
Problem with video length using Lossless Cut to remove chapters
By Shadybob in forum EditingReplies: 2Last Post: 22nd Dec 2021, 21:38 -
how to fix seeking/length of video
By rokicha in forum Newbie / General discussionsReplies: 4Last Post: 6th Jun 2020, 09:46 -
MediaInfo and Encore Disagree on Video Length
By koberulz in forum Newbie / General discussionsReplies: 3Last Post: 5th Jul 2018, 06:54 -
Wrong video length after remuxing
By x264 in forum Newbie / General discussionsReplies: 5Last Post: 17th Feb 2018, 10:42 -
No length in video file or no streaming
By Tarsonix in forum Newbie / General discussionsReplies: 0Last Post: 30th Jul 2017, 15:11