Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#993 closed defect (fixed)

ffmpeg / ffplay fails to correctly decode interlaced h264 (MTS container) when using default number of threads

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

Description

ffplay shows flickering block artifacts when decoding interlaced h264 video from a MTS file. When transcoding to h264/MP4 using ffmpeg similar artifacts appear. In the latter case, the number of artifacts depends on the encoding preset used. -preset ultrafast creates many while -preset medium much less.

  • As a workaround adding -threads 1 to the command line seems to fix this.

Platform used for testing:

  • Ubuntu 11.10
  • Linux 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
  • CPU: Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz

ffprobe output:

ffprobe -loglevel 99 00001.MTS 
ffprobe version git-2012-02-10-394d41e Copyright (c) 2007-2012 the FFmpeg developers
  built on Feb 11 2012 00:00:48 with gcc 4.6.1
  configuration: --prefix=/home/ls/ffmpeg-trunk --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-sram --cpu=core2 --enable-hwaccel=h264_vaapi --enable-hwaccel=mpeg2_vaapi --enable-hwaccel=mpeg4_vaapi --enable-libfaac --enable-x11grab --disable-ffserver --enable-libass --enable-libfreetype
  libavutil      51. 39.100 / 51. 39.100
  libavcodec     54.  1.100 / 54.  1.100
  libavformat    54.  0.100 / 54.  0.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 62.100 /  2. 62.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[mpegts @ 0x1b424e0] Format mpegts probed with size=2048 and score=100
[mpegts @ 0x1b424e0] stream=0 stream_type=1b pid=1011 prog_reg_desc=HDMV
[mpegts @ 0x1b424e0] stream=1 stream_type=81 pid=1100 prog_reg_desc=HDMV
[mpegts @ 0x1b424e0] stream=2 stream_type=90 pid=1200 prog_reg_desc=HDMV
[mpegts @ 0x1b424e0] parser not found for codec hdmv_pgs_subtitle, packets or times may be invalid.
[h264 @ 0x1b463e0] no picture 
[mpegts @ 0x1b424e0] Probe buffer size limit 5000000 reached
Input #0, mpegts, from '00001.MTS':
  Duration: 00:03:01.51, start: 1.000033, bitrate: 17122 kb/s
  Program 1 
    Stream #0:0[0x1011], 125, 1/90000: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1/50, 50 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1100], 71, 1/90000: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 256 kb/s
    Stream #0:2[0x1200], 25, 1/90000: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
[h264 @ 0x1b463e0] detected 4 logical cores

Command that produces artifacts when playing:

~/ffmpeg-trunk/bin/ffplay 00001.MTS

Workaround:

~/ffmpeg-trunk/bin/ffplay -threads 1 00001.MTS

Command that produces artifacts when transcoding:

~/ffmpeg-trunk/bin/ffmpeg -i '00001.MTS' -async 1 -codec:v libx264 -preset ultrafast -crf 20 -codec:a libfaac -ab 256k '00001.mp4'

Workaround:

~/ffmpeg-trunk/bin/ffmpeg -threads 1 -i '00001.MTS' -async 1 -codec:v libx264 -preset ultrafast -crf 20 -codec:a libfaac -ab 256k '00001.mp4'

Attachments (1)

blockartifacts.png (553.2 KB ) - added by ls 13 years ago.
ffplay screenshot with artifacts

Download all attachments as: .zip

Change History (8)

comment:1 by Carl Eugen Hoyos, 13 years ago

Component: FFplayundetermined

Please provide a sample and please provide complete, uncut console output for the failing ffmpeg command line (together with the command line).

comment:2 by ls, 13 years ago

The full ffmpeg output is below. I will provide a sample within the next days. My current sample cannot be uploaded due to privacy (participants of an experiment).

~/ffmpeg-trunk/bin/ffmpeg -i '00001.MTS' -async 1  -codec:v libx264 -preset ultrafast -crf 20 -codec:a libfaac -ab 256k '00001.mp4'
ffmpeg version git-2012-02-10-394d41e Copyright (c) 2000-2012 the FFmpeg developers
  built on Feb 11 2012 00:00:48 with gcc 4.6.1
  configuration: --prefix=/home/ls/ffmpeg-trunk --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-sram --cpu=core2 --enable-hwaccel=h264_vaapi --enable-hwaccel=mpeg2_vaapi --enable-hwaccel=mpeg4_vaapi --enable-libfaac --enable-x11grab --disable-ffserver --enable-libass --enable-libfreetype
  libavutil      51. 39.100 / 51. 39.100
  libavcodec     54.  1.100 / 54.  1.100
  libavformat    54.  0.100 / 54.  0.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 62.100 /  2. 62.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mpegts, from '00001.MTS':
  Duration: 00:03:01.51, start: 1.000033, bitrate: 17122 kb/s
  Program 1 
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 256 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
File '00001.mp4' already exists. Overwrite ? [y/N] y
w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
[libx264 @ 0x146eb20] using SAR=1/1
[libx264 @ 0x146eb20] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x146eb20] profile Constrained Baseline, level 4.2
[libx264 @ 0x146eb20] 264 - core 120 r0+2 a3f4407 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to '00001.mp4':
  Metadata:
    encoder         : Lavf54.0.100
    Stream #0:0: Video: h264 (![0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 50 tbn, 50 tbc
    Stream #0:1: Audio: aac (@[0][0][0] / 0x0040), 48000 Hz, stereo, s16, 256 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (ac3 -> libfaac)
Press [q] to stop, [?] for help
frame= 1579 fps= 62 q=-1.0 Lsize=   59700kB time=00:00:31.08 bitrate=15734.1kbits/s dup=790 drop=0    
video:59046kB audio:627kB global headers:0kB muxing overhead 0.044877%
[libx264 @ 0x146eb20] frame I:7     Avg QP:17.43  size:254007
[libx264 @ 0x146eb20] frame P:1572  Avg QP:20.39  size: 37331
[libx264 @ 0x146eb20] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x146eb20] mb P  I16..4:  8.1%  0.0%  0.0%  P16..4: 26.0%  0.0%  0.0%  0.0%  0.0%    skip:65.9%
[libx264 @ 0x146eb20] coded y,uvDC,uvAC intra: 43.3% 45.6% 12.0% inter: 14.9% 12.1% 0.4%
[libx264 @ 0x146eb20] i16 v,h,dc,p: 36% 24% 26% 14%
[libx264 @ 0x146eb20] i8c dc,h,v,p: 49% 20% 26%  5%
[libx264 @ 0x146eb20] kb/s:15316.61
Version 0, edited 13 years ago by ls (next)

comment:3 by Carl Eugen Hoyos, 13 years ago

Resolution: needs_more_info
Status: newclosed

Please reopen if this problem can be made reproducible.

by ls, 13 years ago

Attachment: blockartifacts.png added

ffplay screenshot with artifacts

comment:4 by ls, 13 years ago

Resolution: needs_more_info
Status: closedreopened

I did a bit more testing and this problem can be reproduced with other interlaced h264 MTS that is available on the web:
Old Kdeenlive forum post

I have attached a screenshot of the artifacts created using the video from here:
http://file.meyersproduction.com/hg10/00009.MTS.zip

Using default threading (-threads 0) only few artifacts show up in this sample. Using -threads 4 produces worse results:

ffplay -threads 4 00009.MTS

Transcoding with ffmpeg creates the same artifacts as described in the initial post.

comment:5 by Carl Eugen Hoyos, 13 years ago

Component: undeterminedavcodec
Keywords: h264 regression added
Priority: normalimportant
Reproduced by developer: set
Status: reopenedopen

comment:6 by Carl Eugen Hoyos, 13 years ago

Resolution: fixed
Status: openclosed

Fixed by Michael.

comment:7 by ls, 13 years ago

Great, thanks for the fast fix! Confirmed for all my test files.

Note: See TracTickets for help on using tickets.