Opened 12 years ago

Closed 12 years ago

#2165 closed defect (fixed)

h264 lossless encoding, decoding does not produce same video content

Reported by: silviob Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: libx264 regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Encoding a UYVY avi file
lossless_h264_encoding.avi
using lossless encoding (libx264) and then decoding it back to an avi file
lossless_h264_encoding_check.avi
then the resulting video is different from the original one.

Sample files are on upload.ffmpeg.org.

I am using a recent windows binary (ffmpeg-20130115-git-5ce023b-win64-static), and the following command lines:

<..>\ffmpeg-20130115-git-5ce023b-win64-static\bin\ffmpeg.exe  -v 9 -loglevel 99  -i lossless_h264_encoding.avi -c:v libx264 -profile:v high444 -crf 0 lossless_h264_encoding.h264

<..>\ffmpeg-20130115-git-5ce023b-win64-static\bin\ffmpeg.exe  -v 9 -loglevel 99  -i lossless_h264_encoding.h264 -f avi -pix_fmt uyvy422 -vcodec rawvideo lossless_h264_encoding_check.avi

Following are the command lines used including output:

<..>\ffmpeg-20130115-git-5ce023b-win64-static\bin\ffmpeg.exe  -v 9 -loglevel 99  -i lossless_h264_encoding.avi -c:v libx264 -profile:v high444 -crf 0 lossless_h264_encoding.h264


ffmpeg version N-48886-g5ce023b Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 14 2013 19:21:37 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib --enable-filter=frei0r
  libavutil      52. 14.100 / 52. 14.100
  libavcodec     54. 89.100 / 54. 89.100
  libavformat    54. 59.107 / 54. 59.107
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set libav* logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set libav* logging level) with argument '99'.
Reading option '-i' ... matched as input file with argument 'lossless_h264_encoding.avi'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'libx264'.
Reading option '-profile:v' ... matched as option 'profile' (set profile) with argument 'high444'.
Reading option '-crf' ... matched as AVOption 'crf' with argument '0'.
Reading option 'lossless_h264_encoding.h264' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set libav* logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file lossless_h264_encoding.avi.
Successfully parsed a group of options.
Opening an input file: lossless_h264_encoding.avi.
[avi @ 000000000032baa0] Format avi probed with size=2048 and score=100
[avi @ 0000000000340ea0] use odml:1
[avi @ 000000000032baa0] File position before avformat_find_stream_info() is 8204
[avi @ 000000000032baa0] parser not found for codec rawvideo, packets or times may be invalid.
    Last message repeated 1 times
[avi @ 000000000032baa0] All info found
[avi @ 000000000032baa0] File position after avformat_find_stream_info() is 622612
Input #0, avi, from 'lossless_h264_encoding.avi':
  Duration: 00:00:00.07, start: 0.000000, bitrate: 148446 kb/s
    Stream #0:0, 1, 1/30: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, 1/30, 30 tbr, 30 tbn, 30 tbc
Successfully openened the file.
Parsing a group of options: output file lossless_h264_encoding.h264.
Applying option c:v (codec name) with argument libx264.
Applying option profile:v (set profile) with argument high444.
Successfully parsed a group of options.
Opening an output file: lossless_h264_encoding.h264.
Successfully openened the file.
[buffer @ 0000000000329e00] Setting entry with key 'video_size' to value '640x480'
[buffer @ 0000000000329e00] Setting entry with key 'pix_fmt' to value '17'
[buffer @ 0000000000329e00] Setting entry with key 'time_base' to value '1/30'
[buffer @ 0000000000329e00] Setting entry with key 'pixel_aspect' to value '0/1'
[buffer @ 0000000000329e00] Setting entry with key 'sws_param' to value 'flags=2'
[buffer @ 0000000000329e00] Setting entry with key 'frame_rate' to value '30/1'
[graph 0 input from stream 0:0 @ 0000000000341280] w:640 h:480 pixfmt:uyvy422 tb:1/30 fr:30/1 sar:0/1 sws_param:flags=2
[scale @ 000000000032a120] Setting 'w' to value '0'
[scale @ 000000000032a120] Setting 'h' to value '0'
[scale @ 000000000032a120] Setting 'flags' to value '0x4'
[auto-inserted scaler 0 @ 00000000003410e0] w:0 h:0 flags:'0x4' interl:0
[format @ 0000000000341200] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[auto-inserted scaler 0 @ 00000000003410e0] picking yuv422p out of 4 ref:uyvy422 alpha:0
[auto-inserted scaler 0 @ 00000000003410e0] w:640 h:480 fmt:uyvy422 sar:0/1 -> w:640 h:480 fmt:yuv422p sar:0/1 flags:0x4
[libx264 @ 0000000000328540] using mv_range_thread = 24
[libx264 @ 0000000000328540] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0000000000328540] profile High 4:4:4 Predictive, level 3.0, 4:2:2 8-bit
Output #0, h264, to 'lossless_h264_encoding.h264':
  Metadata:
    encoder         : Lavf54.59.107
    Stream #0:0, 0, 1/90000: Video: h264, yuv422p, 640x480, 1/30, q=-1--1, 90k tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
[libx264 @ 0000000000328540] using mv_range_thread = 24
[output stream 0:0 @ 0000000000341160] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
[libx264 @ 0000000000328540] frame=   0 QP=0.00 NAL=3 Slice:I Poc:0   I:1200 P:0    SKIP:0    size=169429 bytes
[libx264 @ 0000000000328540] frame=   1 QP=0.00 NAL=2 Slice:P Poc:2   I:848  P:345  SKIP:7    size=162549 bytes
frame=    2 fps=0.0 q=-1.0 Lsize=     324kB time=00:00:00.06 bitrate=39837.2kbits/s
video:324kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.000000%
[libx264 @ 0000000000328540] frame I:1     Avg QP: 0.00  size:169429
[libx264 @ 0000000000328540] frame P:1     Avg QP: 0.00  size:162549
[libx264 @ 0000000000328540] mb I  I16..4: 14.8% 10.3% 74.9%
[libx264 @ 0000000000328540] mb P  I16..4:  7.8% 31.4% 31.5%  P16..4: 11.9%  9.4%  7.4%  0.0%  0.0%    skip: 0.6%
[libx264 @ 0000000000328540] 8x8 transform intra:24.4% inter:78.3%
[libx264 @ 0000000000328540] coded y,uvDC,uvAC intra: 98.0% 99.2% 99.1% inter: 96.6% 97.4% 97.2%
[libx264 @ 0000000000328540] i16 v,h,dc,p: 39% 59%  2%  0%
[libx264 @ 0000000000328540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 67%  0%  0%  1%  0%  0%  0%  0%
[libx264 @ 0000000000328540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 46%  3%  2%  5%  3%  4%  2%  2%
[libx264 @ 0000000000328540] i8c dc,h,v,p:  3% 47% 51%  0%
[libx264 @ 0000000000328540] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000000328540] kb/s:39837.36
[AVIOContext @ 00000000023993a0] Statistics: 1294464 bytes read, 4 seeks



<..>\ffmpeg-20130115-git-5ce023b-win64-static\bin\ffmpeg.exe  -v 9 -loglevel 99  -i lossless_h264_encoding.h264 -f avi -pix_fmt uyvy422 -vcodec rawvideo lossless_h264_encoding_check.avi


ffmpeg version N-48886-g5ce023b Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 14 2013 19:21:37 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib --enable-filter=frei0r
  libavutil      52. 14.100 / 52. 14.100
  libavcodec     54. 89.100 / 54. 89.100
  libavformat    54. 59.107 / 54. 59.107
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set libav* logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set libav* logging level) with argument '99'.
Reading option '-i' ... matched as input file with argument 'lossless_h264_encoding.h264'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'avi'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'uyvy422'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'rawvideo'.
Reading option 'lossless_h264_encoding_check.avi' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set libav* logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file lossless_h264_encoding.h264.
Successfully parsed a group of options.
Opening an input file: lossless_h264_encoding.h264.
[h264 @ 000000000204e620] Format h264 probed with size=2048 and score=51
[h264 @ 000000000204e620] File position before avformat_find_stream_info() is 0
[h264 @ 000000000204e620] decoding for stream 0 failed
[h264 @ 000000000204e620] Estimating duration from bitrate, this may be inaccurate
[h264 @ 000000000204e620] File position after avformat_find_stream_info() is 331978
Input #0, h264, from 'lossless_h264_encoding.h264':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 2, 1/1200000: Video: h264 (High 4:4:4 Predictive), yuv422p, 640x480, 1/60, 30 tbr, 1200k tbn, 60 tbc
Successfully openened the file.
Parsing a group of options: output file lossless_h264_encoding_check.avi.
Applying option f (force format) with argument avi.
Applying option pix_fmt (set pixel format) with argument uyvy422.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument rawvideo.
Successfully parsed a group of options.
Opening an output file: lossless_h264_encoding_check.avi.
Successfully openened the file.
[buffer @ 00000000020b92e0] Setting entry with key 'video_size' to value '640x480'
[buffer @ 00000000020b92e0] Setting entry with key 'pix_fmt' to value '4'
[buffer @ 00000000020b92e0] Setting entry with key 'time_base' to value '1/1200000'
[buffer @ 00000000020b92e0] Setting entry with key 'pixel_aspect' to value '0/1'
[buffer @ 00000000020b92e0] Setting entry with key 'sws_param' to value 'flags=2'
[buffer @ 00000000020b92e0] Setting entry with key 'frame_rate' to value '60/2'
[graph 0 input from stream 0:0 @ 00000000020d0dc0] w:640 h:480 pixfmt:yuv422p tb:1/1200000 fr:30/1 sar:0/1 sws_param:flags=2
[scale @ 00000000020b8fc0] Setting 'w' to value '0'
[scale @ 00000000020b8fc0] Setting 'h' to value '0'
[scale @ 00000000020b8fc0] Setting 'flags' to value '0x4'
[auto-inserted scaler 0 @ 00000000020d0b80] w:0 h:0 flags:'0x4' interl:0
[format @ 00000000020d0ca0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[auto-inserted scaler 0 @ 00000000020d0b80] w:640 h:480 fmt:yuv422p sar:0/1 -> w:640 h:480 fmt:uyvy422 sar:0/1 flags:0x4
[h264 @ 000000000204b140] detected 8 logical cores
Output #0, avi, to 'lossless_h264_encoding_check.avi':
  Metadata:
    ISFT            : Lavf54.59.107
    Stream #0:0, 0, 1/30: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, 1/30, q=2-31, 200 kb/s, 30 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> rawvideo)
Press [q] to stop, [?] for help
[h264 @ 0000000004650b60] Using externally provided dimensions
[output stream 0:0 @ 00000000020d0d20] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
frame=    2 fps=0.0 q=0.0 Lsize=    1206kB time=00:00:00.06 bitrate=148142.9kbits/s
video:1200kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.466309%
[AVIOContext @ 000000000204bd40] Statistics: 331978 bytes read, 0 seeks

Attachments (1)

lossless_h264_encoding.avi (1.2 MB ) - added by Carl Eugen Hoyos 12 years ago.

Download all attachments as: .zip

Change History (5)

by Carl Eugen Hoyos, 12 years ago

Attachment: lossless_h264_encoding.avi added

comment:1 by Carl Eugen Hoyos, 12 years ago

On my Linux work-station with x264 0.128.x the following works as expected:

$ ffmpeg -i lossless_h264_encoding.avi -crf 0 out.h264 -f framecrc -
ffmpeg version N-49127-ge4eebc2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 21 2013 23:43:50 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack --enable-libx264
  libavutil      52. 15.100 / 52. 15.100
  libavcodec     54. 90.100 / 54. 90.100
  libavformat    54. 61.102 / 54. 61.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 33.100 /  3. 33.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, avi, from 'lossless_h264_encoding.avi':
  Duration: 00:00:00.07, start: 0.000000, bitrate: 148446 kb/s
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, 30 tbr, 30 tbn, 30 tbc
[libx264 @ 0x18094e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x18094e0] profile High 4:4:4 Predictive, level 3.0, 4:2:2 8-bit
#tb 0: 1/30
Output #0, h264, to 'out.h264':
  Metadata:
    encoder         : Lavf54.61.102
    Stream #0:0: Video: h264, yuv422p, 640x480, q=-1--1, 90k tbn, 30 tbc
Output #1, framecrc, to 'pipe:':
  Metadata:
    encoder         : Lavf54.61.102
    Stream #1:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, q=2-31, 200 kb/s, 30 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
  Stream #0:0 -> #1:0 (rawvideo -> rawvideo)
Press [q] to stop, [?] for help
0,          0,          0,        1,   614400, 0x319cc48e
0,          1,          1,        1,   614400, 0xec4c279f
frame=    2 fps=0.0 q=-1.0 Lq=0.0 size=     324kB time=00:00:00.06 bitrate=39835.1kbits/s  
video:1524kB audio:0kB subtitle:0 global headers:0kB muxing overhead -78.730824%
[libx264 @ 0x18094e0] frame I:1     Avg QP: 0.00  size:169414
[libx264 @ 0x18094e0] frame P:1     Avg QP: 0.00  size:162547
[libx264 @ 0x18094e0] mb I  I16..4: 14.8% 10.2% 74.9%
[libx264 @ 0x18094e0] mb P  I16..4:  6.8% 31.7% 32.4%  P16..4: 11.8%  9.5%  7.5%  0.0%  0.0%    skip: 0.2%
[libx264 @ 0x18094e0] 8x8 transform intra:24.5% inter:78.7%
[libx264 @ 0x18094e0] coded y,uvDC,uvAC intra: 97.9% 99.1% 99.0% inter: 97.0% 98.9% 98.3%
[libx264 @ 0x18094e0] i16 v,h,dc,p: 41% 57%  2%  0%
[libx264 @ 0x18094e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 67%  1%  0%  1%  0%  0%  0%  0%
[libx264 @ 0x18094e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 47%  3%  2%  5%  3%  4%  2%  2%
[libx264 @ 0x18094e0] i8c dc,h,v,p:  3% 46% 51%  0%
[libx264 @ 0x18094e0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x18094e0] kb/s:39835.32
$ ffmpeg -i out.h264 -pix_fmt uyvy422 -f framecrc -
ffmpeg version N-49127-ge4eebc2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 21 2013 23:43:50 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack --enable-libx264
  libavutil      52. 15.100 / 52. 15.100
  libavcodec     54. 90.100 / 54. 90.100
  libavformat    54. 61.102 / 54. 61.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 33.100 /  3. 33.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[h264 @ 0x269df80] decoding for stream 0 failed
[h264 @ 0x269df80] Estimating duration from bitrate, this may be inaccurate
Input #0, h264, from 'out.h264':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv422p, 640x480, 30 tbr, 1200k tbn, 60 tbc
#tb 0: 1/30
Output #0, framecrc, to 'pipe:':
  Metadata:
    encoder         : Lavf54.61.102
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, q=2-31, 200 kb/s, 30 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> rawvideo)
Press [q] to stop, [?] for help
0,          0,          0,        1,   614400, 0x319cc48e
0,          1,          1,        1,   614400, 0xec4c279f
frame=    2 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.06 bitrate=  15.4kbits/s
video:1200kB audio:0kB subtitle:0 global headers:0kB muxing overhead -99.989583%

If I encode the original avi file with a Zeranoe build on Windows (same version e4eebc2 as above, no difference between 32 and 64bit), the output file is different / shows the exact same problem as the file silviob uploaded:

$ ffmpeg -i outwindows.h264 -pix_fmt uyvy422 -f framecrc -
ffmpeg version N-49127-ge4eebc2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 21 2013 23:43:50 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack --enable-libx264
  libavutil      52. 15.100 / 52. 15.100
  libavcodec     54. 90.100 / 54. 90.100
  libavformat    54. 61.102 / 54. 61.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 33.100 /  3. 33.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[h264 @ 0x16a6f80] decoding for stream 0 failed
[h264 @ 0x16a6f80] Estimating duration from bitrate, this may be inaccurate
Input #0, h264, from 'outwindows.h264':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv422p, 640x480, 30 tbr, 1200k tbn, 60 tbc
#tb 0: 1/30
Output #0, framecrc, to 'pipe:':
  Metadata:
    encoder         : Lavf54.61.102
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, q=2-31, 200 kb/s, 30 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> rawvideo)
Press [q] to stop, [?] for help
0,          0,          0,        1,   614400, 0x319cc48e
0,          1,          1,        1,   614400, 0x92ee27a2
frame=    2 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.06 bitrate=  15.4kbits/s
video:1200kB audio:0kB subtitle:0 global headers:0kB muxing overhead -99.989583%
Last edited 12 years ago by Carl Eugen Hoyos (previous) (diff)

comment:2 by Carl Eugen Hoyos, 12 years ago

Keywords: libx264 added; h264 lossless removed

comment:3 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedavcodec
Keywords: regression added
Priority: normalimportant
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

This is (at least with mingw32) a regression since this x264 commit:
http://git.videolan.org/?p=x264.git;a=commitdiff;h=4dbfcd4

Version 0, edited 12 years ago by Carl Eugen Hoyos (next)

comment:4 by Carl Eugen Hoyos, 12 years ago

Resolution: fixed
Status: openclosed

Should be fixed, thank you for the report!

Note: See TracTickets for help on using tickets.