<p>Just do it all as one step and forget about up-sampling to 16 bit. That just adds complexity, processing time, extra storage and for no gain in quality in the end result that anyone could possibly perceive. </p>

<pre><code>fmpeg myinputVideo.avi -vf "scale=3840:2160,unsharp=1x=13:ly=13"la=2.0" myoutput.mp4
</code></pre>

<p>The internal process of ffmpeg works basically like this: </p>

<pre><code> _______              ______________
|       |            |              |
| input |  demuxer   | encoded data |   decoder
| file  | ---------&gt; | packets      | -----+
|_______|            |______________|      |
                                           v
                                       _________
                                      |         |
                                      | decoded |
                                      | frames  |
                                      |_________|
 ________             ______________       |
|        |           |              |      |
| output | &lt;-------- | encoded data | &lt;----+
| file   |   muxer   | packets      |   encoder
|________|           |______________|
</code></pre>

<p>The "decoded frames" box basically is where the pixels in the image are stored in memory as uncompressed RGB or YUV (or whatever) samples. That's the point where your footage is as good as it is going to get. Any extra filtering or processing will notionally degrade the image due to quantisation loss, or compression etc.. That image is what is sent to the filter chain. What you're doing is:</p>

<pre><code>demux → decode → [decoded frames] → resample → encode → mux → save → 
demux → decode → [decoded, resampled frames] → upscale → sharpen → encode → mux → save
</code></pre>

<p>so you're applying your filters to frames that have had an extra resample and encode step added, not to mention taking up a whole bunch'a space on your HDD.</p>

<p>When you filter something the output of one filter goes to the input of the next filter in the chain, so if you put scale first the scaled image is then sent to the sharpen filter. </p>

<pre><code> _______        ________        _________        ________
|       |      |        |      |         |      |        |
| input | ---&gt; | scale  | ---&gt; | sharpen | ---&gt; | output |
|_______|      |________|      |_________|      |________|
</code></pre>

<p>You can get more complex by using <code>-filter_complex</code> which allows you to have various inputs and outputs for filters.</p>

<p><a href="https://ffmpeg.org/ffmpeg.html#Filtering" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg.html#Filtering</a> for more ascii-art empowered knowledge</p>

CC BY-SA 4.0
2021-03-01T10:15:53.977Z
Is `"scale=3840:2160,unsharp=1x=13:ly=13"la=2.0"` a valid syntax? Should not theree be something else instead of double quote in the `13"la`? Upd. judgung by the [docs](https://ffmpeg.org/ffmpeg-filters.html#toc-unsharp-1) it should be `:` instead of `"` - `"scale=3840:2160,unsharp=1x=13:ly=13:la=2.0"`
Klesun
CC BY-SA 4.0
2018-11-27T03:41:54.047Z
2018-11-27T04:04:24.273Z
2018-11-27T04:04:24.273Z
stib
<p><strong>Edit: its not liking it when I specify .exr as the output file....not sure if there's a fix to support exr in ffmpeg. Just pretends its .png then unless you can help with that as well</strong></p>

<p>Hi so I transcoded a 30 min video into a 16 bit 1080p.exr image strip. I then plan on upscaling these images with ffmpeg to 4k. I then want to render it out again as an 8 bit h.264 .avi.</p>

<p>Somewhere here I want to apply sharpening to make the upscale a bit cleaner (this command looked nice when applied to the exr on their own):</p>

<pre><code>-filter "unsharp=1x=13:ly=13"la=2.0"
</code></pre>

<p>Will unsharpening re-encode? Because my final video output is h.264 8/10bit I don't want to re-encode that.   </p>

<p>My question is where in my commands should I be applying the unsharp? And should I only apply it once or as many times throughout that it makes things look nice?</p>

<p>I thought for simplicity I would divide my commands up, but maybe they should be done as a single command? Will a single command lessen the number of re-encodes any?  </p>

<p>Step 1. Upscale:</p>

<pre><code>ffmpeg -i %d.exr -vf scale=3840:-1 C:\Users\Me\Desktop\Test\output_3840.exr
</code></pre>

<p>Step 2: Turn images into .avi (not sure if this works for avi, i kno it works for mkv tho)</p>

<pre><code>ffmpeg -framerate 500/21 -i %d.exr -c:v libx264 -crf 18 -pix_fmt yuv422p10le output.avi
</code></pre>

<p>Step 3: Unsharpen...but when/where?</p>

<pre><code>-filter "unsharp=1x=13:ly=13"la=2.0"
</code></pre>

<p>I'm not even sure how to combine these, or like I said if doing so will limit the re-encodes. Is there a single command I can/should be using here based on the 3 above? I'll just do the audio as a separate command with -c copy so it doesn't re-encode, it makes it less confusing for me.</p>

CC BY-SA 4.0
2018-11-27T03:26:31.847Z
Of course it will re-encode. You can't change the content without re-encoding. Stop fretting about the infinitesimal losses re-encoding is going to make, when the end result is an 8-bit h.264 file. It. Won't. Make. Any. Difference.
stib
CC BY-SA 4.0
2018-11-27T03:51:40.630Z
my base footage is h.264 though. so unfortunately i need to worry about it. and limit the total render to 1, and transcode and render the number of extra times necessary inbetween.
kite
CC BY-SA 4.0
2018-11-27T03:55:07.737Z
No, the compression has already happened. Once ffmpeg has decoded the footage that's as good as it's going to get. Adding the 16-bit png stage will not increase the quality of the input, it will in fact decrease it very very slightly due to quantisation loss. But mostly it will just be a PITA for no benefit.
stib
CC BY-SA 4.0
2018-11-27T03:58:06.373Z
Artifacts are the problem I'm trying to avoid. Re-encoding the fooage as h.264 it creates artifacts. Re-encoding twice creates a stupid amount of them and its very noticable, thus I need to keep of and limit the re-encodes and rely on trancode to higher bit numbers if necessary. The problem is my base footage is 8 bit.
kite
CC BY-SA 4.0
2018-11-27T04:06:06.120Z
But you don't need to re-encode twice. Upscale and filter in the one operation. Did you look at my answer?
stib
CC BY-SA 4.0
2018-11-27T23:26:38.363Z
"Yes I looked at your answer. Did you look at my question?" Comments like this are extremely aggressive. And you have made many such on this and my other post. You ignored my criteria as unimportant and gave an answer based on what you thought was important. There are reasons I asked the question the way I did. If you wish further communication please keep it specific to answering the question as posed.
kite
<ffmpeg>
Where/when should I specify unsharpen when converting images to video?
kite
# Where/when should I specify unsharpen when converting images to video?

(Asked by: username_0 on 2018-11-27)

Edit: its not liking it when I specify .exr as the output file....not sure if there's a fix to support exr in ffmpeg. Just pretends its .png then unless you can help with that as well
Hi so I transcoded a 30 min video into a 16 bit 1080p.exr image strip. I then plan on upscaling these images with ffmpeg to 4k. I then want to render it out again as an 8 bit h.264 .avi.
Somewhere here I want to apply sharpening to make the upscale a bit cleaner (this command looked nice when applied to the exr on their own):
-filter "unsharp=1x=13:ly=13"la=2.0"

Will unsharpening re-encode? Because my final video output is h.264 8/10bit I don't want to re-encode that.   
My question is where in my commands should I be applying the unsharp? And should I only apply it once or as many times throughout that it makes things look nice?
I thought for simplicity I would divide my commands up, but maybe they should be done as a single command? Will a single command lessen the number of re-encodes any?  
Step 1. Upscale:
ffmpeg -i %d.exr -vf scale=3840:-1 C:\Users\Me\Desktop\Test\output_3840.exr

Step 2: Turn images into .avi (not sure if this works for avi, i kno it works for mkv tho)
ffmpeg -framerate 500/21 -i %d.exr -c:v libx264 -crf 18 -pix_fmt yuv422p10le output.avi

Step 3: Unsharpen...but when/where?
-filter "unsharp=1x=13:ly=13"la=2.0"

I'm not even sure how to combine these, or like I said if doing so will limit the re-encodes. Is there a single command I can/should be using here based on the 3 above? I'll just do the audio as a separate command with -c copy so it doesn't re-encode, it makes it less confusing for me.

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Of course it will re-encode. You can't change the content without re-encoding. Stop fretting about the infinitesimal losses re-encoding is going to make, when the end result is an 8-bit h.264 file. It. Won't. Make. Any. Difference.  
> **username_0**: my base footage is h.264 though. so unfortunately i need to worry about it. and limit the total render to 1, and transcode and render the number of extra times necessary inbetween.  
> **username_1**: No, the compression has already happened. Once ffmpeg has decoded the footage that's as good as it's going to get. Adding the 16-bit png stage will not increase the quality of the input, it will in fact decrease it very very slightly due to quantisation loss. But mostly it will just be a PITA for no benefit.  
> **username_0**: Artifacts are the problem I'm trying to avoid. Re-encoding the fooage as h.264 it creates artifacts. Re-encoding twice creates a stupid amount of them and its very noticable, thus I need to keep of and limit the re-encodes and rely on trancode to higher bit numbers if necessary. The problem is my base footage is 8 bit.  
> **username_1**: But you don't need to re-encode twice. Upscale and filter in the one operation. Did you look at my answer?  
> **username_0**: "Yes I looked at your answer. Did you look at my question?" Comments like this are extremely aggressive. And you have made many such on this and my other post. You ignored my criteria as unimportant and gave an answer based on what you thought was important. There are reasons I asked the question the way I did. If you wish further communication please keep it specific to answering the question as posed.  

---

## 1 answers

### Answer by username_1 on 2018-11-27. Score: 1

Just do it all as one step and forget about up-sampling to 16 bit. That just adds complexity, processing time, extra storage and for no gain in quality in the end result that anyone could possibly perceive. 
fmpeg myinputVideo.avi -vf "scale=3840:2160,unsharp=1x=13:ly=13"la=2.0" myoutput.mp4

The internal process of ffmpeg works basically like this: 
 _______              ______________
|       |            |              |
| input |  demuxer   | encoded data |   decoder
| file  | ---------> | packets      | -----+
|_______|            |______________|      |
                                           v
                                       _________
                                      |         |
                                      | decoded |
                                      | frames  |
                                      |_________|
 ________             ______________       |
|        |           |              |      |
| output | <-------- | encoded data | <----+
| file   |   muxer   | packets      |   encoder
|________|           |______________|

The "decoded frames" box basically is where the pixels in the image are stored in memory as uncompressed RGB or YUV (or whatever) samples. That's the point where your footage is as good as it is going to get. Any extra filtering or processing will notionally degrade the image due to quantisation loss, or compression etc.. That image is what is sent to the filter chain. What you're doing is:
demux → decode → [decoded frames] → resample → encode → mux → save → 
demux → decode → [decoded, resampled frames] → upscale → sharpen → encode → mux → save

so you're applying your filters to frames that have had an extra resample and encode step added, not to mention taking up a whole bunch'a space on your HDD.
When you filter something the output of one filter goes to the input of the next filter in the chain, so if you put scale first the scaled image is then sent to the sharpen filter. 
 _______        ________        _________        ________
|       |      |        |      |         |      |        |
| input | ---> | scale  | ---> | sharpen | ---> | output |
|_______|      |________|      |_________|      |________|

You can get more complex by using -filter_complex which allows you to have various inputs and outputs for filters.
https://ffmpeg.org/ffmpeg.html#Filtering for more ascii-art empowered knowledge

> **Comments:**
> **username_2**: Is `"scale=3840:2160,unsharp=1x=13:ly=13"la=2.0"` a valid syntax? Should not theree be something else instead of double quote in the `13"la`? Upd. judgung by the [docs](https://ffmpeg.org/ffmpeg-filters.html#toc-unsharp-1) it should be `:` instead of `"` - `"scale=3840:2160,unsharp=1x=13:ly=13:la=2.0"`  

---

