[FFmpeg-user] Libnvenc live transcode mpeg2 to x264 hls missing key frames?

Subscriptions@znet.ca subscriptions at znet.ca
Fri Feb 5 05:10:08 CET 2016


Hello everyone,

I am experimenting unusual behaviour while transcoding live video via 
libnvenc, and would like to ask if someone else had this problem or some 
suggestion on what I am not doing right.

The situation: I want to transcode a live mpeg2 stream of ~16Mb/s to 
h264, and got an nvidia gtx690 card for making this task. The incoming 
stream is an mpeg ts from an antenna via hdhomerun ATSC tuner, and the 
stream can be watched as mpeg2 just perfectly.

The problem: When I encode the stream as h264 mpeg ts segmented video 
(or hls) **via libnvenc**, the stream can be played only if the player 
(ffplay, etc) is started from the first segment, and the player will not 
start when first segment gets outside the m3u list. The stream will play 
from any starting point if the encoding is done with libx264.

The error given is that there is no key frame other than PPS0, what 
makes no sense as the stream will be useless without keyframes - and it 
plays just fine if started from the beginning. Trying to force key 
frames or reduce the gop size makes no difference, up to now I found no 
way to make the stream usable if not started from the beginning. Again, 
this is only if transcoded via libnvenc.

I did upload transcoded files both via libnvenc and libx264 to 
**http://downloads.znet.ca/ffmpeg-test/** , if someone is interested. It 
is to be noted that any segment produced via libx264 will have keyframe 
with all necessary information for being played alone, while only 
segment 0 from the ones transcoded with libnvenc will have this 
information. (NOTE: video produced with libx264 is of awful quality, but 
can be played segment by segment; the one via libnvenc has very good 
quality, but starts from segment 0 only)

------------------------------------
Transcoding:
ffmpeg -i udp://239.255.254.5:1234?overrun_nonfatal=1 -y -c:a copy -c:v 
libnvenc -b:v 4M -profile:v high -preset ultrafast  -bufsize 8M 
-segment_format mpeg_ts ./m3u/TEST2/TS-nvenc.m3u8

The only difference when transcoding with libx264 is -c:v libx264.
The first segment trancoded via libnvenc and any segment transcoded via 
libx264 will show following:

ggeorgiev at gtx690:/var/www/iptv/html$ ffprobe m3u/TEST2/TS-x2645.ts
ffprobe version 2.4.git Copyright (c) 2007-2014 the FFmpeg developers
   built on Dec 21 2015 20:16:32 with gcc 4.9.2 (Debian 4.9.2-10)
   configuration: --enable-libnvenc --enable-libfaac --enable-libfdk-aac 
--enable-librtmp --enable-libx264 --enable-gpl --enable-nonfree
   libavutil      54. 10.100 / 54. 10.100
   libavcodec     56.  8.102 / 56.  8.102
   libavformat    56.  9.101 / 56.  9.101
   libavdevice    56.  1.100 / 56.  1.100
   libavfilter     5.  1.106 /  5.  1.106
   libswscale      3.  1.101 /  3.  1.101
   libswresample   1.  1.100 /  1.  1.100
   libpostproc    53.  3.100 / 53.  3.100
Input #0, mpegts, from 'm3u/TEST2/TS-x2645.ts':
   Duration: 00:00:08.37, start: 43.108333, bitrate: 4735 kb/s
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: h264 (Constrained Baseline) 
([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 
fps, 29.97 tbr, 90k tbn, 59.94 tbc
     Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 
5.1(side), fltp, 384 kb/s


All segments, except the first one transcoded with libnvenc will show 
following:
ggeorgiev at gtx690:/var/www/iptv/html$ ffprobe m3u/TEST2/TS-nvenc2.ts

ggeorgiev at gtx690:/var/www/iptv/html$ ffprobe m3u/TEST2/TS-nvenc2.ts
ffprobe version 2.4.git Copyright (c) 2007-2014 the FFmpeg developers
   built on Dec 21 2015 20:16:32 with gcc 4.9.2 (Debian 4.9.2-10)
   configuration: --enable-libnvenc --enable-libfaac --enable-libfdk-aac 
--enable-librtmp --enable-libx264 --enable-gpl --enable-nonfree
   libavutil      54. 10.100 / 54. 10.100
   libavcodec     56.  8.102 / 56.  8.102
   libavformat    56.  9.101 / 56.  9.101
   libavdevice    56.  1.100 / 56.  1.100
   libavfilter     5.  1.106 /  5.  1.106
   libswscale      3.  1.101 /  3.  1.101
   libswresample   1.  1.100 /  1.  1.100
   libpostproc    53.  3.100 / 53.  3.100
[h264 @ 0x2aca460] non-existing PPS 0 referenced
     Last message repeated 1 times
[h264 @ 0x2aca460] decode_slice_header error
[h264 @ 0x2aca460] no frame!
[h264 @ 0x2aca460] non-existing PPS 0 referenced
     Last message repeated 1 times
[h264 @ 0x2aca460] decode_slice_header error
[h264 @ 0x2aca460] no frame!
[h264 @ 0x2aca460] non-existing PPS 0 referenced
     Last message repeated 1 times
[h264 @ 0x2aca460] decode_slice_header error
......
......  --- exactly same lines repeating ----
......
[h264 @ 0x2aca460] non-existing PPS 0 referenced
     Last message repeated 1 times
[h264 @ 0x2aca460] decode_slice_header error
[h264 @ 0x2aca460] no frame!
[mpegts @ 0x2ac64c0] decoding for stream 0 failed
[mpegts @ 0x2ac64c0] Could not find codec parameters for stream 0 
(Video: h264 ([27][0][0][0] / 0x001B), none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' 
options
Input #0, mpegts, from 'm3u/TEST2/TS-nvenc2.ts':
   Duration: 00:00:02.01, start: 5.404000, bitrate: 4867 kb/s
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: h264 ([27][0][0][0] / 0x001B), none, 
29.97 fps, 29.97 tbr, 90k tbn, 180k tbc
     Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 
5.1(side), fltp, 384 kb/s

So, how it can be that key frames are invisible in the output produced 
by libnvenc? And if so, how the stream can be played normally if there 
are no key frames in it?

Any idea appreciated,
Thanks, george.



More information about the ffmpeg-user mailing list