ffmpeg: Trying to take thumbnail fps=fps=1/60 works but not fps/fps=1/600

2

1

I am following this doc from the ffmpeg site:

This will create one thumbnail image every minute, named img001.jpg, img002.jpg, img003.jpg, ... (%03d means that ordinal number of each thumbnail image should be formatted using 3 digits)

ffmpeg -i myvideo.avi -f image2 -vf fps=fps=1/60 img%03d.jpg

This will create one thumbnail image every 10 minutes, named thumb0001.bmp, thumb0002.bmp, thumb0003.bmp, ...

ffmpeg -i test.flv -f image2 -vf fps=fps=1/600 thumb%04d.bmp

But If I use the 1/600 options it does not work and gives the following error:

ffmpeg -i src/e0b4c83e7ab2ada44c2785d25b0d4a9d45fc0c66.3gp -f image2 -vf fps=fps=1/250 thumbs/images%d.jpg
ffmpeg version 1.0.3 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 13 2013 21:48:31 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-3)
  configuration:
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'src/e0b4c83e7ab2ada44c2785d25b0d4a9d45fc0c66.3gp':
  Metadata:
    major_brand     : 3gp4
    minor_version   : 512
    compatible_brands: isomiso23gp4
    creation_time   : 2013-11-27 14:02:52
  Duration: 00:05:01.33, start: 0.000000, bitrate: 177 kb/s
    Stream #0:0(und): Video: h263 (s263 / 0x33363273), yuv420p, 176x144 [SAR 12:11 DAR 4:3], 161 kb/s, 15 fps, 15 tbr, 15 tbn, 29.97 tbc
    Metadata:
      creation_time   : 2013-11-27 14:06:48
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s
    Metadata:
      creation_time   : 2013-11-27 14:06:48
      handler_name    : SoundHandler
[mjpeg @ 0x3621940] bitrate tolerance too small for bitrate
[mjpeg @ 0x363c1c0] ff_frame_thread_encoder_init failed
Output #0, image2, to 'thumbs/images%d.jpg':
  Metadata:
    major_brand     : 3gp4
    minor_version   : 512
    compatible_brands: isomiso23gp4
    Stream #0:0(und): Video: mjpeg, yuvj420p, 176x144 [SAR 12:11 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 0k tbc
    Metadata:
      creation_time   : 2013-11-27 14:06:48
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h263 -> mjpeg)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Why does 1/60 work and not 1/600? How to fix it? Also updating the server is not an option.

Starx

Posted 2013-12-01T23:39:09.303

Reputation: 1 881

What is the lowest value that still gives these errors? Does this value change with other inputs? Testing with a recent static build of ffmpeg will be helpful (just download, extract, and run).

– llogan – 2013-12-02T05:35:41.717

Answers

2

I do not yet know why the default settings for jpg output while using the fps video filter with certain values causes the errors:

[mjpeg @ 0x3621940] bitrate tolerance too small for bitrate
[mjpeg @ 0x363c1c0] ff_frame_thread_encoder_init failed

Example

A workaround is to use the -qscale:v (or the alias -q:v) option:

ffmpeg -i input.mkv -vf fps=1/250 -qscale:v 2 output%d.jpg

Notes

  • The effective range for -qscale:v when outputting to jpeg is a linear scale of 2-31. A lower value is a higher quality.

  • -f image2 is not needed.

  • You can also omit the additional fps= as shown in my example.

  • Another workaround is to use a different output format, such as png, but this may not be an acceptable solution for you.

  • Another possible workaround is to use the select video filter instead, but it is not as user friendly.

  • Using -threads 1 eliminates the ff_frame_thread_encoder_init failed error, but not the other error.

  • The same errors show up when using -r instead of the fps filter.

I'll update this answer if I find out more (I ran out of time to do a proper investigation...).

llogan

Posted 2013-12-01T23:39:09.303

Reputation: 31 929