<p>Just do this:</p>
<pre><code>ffmpeg -i $input -i $output -lavfi ssim -f null -
</code></pre>
<p>This will compare the two videos using SSIM. If it's lossless then you will see:</p>
<pre><code>SSIM Y:1.000000 (inf) U:1.000000 (inf) V:1.000000 (inf) All:1.000000 (inf)
</code></pre>
<p>You don't need both <code>-qp 0</code> and <code>-crf 0</code> btw. The latter is lossless if the input is 8-bit. The former always is. Also you don't need to set a profile manually. FFmpeg will pick the right profile for you.</p>

CC BY-SA 4.0
2024-05-05T04:55:36.793Z
2024-05-05T04:55:36.793Z
veppy
<p>i've transcoded an interlaced JPEG2000 video file to H.264 using ffmpeg.  following <a href="https://trac.ffmpeg.org/wiki/Encode/H.264" rel="nofollow noreferrer">the guidelines</a>, i constructed the following command line:</p>
<pre><code>ffmpeg -hide_banner -i $input \
        -vf tinterlace=0 \
        -c:v libx264 -crf 0 -qp 0 -preset veryslow \
        -x264-params interlaced=1 -flags +ildct+ilme \
        -profile:v high444 \
        -map 0 -c:a aac -c:d copy -c:s copy -c:t copy -y $output
</code></pre>
<p>here is part of the mediainfo report of the resulting video (non-video tracks excluded for brevity):</p>
<pre><code>General
Complete name                            : output.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 263 MiB
Duration                                 : 1 min 0 s
Overall bit rate                         : 36.8 Mb/s
Writing application                      : Lavf60.3.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High 4:2:2@L4
Format settings                          : CABAC / 16 Ref Frames
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 16 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1 min 0 s
Bit rate                                 : 36.5 Mb/s
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Bit depth                                : 10 bits
Scan type                                : MBAFF
Scan type, store method                  : Interleaved fields
Scan order                               : Top Field First
Bits/(Pixel*Frame)                       : 3.523
Stream size                              : 261 MiB (99%)
Writing library                          : x264 core 164 r3106 eaa68fa
Encoding settings                        : cabac=1 / ref=16 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=18 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=tff / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=0 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=0.0 / qcomp=0.60 / qpmin=0 / qpmax=81 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Color range                              : Full
</code></pre>
<p>my question is: is there a way to tell if the resulting output file truly is lossless?  (there is no output line that says 'lossless' in the ffmpeg output nor in the mediainfo report on the file.)</p>
<p>[NB - even though it might not be common modern practice to create interlaced video, the output video needs to preserve interlacing because it's part of The Requirements®.]</p>

<ffmpeg><h.264><transcoding>
verify lossless in H.264
david furst
# verify lossless in H.264

(Asked by: username_0 on 2023-11-02)

i've transcoded an interlaced JPEG2000 video file to H.264 using ffmpeg.  following the guidelines, i constructed the following command line:
ffmpeg -hide_banner -i $input \
        -vf tinterlace=0 \
        -c:v libx264 -crf 0 -qp 0 -preset veryslow \
        -x264-params interlaced=1 -flags +ildct+ilme \
        -profile:v high444 \
        -map 0 -c:a aac -c:d copy -c:s copy -c:t copy -y $output

here is part of the mediainfo report of the resulting video (non-video tracks excluded for brevity):
General
Complete name                            : output.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 263 MiB
Duration                                 : 1 min 0 s
Overall bit rate                         : 36.8 Mb/s
Writing application                      : Lavf60.3.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High 4:2:2@L4
Format settings                          : CABAC / 16 Ref Frames
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 16 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1 min 0 s
Bit rate                                 : 36.5 Mb/s
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Bit depth                                : 10 bits
Scan type                                : MBAFF
Scan type, store method                  : Interleaved fields
Scan order                               : Top Field First
Bits/(Pixel*Frame)                       : 3.523
Stream size                              : 261 MiB (99%)
Writing library                          : x264 core 164 r3106 eaa68fa
Encoding settings                        : cabac=1 / ref=16 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=18 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=tff / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=0 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=0.0 / qcomp=0.60 / qpmin=0 / qpmax=81 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Color range                              : Full

my question is: is there a way to tell if the resulting output file truly is lossless?  (there is no output line that says 'lossless' in the ffmpeg output nor in the mediainfo report on the file.)
[NB - even though it might not be common modern practice to create interlaced video, the output video needs to preserve interlacing because it's part of The Requirements®.]

**Tags:** ffmpeg, h.264, transcoding


---

## 1 answers

### Answer by username_1 on 2024-05-05. Score: 1

Just do this:
ffmpeg -i $input -i $output -lavfi ssim -f null -

This will compare the two videos using SSIM. If it's lossless then you will see:
SSIM Y:1.000000 (inf) U:1.000000 (inf) V:1.000000 (inf) All:1.000000 (inf)

You don't need both -qp 0 and -crf 0 btw. The latter is lossless if the input is 8-bit. The former always is. Also you don't need to set a profile manually. FFmpeg will pick the right profile for you.


---

