<div dir="ltr"><div>It appears my problem was due to lack of IDR frames - playing the segments with ffplay gave me some more error messages to google ;-) I was able to get it working by forcing nvenc to emit an IDR frame at the beginning of each GOP. I can't figure out if there's a way to tell from the parser whether the current frame is an IDR frame or just a regular I frame though, should this be possible to detect?</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 9, 2018 at 10:30 AM Evan Odabashian <<a href="mailto:eodabash@gmail.com">eodabash@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Well that is basically what I'm doing already, using the built-in HLS muxer not manually creating the ts segments and playlist. I'm using the h264 parser because the samples I'm receiving from nvenc are not complete frames so I'm using the parser to assemble the full frames then give them to the muxer via av_interleaved_write_frame. </div><div><br></div><div>Presumably the HLS muxer (which I believe is the code located in hlsenc.c right?) knows how to build valid HLS segments so I can only assume I'm misrepresenting something to it about the frames I'm providing.<br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 9, 2018 at 4:42 AM He Lei <<a href="mailto:helei0908@hotmail.com" target="_blank">helei0908@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word;line-break:after-white-space">
Many frames are keyframes. such as SPS/PPS and I frames, If you generate the hls_list file yourself,  and mux as ts file.  It has to start with SPS and PPS, and then I frame;
<div><br>
</div>
<div><br>
</div>
<div>Another way, you can mux as hls, that would be easier():<br>
<div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_3421250582144652247m_-6095284775855007397Apple-tab-span" style="white-space:pre-wrap"></span>avformat_alloc_output_context2(&</span>format_ctx, xxx, “hls”, xxx);</div>
</div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures:no-common-ligatures"><br>
</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures:no-common-ligatures"><span style="font-family:Helvetica;font-size:12px"><span class="m_3421250582144652247m_-6095284775855007397Apple-tab-span" style="white-space:pre-wrap"></span>and set the  hls_list_size to 0:</span></span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo">
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal"><span class="m_3421250582144652247m_-6095284775855007397Apple-tab-span" style="white-space:pre-wrap"></span>av_opt_set_int(format_ctx, “hls_list_size”, 0, 0);</div>
<div style="margin:0px;font-stretch:normal;line-height:normal"><br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal">If you want to format the list,also use av_opt_set.  </div>
<div style="margin:0px;font-stretch:normal;line-height:normal">This command tells you something you can set:
<span class="m_3421250582144652247m_-6095284775855007397Apple-tab-span" style="white-space:pre-wrap"></span>“ffmpeg -h muxer=hls”</div>
<div style="margin:0px;font-stretch:normal;line-height:normal"><br>
</div>
<div><br>
<div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
LeiHe</div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<a href="mailto:helei0908@hotmail.com" target="_blank">helei0908@hotmail.com</a></div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<br>
</div>
<br class="m_3421250582144652247m_-6095284775855007397Apple-interchange-newline">
</div>
<div><br>
<blockquote type="cite">
<div>在 2018年10月9日,上午8:38,Evan Odabashian <<a href="mailto:eodabash@gmail.com" target="_blank">eodabash@gmail.com</a>> 写道:</div>
<br class="m_3421250582144652247m_-6095284775855007397Apple-interchange-newline">
<div>
<div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
I'm trying to use libavformat to write a stream of H.264 data (coming from the NvCodec API) directly (without re-encoding) to an HLS playlist. I'm sending the packets returned by the encoder through av_parser_parse2 until I get a complete frame, and then writing
 the resulting frame with av_interleaved_write_frames. This is mostly working in that I get an m3u8 playlist + .ts segments that plays back successfully if it starts from the first .ts segment (and can play through any number of subsequent segments). </div>
<div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<br>
</div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
I'm not able to start playback directly from any segment after the first one however. Viewing the file details in Windows explorer for the first .ts segment shows correct values for the frame dimensions, bitrate, and frame rate. For all other segments however
 these values are wrong (and not consistent from one file to the next). I'm pretty sure each new segment is beginning on a keyframe (in that I see the new .ts file appear right after the parser detects a keyframe and I write the output frame with the AV_PKT_FLAG_KEY
 flag). I can change the segment duration to any value I want (1 second, 10 seconds, etc) and see the same behavior I don't think this is an issue with the incoming sample themselves. </div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<br>
</div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
Can anyone guess what might be the problem here, or have some ideas to try and diagnose the problem further?</div>
<br class="m_3421250582144652247m_-6095284775855007397Apple-interchange-newline">
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>

_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div>
</blockquote></div>