subimage specification returns no images with video

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Jerware
Posts: 4
Joined: 2014-08-21T23:02:26-07:00
Authentication code: 6789

subimage specification returns no images with video

Post by Jerware »

Hi, I asked for help on the Users forum about this problem and it was suggested I report the issue here. First, a link to my initial thread:
viewtopic.php?f=1&t=26144

Basically, when converting a video file to stills, some subimage ranges produce the following non-fatal error:

convert.exe: subimage specification returns no images `video.mpeg' @ error/constitute.c/ReadImage/577.

As linked in the other thread, here is a test video that is only 20 frames long:
http://ledseq.com/downloads/20frames.mp4

Run the following and it works fine:

Code: Select all

convert 20frames.mp4[0-9] -type truecolor -resize 16x16! -quality 100 %06d.bmp
Run the following and you get the error:

Code: Select all

convert 20frames.mp4[10-19] -type truecolor -resize 16x16! -quality 100 %06d.bmp
Despite the error, it appears that any subimage range is successfully extracted. I just want to be sure there's actually nothing wrong, and hopefully find a way to avoid the error before I suggest this command to my own users.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: subimage specification returns no images with video

Post by fmw42 »

I only get this message when the first number of a range is larger than one digit.

This works

Code: Select all

convert 20frames.mp4[0-19] %06d.bmp

convert 20frames.mp4[9-19] %06d.bmp

But this does not

Code: Select all

convert 20frames.mp4[10-19] %06d.bmp

convert 20frames.mp4[11-18] %06d.bmp
However, this works.

Code: Select all

convert 20frames.mp4[10] %06d.bmp

convert 20frames.mp4[11] %06d.bmp

convert 20frames.mp4[18] %06d.bmp

convert 20frames.mp4[19] %06d.bmp
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: subimage specification returns no images with video

Post by snibgo »

Multiple digits, by itself, doesn't seem to cause a problem.

My tests suggest that errors arise when last < 2 * first.

But that might be coincidence. Someone needs to run low-level tests with the ffmpeg interface. My development environment can't do that.
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: subimage specification returns no images with video

Post by dlemstra »

It seems that ffmpeg does not support specifying a start frame. It only allows you to specify the total number of frames. It will always start at the first index. If you find an option that will allow us to specify the start index please tell us but I could not find it here: https://www.ffmpeg.org/ffmpeg.html.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: subimage specification returns no images with video

Post by snibgo »

ffmpeg: To get, for example, 12 frames from a movie starting at frame 4 (counting from zero):

Code: Select all

ffmpeg -an -r 1 -i 20frames.mp4 -ss 4 -r 1 -t 12 ox_%06d.png
Output frames will be numbered from 1, ie ox_000001.png to ox_000012.png. [EDIT corrected typo.]

-an: ignore input audio
-r 1: change input frame rate to 1 frame per second (so timestamp calculations are trivial)
-i 20frames.mp4: input filename
-ss 4: start at timestamp 4 seconds
-r 1: output framerate is 1 per second (same as input, so ffmpeg won't resample frames)
-t 12: duration of input in seconds
ox_%06d.png output filename.
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: subimage specification returns no images with video

Post by dlemstra »

That looks like it could work. I will give it a try this week and submit a patch if it works.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: subimage specification returns no images with video

Post by snibgo »

I have corrected a typo.

The order of options to ffmpeg is critical. There are two "-r 1" options. The first changes metadata of the input stream. The second would, if different to the first, cause temporal supersampling or subsampling, so the output would have a different number of frames.
snibgo's IM pages: im.snibgo.com
Post Reply