Skip parts of video while converting it to images with ffmpeg

0

1

I use this command on ffmpeg to convert a video into images:

ffmpeg -i video.mp4 -q:v 1 -r 1 -f image2 frame-03d%.jpg

What I want to do is to skip the first x seconds and the last y seconds of the video from frame convertion, witch basically are intro and ending. Every video have different lenght but intro and ending are always the same in every video (about 30 seconds). Is there a way to do this?

Hyperion

Posted 2015-05-12T18:50:04.830

Reputation: 389

Answers

1

ffmpeg -i BigBuckBunny_320x180.mp4 -ss 00:00:09.000 -t 60 -q:v 1 -r 1 -f image2 image_%05d.jpeg

-ss start time
-t duration from start time

or use trim

ffmpeg -i BigBuckBunny_320x180.mp4 -vf trim=09:69 -r 1 -f image2 image_%05d.jpeg

How to get duration of video example.

ffprobe -v quiet -show_streams -select_streams v:0 -show_entries stream=duration BigBuckBunny_320x180.mp4 | grep duration | awk -F= '{print $2}'

Alam

Posted 2015-05-12T18:50:04.830

Reputation: 146

It should be noted that for videos of varying length, you have to use a shell script or batch file to figure out the total duration in seconds and then subtract the 30 seconds from the end before calling ffmpeg. This is the "trickier" part of the question. – slhck – 2015-05-13T08:00:45.763

Its just en example. Anyways he is going to get intro and ending period. He can get clip duration from same iteration. – Alam – 2015-05-13T18:40:10.383

Yes, he can, but like I said, this is the more complicated issue here. So your answer would be more helpful if it showed how to get the duration, do the math, then pass that to ffmpeg. – slhck – 2015-05-14T14:56:05.697

@slhck I added command to get duration of video. Hope it helps. – Alam – 2015-05-14T16:51:09.313

Ok so the command should be -t x where x is calculated as VIDEO DURATION - 60 (30 seconds from the begin and 30 seconds from the end). But i don't get what the trim command does, what is 09:69? – Hyperion – 2015-05-14T17:17:10.923

@Hyperion It trims from 9 to 69 seconds. – slhck – 2015-05-14T17:32:48.410