<p>To directly compare the YUV422P AVI and YUV420P MP4,</p>

<pre><code>ffmpeg -i input.avi -i out.mp4
   -filter_complex
      "[0]format=yuv420p,split[avi-p][avi-s];
       [1][avi-p]psnr;[1][avi-s]ssim" -f null -
</code></pre>

CC BY-SA 3.0
2017-06-01T02:11:25.197Z
It gives an average value on the terminal, how can we output a log file with values of each frame?  I tried `-lavfi psnr="stats_file=psnr.log"` but no luck.
shintaroid
CC BY-SA 3.0
2017-05-31T07:34:31.603Z
2017-05-31T07:34:31.603Z
Gyan
<p>I have an AVI file <code>input.avi</code> encoded in <code>HQ</code> which has <code>yuv422</code> format according to <code>ffprobe</code>.</p>

<p>Now, if I run the following command</p>

<pre><code>ffmpeg -i input.avi -c:v libx264 -crf 0 -pix_fmt yuv420p out.mp4
</code></pre>

<p>Will the <code>out.mp4</code> be lossless compared with <code>input.avi</code>? or it will be 'lossless' except half of the <code>U</code> and <code>V</code> information is lost?</p>

CC BY-SA 3.0
2017-05-31T01:28:38.093Z
No. Yes. You pretty much answered your own question in the last line.
stib
CC BY-SA 3.0
2017-05-31T01:29:34.563Z
BTW you can encode h.264 in yuv422, but not all players will play it
stib
CC BY-SA 3.0
2017-05-31T01:37:26.457Z
@stib Thanks! I want to calculate the PSNR and SSIM between `input.avi` and an encoded mp4 file. But the yuv format is different, so I am encoding the `input.avi` to 'lossless' yuv420p mp4, then calculate the PSNR and SSIM.
shintaroid
CC BY-SA 3.0
2017-05-31T04:55:58.400Z
Just look at the SSIM score for the luma plane. U and V are not relevant in this case. Or you could downsample the AVI to 4:2:0 before passing it to the quality compare filters i.e. `[1]format=yuv420p[a];[0][a]psnr..`
Gyan
CC BY-SA 3.0
2017-05-31T07:14:29.730Z
@Mulvya Thanks! Would you please give a full command sample? I am new to `ffmpeg`, I am not sure how to add `[1]format=yuv420p[a];[0][a]psnr..` to my command
shintaroid
<ffmpeg><libx264>
What does it mean when encode a yuv422 file to yuv420 by libx264 lossless encoding?
shintaroid
# What does it mean when encode a yuv422 file to yuv420 by libx264 lossless encoding?

(Asked by: username_0 on 2017-05-30)

I have an AVI file input.avi encoded in HQ which has yuv422 format according to ffprobe.
Now, if I run the following command
ffmpeg -i input.avi -c:v libx264 -crf 0 -pix_fmt yuv420p out.mp4

Will the out.mp4 be lossless compared with input.avi? or it will be 'lossless' except half of the U and V information is lost?

**Tags:** ffmpeg, libx264

> **Comments:**
> **username_1**: No. Yes. You pretty much answered your own question in the last line.  
> **username_1**: BTW you can encode h.264 in yuv422, but not all players will play it  
> **username_0**: @username_1 Thanks! I want to calculate the PSNR and SSIM between `input.avi` and an encoded mp4 file. But the yuv format is different, so I am encoding the `input.avi` to 'lossless' yuv420p mp4, then calculate the PSNR and SSIM.  
> **username_2**: Just look at the SSIM score for the luma plane. U and V are not relevant in this case. Or you could downsample the AVI to 4:2:0 before passing it to the quality compare filters i.e. `[1]format=yuv420p[a];[0][a]psnr..`  
> **username_0**: @Mulvya Thanks! Would you please give a full command sample? I am new to `ffmpeg`, I am not sure how to add `[1]format=yuv420p[a];[0][a]psnr..` to my command  

---

## 1 answers

### Answer by username_2 on 2017-05-31. Score: 1 | Accepted answer

To directly compare the YUV422P AVI and YUV420P MP4,
ffmpeg -i input.avi -i out.mp4
   -filter_complex
      "[0]format=yuv420p,split[avi-p][avi-s];
       [1][avi-p]psnr;[1][avi-s]ssim" -f null -

> **Comments:**
> **username_0**: It gives an average value on the terminal, how can we output a log file with values of each frame?  I tried `-lavfi psnr="stats_file=psnr.log"` but no luck.  

---

