[FFmpeg-devel] [PATCH v2 2/2] avformat/dashenc: Option to generate hls playlist as well

Michael Niedermayer michael at niedermayer.cc
Wed Nov 22 17:36:14 EET 2017


On Wed, Nov 22, 2017 at 02:50:12PM +0530, Karthick J wrote:
> This is to take full advantage of Common Media Application Format.
> Now server can generate one content and serve both HLS and DASH players.
> ---
>  doc/muxers.texi       |   3 ++
>  libavformat/dashenc.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 101 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 0bb8ad2..1cf2481 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -249,6 +249,9 @@ DASH-templated name to used for the media segments. Default is "chunk-stream$Rep
>  URL of the page that will return the UTC timestamp in ISO format. Example: "https://time.akamai.com/?iso"
>  @item -http_user_agent @var{user_agent}
>  Override User-Agent field in HTTP header. Applicable only for HTTP output.
> + at item -hls_playlist @var{hls_playlist}
> +Generate HLS playlist files as well. The master playlist is generated with the filename master.m3u8.
> +One media playlist file is generated for each stream with filenames media_0.m3u8, media_1.m3u8, etc.
>  @item -adaptation_sets @var{adaptation_sets}
>  Assign streams to AdaptationSets. Syntax is "id=x,streams=a,b,c id=y,streams=d,e" with x and y being the IDs
>  of the adaptation sets and a,b,c,d and e are the indices of the mapped streams.
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 201668a..4c3962a 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -36,6 +36,7 @@
>  #include "avc.h"
>  #include "avformat.h"
>  #include "avio_internal.h"
> +#include "hlsenc.h"
>  #include "internal.h"
>  #include "isom.h"
>  #include "os_support.h"
> @@ -101,6 +102,8 @@ typedef struct DASHContext {
>      const char *media_seg_name;
>      const char *utc_timing_url;
>      const char *user_agent;
> +    int hls_playlist;
> +    int master_playlist_created;
>  } DASHContext;
>  
>  static struct codec_string {
> @@ -217,6 +220,13 @@ static void set_http_options(AVDictionary **options, DASHContext *c)
>          av_dict_set(options, "user_agent", c->user_agent, 0);
>  }
>  
> +static void get_hls_playlist_name(char *playlist_name, const char *base_url, int id) {
> +    if (base_url)
> +        sprintf(playlist_name, "%smedia_%d.m3u8", base_url, id);
> +    else
> +        sprintf(playlist_name, "media_%d.m3u8", id);
> +}

please always use snprint, not sprintf as it can overwrite the array

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20171122/5e7a13b5/attachment.sig>


More information about the ffmpeg-devel mailing list