[FFmpeg-user] Trying to cut 5 sec of beginning and ending of mp4 files

Sam Logan shapableline at gmail.com
Tue Jan 19 02:29:45 CET 2016


>> I am been trying almost every combination of switches to be able to cut 5
sec from the start and 5 sec from the ending of variable length mp4 files.

>> I have made some headway.  I am using this command line:
for %%a in ("*.mp4") do ffmpeg -ss 00:00:10 -i  "%%a" -codec copy
"newfiles\%%~na.mp4"
which does seem to cut out the first 10 seconds of the 100 MPG4 files I
have tried.  Now if I
can only figure out how to cut out the last 5 seconds.  Remember these mpeg
files are
varying lengths varying from 24 minutes to 1 hr 20 minutes.

The -ss option specifies the STARTING time. Since you want to crop 5
seconds from the beginning, you want to use "-ss 00:00:05", not "-ss
00:00:10".

FFmpeg does not, AFAIK, have an option to directly specify ending time.
Instead, you specify DURATION of the video with the -t option. Since you
want to crop 5 seconds from the beginning and 5 seconds from the end, that
is a total of 10 seconds you want to remove from duration, so you will need
to subtract 10 seconds from the duration of each video.

AFAIK, FFmpeg's -t option has no way of accepting an arithmetic expression
consisting of the total duration less 10 seconds. So you will have to do
that part semi-manually. So here is what I would do if I were in your
position:

For each of the 100+ videos you want to cut, open that video and manually
note its total duration in a text file or spreadsheet. Then subtract 10
seconds from each video's duration.

Then write a batch file, consisting of one line for each video:

ffmpeg -i "VideoPath\VideoInput1.mp4" -ss 00:00:05 -t hh:mm:ss -codec copy
"VideoPath\VideoOutput1.mp4"
ffmpeg -i "VideoPath\VideoInput2.mp4" -ss 00:00:05 -t hh:mm:ss -codec copy
"VideoPath\VideoOutput2.mp4"
etc.

and for each line:

-modifying "VideoPath" to the video path
-modifying "VideoInputN.mp4" and "VideoOutputN.mp4" to each video's filename
-modifying "hh:mm:ss" to the video's duration less 10 seconds

Then just run the batch file and you're done.

On Mon, Jan 18, 2016 at 5:54 PM, <tsh at tshilton.com> wrote:

> Hi
> I have made some headway.  I am using this command line:
> for %%a in ("*.mp4") do ffmpeg -ss 00:00:10 -i  "%%a" -codec copy
> "newfiles\%%~na.mp4"
> which does seem to cut out the first 10 seconds of the 100 MPG4 files I
> have tried.  Now if I
> can only figure out how to cut out the last 5 seconds.  Remember these
> mpeg files are
> varying lengths varying from 24 minutes to 1 hr 20 minutes.
>
> Again any help would be appricated.
> PS I am see an undetermined length message at the end of each file run in
> the bat file.  It seems
> To add about 5 or so seconds before showing the last 20 frames the best I
> can tell.  These last
> 20 frames is what I would like to get removed from the MP4 file that I
> already converted with
> The above command line.
>
> Thanks
> Thomas
>
> -----Original Message-----
> From: ffmpeg-user [mailto:ffmpeg-user-bounces at ffmpeg.org] On Behalf Of
> tsh at tshilton.com
> Sent: Monday, January 18, 2016 1:52 PM
> To: ffmpeg-user at ffmpeg.org
> Subject: [FFmpeg-user] Trying to cut 5 sec of beginning and ending of mp4
> files
>
> Hi
>
> I am been trying almost every combination of switches to be able to cut 5
> sec from the start and 5 sec from the ending of variable length mp4 files.
>
> I have not been successful at doing either.  I guess I really don't
> understand the usage.  I have more than 100 files to do.
>
> Can anyone suggest a command string that will work?
>
>
>
> Thanks
>
> Thomas
>
>
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list