<h3>Option placement matters</h3>

<blockquote>
  <p>Is there an option I'm missing?</p>
</blockquote>

<p>No, but option placement matters. Options before the input apply to the input, and options before the output generally apply to the output. The exception are global options. See the <a href="http://ffmpeg.org/ffmpeg.html#Synopsis" rel="nofollow noreferrer">FFmpeg synopsis</a> and <a href="http://ffmpeg.org/ffmpeg.html#Description" rel="nofollow noreferrer">FFmpeg description</a> for more details on option placement.</p>

<p>Therefore, you must move your <code>-q</code> (alias for <code>-qscale</code>) option:</p>

<pre><code>ffmpeg -i video_test.avc -q:v 2 frames/frames_%04d.jpg
</code></pre>

<ul>
<li><code>-f image2</code> is superfluous here since ffmpeg knows that your outputs are images.</li>
<li>A sane range for <code>-q:v</code> for the encoder <code>mjpeg</code> is 2-5; lower is higher quality.</li>
<li>It is recommended to be explicit as to which stream you want to apply <code>-q</code> to since ffmpeg can not know if it should be applied to video or audio, so in your case use <code>-q:v</code>. This is good practice, although it does not matter for your input since you have no audio.</li>
</ul>

<h3>A fake "ffmpeg"</h3>

<blockquote>
  <p>I've noticed that FFMPEG on my Mac works as expected and generates nice frames, but FFMPEG on my production server that runs Ubuntu exhibits this problem.</p>
</blockquote>

<p>Ubuntu no longer uses FFmpeg:</p>

<ul>
<li><a href="https://stackoverflow.com/a/9477756/1109017">Who can tell me the difference and relation between ffmpeg, libav, and avconv?</a></li>
<li><a href="http://blog.pkh.me/p/13-the-ffmpeg-libav-situation.html" rel="nofollow noreferrer">The FFmpeg/Libav situation</a></li>
</ul>

<p>Since I do not use the fork my answer may not work for you.</p>

<h3>Getting ffmpeg</h3>

<p>FFmpeg development is very active and it is always a good idea to use a recent version. Two main ways of getting it are:</p>

<ul>
<li>Follow a step-by-step <a href="http://trac.ffmpeg.org/wiki/UbuntuCompilationGuide" rel="nofollow noreferrer">guide to compile ffmpeg</a></li>
<li>Use an already compiled <a href="http://ffmpeg.org/download.html#LinuxBuilds" rel="nofollow noreferrer">ffmpeg build</a> (<a href="https://askubuntu.com/a/270107/59378">instructions</a>)</li>
</ul>

CC BY-SA 3.0
2013-08-05T20:13:09.657Z
It was the placement of the `-q 1` that did it. Thanks.
CadentOrange
CC BY-SA 3.0
2013-08-05T19:31:39.283Z
2013-08-05T19:31:39.283Z
2017-05-23T12:40:36.170Z
llogan
<p>I'm attempting to extract the individual frames from a raw AVC video stream. I'm doing this via the following ffmpeg command: <code>ffmpeg -q 1 -i video_test.avc -f image2 frames/frames_%04d.jpg</code></p>

<p>The problem I'm encountering is the first few frames look good. I'm including an example below.
<img src="https://i.sstatic.net/9KWDv.jpg" alt="Example of good frame"></p>

<p>The extracted frames then get progressively worse and by the time I get to the 17th frame, they're really blocky.
<img src="https://i.sstatic.net/imKyK.jpg" alt="Example of blocky image"></p>

<p>You get get the raw video from this <a href="https://dl.dropboxusercontent.com/u/21682354/Internet%20Posts/ffmpeg%20issue/video_test.avc" rel="noreferrer">link</a>.</p>

<p>Is there an option I'm missing? I've noticed that FFMPEG on my Mac works as expected and generates nice frames, but FFMPEG on my production server that runs Ubuntu exhibits this problem. </p>

CC BY-SA 3.0
2013-08-05T16:16:02.730Z
Does it improve each time a keyframe is reached or does it continue to get worse indefinitely?
AJ Henderson
CC BY-SA 3.0
2013-08-05T16:54:25.820Z
Once it gets to the blocky state, it stays at that blocky state indefinitely. It doesn't get worse.
CadentOrange
CC BY-SA 3.0
2013-08-05T16:56:01.353Z
Have you tried different versions of FFMPEG to see if it is just a bug in the particular version?  Sorry, just throwing out random troubleshooting thoughts.  I'm not aware of anything specific to this problem.
AJ Henderson
CC BY-SA 3.0
2013-08-05T18:59:07.360Z
I'm using the binaries from the repository listed on http://ffmpeg.org/download.html. This gets updated somewhat frequently and the last update was on July 15th. I'll try building it from source tomorrow and see if that changes anything.
CadentOrange
<video-quality><ffmpeg>
FFMPEG output is blocky
CadentOrange
# FFMPEG output is blocky

(Asked by: username_0 on 2013-08-05)

I'm attempting to extract the individual frames from a raw AVC video stream. I'm doing this via the following ffmpeg command: `ffmpeg -q 1 -i video_test.avc -f image2 frames/frames_%04d.jpg`

The problem I'm encountering is the first few frames look good. I'm including an example below.
![Example of good frame](https://i.sstatic.net/9KWDv.jpg)

The extracted frames then get progressively worse and by the time I get to the 17th frame, they're really blocky.
![Example of blocky image](https://i.sstatic.net/imKyK.jpg)

You get get the raw video from this [link](https://dl.dropboxusercontent.com/u/21682354/Internet%20Posts/ffmpeg%20issue/video_test.avc).

Is there an option I'm missing? I've noticed that FFMPEG on my Mac works as expected and generates nice frames, but FFMPEG on my production server that runs Ubuntu exhibits this problem.

**Tags:** video-quality, ffmpeg

> **Comments:**
> **username_1**: Does it improve each time a keyframe is reached or does it continue to get worse indefinitely?  
> **username_0**: Once it gets to the blocky state, it stays at that blocky state indefinitely. It doesn't get worse.  
> **username_1**: Have you tried different versions of FFMPEG to see if it is just a bug in the particular version?  Sorry, just throwing out random troubleshooting thoughts.  I'm not aware of anything specific to this problem.  
> **username_0**: I'm using the binaries from the repository listed on http://ffmpeg.org/download.html. This gets updated somewhat frequently and the last update was on July 15th. I'll try building it from source tomorrow and see if that changes anything.  

---

## 1 answers

### Answer by username_2 on 2013-08-05. Score: 8 | Accepted answer

Option placement matters

Is there an option I'm missing?

No, but option placement matters. Options before the input apply to the input, and options before the output generally apply to the output. The exception are global options. See the FFmpeg synopsis and FFmpeg description for more details on option placement.
Therefore, you must move your -q (alias for -qscale) option:
ffmpeg -i video_test.avc -q:v 2 frames/frames_%04d.jpg


-f image2 is superfluous here since ffmpeg knows that your outputs are images.
A sane range for -q:v for the encoder mjpeg is 2-5; lower is higher quality.
It is recommended to be explicit as to which stream you want to apply -q to since ffmpeg can not know if it should be applied to video or audio, so in your case use -q:v. This is good practice, although it does not matter for your input since you have no audio.

A fake "ffmpeg"

I've noticed that FFMPEG on my Mac works as expected and generates nice frames, but FFMPEG on my production server that runs Ubuntu exhibits this problem.

Ubuntu no longer uses FFmpeg:

Who can tell me the difference and relation between ffmpeg, libav, and avconv?
The FFmpeg/Libav situation

Since I do not use the fork my answer may not work for you.
Getting ffmpeg
FFmpeg development is very active and it is always a good idea to use a recent version. Two main ways of getting it are:

Follow a step-by-step guide to compile ffmpeg
Use an already compiled ffmpeg build (instructions)

> **Comments:**
> **username_0**: It was the placement of the `-q 1` that did it. Thanks.  

---

