I was looking for a solution to a problem and on my travels I cane across something linked to what I was doing which prompted a 2nd question.

I bundled both these questions here. If I should not I will split it into 2 separate question if requested.

I was looking for way to output an image from my ip camera using ffmpeg from a RTSP strteam.

I found it and it was this (I tested in a DOS prompt)

ffmpeg -i rtsp:// -f image2 -s 360x240 -vf fps=fps=10/60 img%3d.jpg

I was looking at a way of controlling the quality of the image. I remember when I encoded serveral jpegs to a video file I would use this:

-f image2 -r FPS-i  + MyPath + \img%05d.jpg -crf 23  -y -r 'FPS' + 'oggOut.ogg'

Here the quality is set using -crf 23 where the 23 is setting the quality of the image. I have been told the lower the number the better the quality.

Is there a way of specifing image quality in my 1st command line? I have tried putting the crf everywhere but it tells me flag not recognised.

Whilst looking for a solution I found this page:

some examples out putting jpeg from a stream

The last example on that page stated:

This will create one thumbnail image every I-frame

I had understood that an i-Frame is a change in preceding and current frames? When I tested this it just gave me a stream of images. Have I mis-understood what an I-Frame is?

  • 1
    The first line of the FFMPEG page you link to at the bottom of your question would be the one to use. However, because FFMPEG is receiving a live stream from your camera you can't use the time setting in the answer. You will need to repeat the command for each thumbnail you want to generate. – Kinnectus Feb 15 '15 at 12:34
  • @BigChris Hi, I just this now worked that out for myself. I am just trying to work out how to read to the end of stream when the basestream.length property is not available. – Andrew Simpson Feb 15 '15 at 12:36
  • Is the stream of images not what you expected from the "create one thumbnail image every I-frame" example? – llogan Feb 16 '15 at 18:14
  • @LordNeckbeard Hi, I know I got a lot to learn but what is an I-Frame please? – Andrew Simpson Feb 16 '15 at 18:45
  • 1
    Intra coded frames/slices (I‑frames/slices or Key frames) provides a good overview. – llogan Feb 17 '15 at 18:36

For JPG output use -q:v to control quality. Range is 2-31. A lower value is a higher quality, and therefore higher file size.

The -crf option is used by the encoders libx264 (H.264 video) and libvpx (VP8/VP9 video), but the values vary between these encoders. It is not for mjpeg (JPG images/MJPEG video) or libtheora (Theora video).

Also, you may find the scale video filter to be more flexible than -s because you can just declare one dimension and the filter will automatically provide the other while preserving the aspect ratio: -vf fps=1/6,scale=360:-1. Using -s to force a specific size may result in a squished or stretched output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.