Showing results for 
Search instead for 
Did you mean: 

QSV encode hangs early in transcode process

This has also been crossposted at the FFMPEG forum as it's not clear whether this is an Intel issue or an FFMPEG issue.



Environment: cygwin/Windows10
CPU: Core i7-5600U
FFMPEG Build: using the Nov 10 2016 snapshot build from Zeranoe: ffmpeg version N-82324-g872b358 
Intel SDK build: (aka "Media SDK 2016 R2")

Problem description: when transcoding an MP4 file using the h264_qsv encoder, the encode process *sometimes* hangs and never completes. Specifically:
- the ffmpeg-generated progress indicator stops incrementing, generally between one and four seconds into the encode. 
- Windows reports 100% utilization on the CPU core where the ffmpeg.exe process is running. 
- I left the process running for over an hour at one point to (almost) guarantee that it wasn't just some strange performance issue - it never completes.
- Process manager reports zero increment of read or write bytes from that process, implying to me there's an infinite loop somewhere.
- The issue is reproduceable, but is NOT guaranteed to occur on every encode. I'd estimate that roughly 1/3 of the time the encode hangs, and the rest of the time it completes successfully.
- I've attempted to vary settings to try and correlate the failure/hang with particular configs/parameters but have not been able to isolate anything. I've specifically used different input files from both Sony and GoPro sources (all I have available), different ratecontrol methods, different global_quality settings, different input seek offsets, different durations, different audio codecs (including discarding audio entirely). 
- The problem ONLY occurs when using the h264_qsv codec, I haven't seen it using libx264.

At this point I'm not sure how else to troubleshoot this, would appreciate input and/or suggestions. It's unclear to me where in the Intel<-->ffmpeg interface this might lie or how to determine that: it's entirely possible this is a QSV problem.

ffmpeg output (the program hangs indefinitely at the last line, but is NOT consistent at exactly how many frames it processes before hanging... I've seen anywhere from zero frames up to a couple hundred. If it gets past the first five seconds or so it always completes.)

ffmpeg version N-82324-g872b358 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 36.100 / 55. 36.100
  libavcodec     57. 66.101 / 57. 66.101
  libavformat    57. 57.100 / 57. 57.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 66.100 /  6. 66.100
  libswscale      4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
[mpegts @ 0000000000612660] parser not found for codec hdmv_pgs_subtitle, packets or times may be invalid.
    Last message repeated 1 times
[h264 @ 0000000000614ca0] Reinit context to 1920x1088, pix_fmt: yuv420p
[NULL @ 0000000000614ca0] Ignoring NAL type 9 in extradata
    Last message repeated 8 times
Input #0, mpegts, from '00021.MTS':
  Duration: 00:04:36.13, start: 1.040000, bitrate: 22468 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High), 1 reference frame (HDMV / 0x564D4448), yuv420p(top first, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
[graph 0 input from stream 0:0 @ 0000000000612580] w:1920 h:1080 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:1/1 sws_param:flags=2
[auto-inserted scaler 0 @ 0000000000f56f00] w:iw h:ih flags:'bicubic' interl:0
[format @ 000000000061b0c0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[auto-inserted scaler 0 @ 0000000000f56f00] w:1920 h:1080 fmt:yuv420p sar:1/1 -> w:1920 h:1080 fmt:nv12 sar:1/1 flags:0x4
[h264 @ 0000000003211e00] Ignoring NAL type 9 in extradata
[h264_qsv @ 00000000028800a0] Initialized an internal MFX session using hardware accelerated implementation
[h264_qsv @ 00000000028800a0] Using the VBR with lookahead (LA) ratecontrol method
[h264_qsv @ 00000000028800a0] profile: high; level: 40
[h264_qsv @ 00000000028800a0] GopPicSize: 250; GopRefDist: 4; GopOptFlag: closed ; IdrInterval: 0
[h264_qsv @ 00000000028800a0] TargetUsage: 4; RateControlMethod: LA
[h264_qsv @ 00000000028800a0] TargetKbps: 1000; LookAheadDepth: 40
[h264_qsv @ 00000000028800a0] NumSlice: 1; NumRefFrame: 2
[h264_qsv @ 00000000028800a0] RateDistortionOpt: OFF
[h264_qsv @ 00000000028800a0] RecoveryPointSEI: OFF IntRefType: 0; IntRefCycleSize: 0; IntRefQPDelta: 0
[h264_qsv @ 00000000028800a0] MaxFrameSize: 783360; MaxSliceSize: 0;
[h264_qsv @ 00000000028800a0] BitrateLimit: ON; MBBRC: OFF; ExtBRC: unknown
[h264_qsv @ 00000000028800a0] Trellis: auto
[h264_qsv @ 00000000028800a0] RepeatPPS: ON; NumMbPerSlice: 0; LookAheadDS: unknown
[h264_qsv @ 00000000028800a0] AdaptiveI: unknown; AdaptiveB: unknown; BRefType: off
[h264_qsv @ 00000000028800a0] MinQPI: 0; MaxQPI: 0; MinQPP: 0; MaxQPP: 0; MinQPB: 0; MaxQPB: 0
[h264_qsv @ 00000000028800a0] Entropy coding: CABAC; MaxDecFrameBuffering: 2
[h264_qsv @ 00000000028800a0] NalHrdConformance: OFF; SingleSeiNalUnit: ON; VuiVclHrdParameters: OFF VuiNalHrdParameters: OFF
Output #0, mp4, to 'out.mp4':
    encoder         : Lavf57.57.100
    Stream #0:0: Video: h264 (h264_qsv), 1 reference frame ([33][0][0][0] / 0x0021), nv12(left), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 1000 kb/s, 25 fps, 12800 tbn, 25 tbc
      encoder         : Lavc57.66.101 h264_qsv
    Side data:
      cpb: bitrate max/min/avg: 0/0/1000000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_qsv))
Press to stop, [?] for help
[NULL @ 0000000000614ca0] Ignoring NAL type 9 in extradata
[h264 @ 0000000003211e00] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 00000000031abd40] reference picture missing during reorder
[h264 @ 00000000031abd40] Missing reference picture, default is 2147483647
*** 3 dup!
frame=   30 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=3 drop=0 speed=   0x

[lwobker:/dtop]$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 61
model name      : Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
stepping        : 4
cpu MHz         : 2594.000
cache size      : 256 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 20
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt aes xsave osxsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:





0 Kudos
0 Replies