[Libav-user] streaming raw H.264 to HLS

Evan Odabashian eodabash at gmail.com
Tue Oct 9 20:30:32 EEST 2018


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.

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.

On Tue, Oct 9, 2018 at 4:42 AM He Lei <helei0908 at hotmail.com> wrote:

> 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;
>
>
> Another way, you can mux as hls, that would be easier():
> avformat_alloc_output_context2(&format_ctx, xxx, “hls”, xxx);
>
> and set the  hls_list_size to 0:
> av_opt_set_int(format_ctx, “hls_list_size”, 0, 0);
>
> If you want to format the list,also use av_opt_set.
> This command tells you something you can set: “ffmpeg -h muxer=hls”
>
>
> LeiHe
> helei0908 at hotmail.com
>
>
>
> 在 2018年10月9日,上午8:38,Evan Odabashian <eodabash at gmail.com> 写道:
>
> 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).
>
> 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.
>
> Can anyone guess what might be the problem here, or have some ideas to try
> and diagnose the problem further?
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20181009/8df73975/attachment.html>


More information about the Libav-user mailing list