Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread


在 2020/7/25 下午2:11,“ffmpeg-devel 代表 Zlomek, 
Josef” 写入:

Hi Steven,

It is better but still not correct. Consider this test:

test("http://server/foo/bar;,
"a/b/../c/d/../e../.../..f/g../h../other/url/a.mp3/...");
It should give "
http://server/foo/bar/a/c/e../.../..f/g../h../other/url/a.mp3/...;.

I think the best would be to use strtok(p, "/") to split the path into the
components and for each ".." component remove the previous one (if there
are some still).
I think you can submit patch if you have full idea for it.

Best regards,
Josef

On Sat, Jul 25, 2020 at 4:45 AM Steven Liu  wrote:

> fix ticket: 8814
> if get ".." in the url, check next byte and lead byte by double dot,
> it there have no '/' and not root node, it is not used go to directory 
".."
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/url.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/libavformat/url.c b/libavformat/url.c
> index 20463a6674..35f27fe3ca 100644
> --- a/libavformat/url.c
> +++ b/libavformat/url.c
> @@ -97,6 +97,18 @@ static void trim_double_dot_url(char *buf, const char
> *rel, int size)
>  /* set new current position if the root node is changed */
>  p = root;
>  while (p && (node = strstr(p, ".."))) {
> +if (strlen(node) > 2 && node[2] != '/') {
> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
> +if (p != node && p[node - p - 1] != '/') {
> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
>  av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
>  p = node + 3;
>  sep = strrchr(tmp_path, '/');
> --
> 2.25.0
>
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



-- 
Josef Zlomek
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/crypto.c: remove unnecessary code

2020-07-13 Thread


在 2020/7/14 上午2:45,“ffmpeg-devel 代表 Tomas 
Härdin” 写入:

lör 2020-07-11 klockan 16:04 +0800 skrev Steven Liu:
> Because the newpos variable is set value before use it.
> The newpos variable declared at the head partition of crypto_seek.
> 
> Signed-off-by: Steven Liu 
> ---
>  libavformat/crypto.c | 11 ---
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/crypto.c b/libavformat/crypto.c
> index 31f9ac0ab9..daa29ed501 100644
> --- a/libavformat/crypto.c
> +++ b/libavformat/crypto.c
> @@ -252,21 +252,18 @@ static int64_t crypto_seek(URLContext *h, int64_t 
pos, int whence)
>  case SEEK_CUR:
>  pos = pos + c->position;
>  break;
> -case SEEK_END: {
> -int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE );
> +case SEEK_END:
> +newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE );

Make me wonder why this was declared like this in the first place.
Maybe move the definition of the newpos in the outer scope to where
it's used instead? FFmpeg is C99 now so that should be fine.
I just want make it clean, whatever C89, C99.
Because there had one definition of the newpos at the function start part, and 
assignment value at here before use it at here,
and remove the braces.
Just make it looks clean.
>  if (newpos < 0) {
>  av_log(h, AV_LOG_ERROR,
>  "Crypto: seek_end - can't get file size (pos=%lld)\r\n", 
(long long int)pos);
>  return newpos;
>  }
>  pos = newpos - pos;
> -}
>  break;
> -case AVSEEK_SIZE: {
> -int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE );
> +case AVSEEK_SIZE:
> +newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE );
>  return newpos;

Why not just return ffurl_seek()?
you are right, will submit v2


Thanks

Steven




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/hls: check target duration in the playlist

2020-05-16 Thread
2020年5月16日 下午8:21,Carl Eugen Hoyos  写道: Am Sa., 16. Mai 2020 um 14:12 Uhr 
schrieb Steven Liu : fix ticket: 8673 reference rfc8216 4.3.3.1 said: The 
EXT-X-TARGETDURATION tag is REQUIRED. in ticket 8673, the EXT-X-TARGETDURATION 
is incorrect, so hls should return error. Can't an invalid target duration be 
ignored? Or is the stream unplayable without target duration? Ah, you are 
right, it’s not EXT-X-TARGETDURATION problem. Need continue analyse  :( Carl 
Eugen ___ ffmpeg-devel mailing list 
ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To 
unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with 
subject "unsubscribe". Thanks Steven Liu 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/1] avformat/hlsenc: fix for zero EXTINFtag duration

2018-03-12 Thread
> On 12 Mar 2018, at 17:31, vdi...@akamai.com wrote:
> 
> From: Vishwanath Dixit 
> 
> This is the fix for bug https://trac.ffmpeg.org/ticket/7073
> ---
> libavformat/hlsenc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 08fe0aa..7d9512b 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2501,7 +2501,7 @@ static int hls_init(AVFormatContext *s)
> /* Get one video stream to reference for split segments
>  * so use the first video stream index. */
> if ((vs->has_video == 1) && (vs->streams[j]->codecpar->codec_type 
> == AVMEDIA_TYPE_VIDEO)) {
> -vs->reference_stream_index = j;
> +vs->reference_stream_index = vs->streams[j]->index;
> }
> vs->has_subtitle += vs->streams[j]->codecpar->codec_type == 
> AVMEDIA_TYPE_SUBTITLE;
> }
> -- 
> 1.9.1
> 

LGTM

Thanks
Steven



pushed


Thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Check ret on avformat_write_header

2018-01-25 Thread


> On 24 Jan 2018, at 09:24, Brendan McGrath  wrote:
> 
> Encoding currently fails when using hls_ts_options with the fmp4
> segment type.
> 
> This is due to the fact that avformat_write_header does not process
> the passed options when the avformat is already initialized.
> 
> When using fmp4, the hls_ts_options are parsed and the avformat
> initialized within hls_mux_init.
> 
> This patch checks the return of avformat_write_header so that if
> it is greater than zero (indicating the avformat is already
> initialized) then it does not error.
> 
> Signed-off-by: Brendan McGrath 
> ---
> I'm not sure if hls_ts_options is supposed to be used with fmp4 as the
> description is currently:
> hls_ts_options E... set hls mpegts list of options for 
> the container format used for hls
> 
> If it is (and the code within hls_mux_init seems to indicate that it is) - 
> then this
> patch fixes that (and the next will change the description - perhaps the 
> option should
> be renamed too?).

maybe fmp4 need not use this option in short time.
> 
> I also considered checking if ret was < 0 and erroring immediately rather 
> than relying
> on av_dict_count. But I wasn't sure if that check had been intentionally left 
> out
> so the av_dict_free would take place.
> 
> Let me know if the preference is for another if statement for ret < 0.
> 
> libavformat/hlsenc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 42e437f..d83d3b9 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1878,7 +1878,7 @@ static int hls_write_header(AVFormatContext *s)
> 
> av_dict_copy(, hls->format_options, 0);
> ret = avformat_write_header(vs->avf, );
> -if (av_dict_count(options)) {
> +if (ret <= 0 && av_dict_count(options)) {
> av_log(s, AV_LOG_ERROR, "Some of provided format options in '%s' 
> are not recognized\n", hls->format_options_str);
> ret = AVERROR(EINVAL);
> av_dict_free();
> -- 
> 2.7.4
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] hls: don't print a certain warning if playlist loading is aborted

2018-01-25 Thread

> On 24 Jan 2018, at 15:08, wm4  wrote:
> 
> AVERROR_EXIT happens when the user's interrupt callback signals that
> playback should be aborted. In this case, the demuxer shouldn't print a
> warning, as it's expected that all network accesses are stopped.
> ---
> libavformat/hls.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 6e1a2e3f1e..02e764f932 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -1422,8 +1422,9 @@ reload:
> if (!v->finished &&
> av_gettime_relative() - v->last_load_time >= reload_interval) {
> if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) {
> -av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist 
> %d\n",
> -   v->index);
> +if (ret != AVERROR_EXIT)
> +av_log(v->parent, AV_LOG_WARNING, "Failed to reload 
> playlist %d\n",
> +   v->index);
> return ret;
> }
> /* If we need to reload the playlist again below (if
> -- 
> 2.15.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patchset LGTM


Thanks
Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Check ret on avformat_write_header

2018-01-25 Thread


> On 24 Jan 2018, at 09:24, Brendan McGrath  wrote:
> 
> Encoding currently fails when using hls_ts_options with the fmp4
> segment type.
> 
> This is due to the fact that avformat_write_header does not process
> the passed options when the avformat is already initialized.
> 
> When using fmp4, the hls_ts_options are parsed and the avformat
> initialized within hls_mux_init.
> 
> This patch checks the return of avformat_write_header so that if
> it is greater than zero (indicating the avformat is already
> initialized) then it does not error.
> 
> Signed-off-by: Brendan McGrath 
> ---
> I'm not sure if hls_ts_options is supposed to be used with fmp4 as the
> description is currently:
> hls_ts_options E... set hls mpegts list of options for 
> the container format used for hls
> 
> If it is (and the code within hls_mux_init seems to indicate that it is) - 
> then this
> patch fixes that (and the next will change the description - perhaps the 
> option should
> be renamed too?).
> 
> I also considered checking if ret was < 0 and erroring immediately rather 
> than relying
> on av_dict_count. But I wasn't sure if that check had been intentionally left 
> out
> so the av_dict_free would take place.
> 
> Let me know if the preference is for another if statement for ret < 0.
> 
> libavformat/hlsenc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 42e437f..d83d3b9 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1878,7 +1878,7 @@ static int hls_write_header(AVFormatContext *s)
> 
> av_dict_copy(, hls->format_options, 0);
> ret = avformat_write_header(vs->avf, );
> -if (av_dict_count(options)) {
> +if (ret <= 0 && av_dict_count(options)) {
> av_log(s, AV_LOG_ERROR, "Some of provided format options in '%s' 
> are not recognized\n", hls->format_options_str);
> ret = AVERROR(EINVAL);
> av_dict_free();
> -- 
> 2.7.4
> 
> 

Should be ok


Thanks
Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread

> On 19 Jan 2018, at 11:18, Jeyapal, Karthick  wrote:
> 
> 
> 
> On 1/19/18 8:42 AM, Brendan McGrath wrote:
>> Thanks Karthick - I can confirm that your patch does solve the issue.
> Thanks for the confirmation.
>> 
>> However - I noticed your patch does not include HEVC. I believe this format 
>> is now supported in HLS (and that several players including iOS 11 now 
>> provide support).
> Yes, I just supported H264 since I was working on it. But that patch is 
> modular enough to easily extend CODECS tag support for HEVC. 
> Maybe somebody can add the HEVC support in CODECS tag later :)
Can you add it into the patch, so that will be perfect :D
>> 
>> On 19/01/18 00:41, Jeyapal, Karthick wrote:
>>> On 1/18/18 6:53 PM, Brendan McGrath wrote:
 I tried your suggestion and it still didn't work. So I took another look 
 at the spec and it looks like what was originally there was correct (as 
 seen in the below example):
 https://tools.ietf.org/html/rfc8216#section-8.6
 
 In that example - english-audio.m3u8 appears in both a MEDIA and 
 STREAM-INF entry with the STREAM-INF entry including an AUDIO tag that 
 references back to itself.
 
 So I believe this patch can be dropped.
 
 What I did discover was that it worked when I added a CODECS tag to the 
 STREAM-INF variant of the audio stream. The spec just says:
 Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute
 
 So I guess this is a bug in iOS.
>>> I agree. But, there is a patch available 
>>> https://patchwork.ffmpeg.org/patch/7000/ to add CODECS tag. 
>>> You could check if applying that patch solves your issue. 
 On 18/01/18 21:59, Dixit, Vishwanath wrote:
> On 1/18/18 2:39 PM, Brendan McGrath wrote:
>> When using an 'agroup' within var_stream_map - the audio stream is
>> being added to the master playlist file as both an audio rendition
>> and an individual stream (with an AUDIO reference back to itself).
>> 
>> This patch ensures an audio rendition does not also appear within
>> the stream info list.
>> 
>> What follows is an example of the command to create this issue and
>> the contents of the master playlist before and after this patch is
>> applied:
>> 
>> ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
>> -map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
>> "v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
>> tv_hls.m3u8 tv_hls_%v.m3u8
>> 
>> Before:
>>  #EXTM3U
>>  #EXT-X-VERSION:3
>>  
>> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>>  #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
>>  tv_hls_0.m3u8
>> 
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_1.m3u8
>> 
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_2.m3u8
>> 
>> After:
>>  #EXTM3U
>>  #EXT-X-VERSION:3
>>  
>> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_1.m3u8
>> 
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_2.m3u8
>> 
>> Signed-off-by: Brendan McGrath 
>> ---
>> 
> Some use cases may need audio only variant streams. Ex: when bandwidth is 
> too low. Also, I think the playback issue you are seeing, is because of 
> AUDIO referencing back to itself, but, not because of audio only variant 
> stream. So, instead of completely removing the audio only variant 
> streams, you can just remove the self-referencing attribute (AUDIO=) from 
> the #EXT-X-STREAM-INF tag’s attribute list, for the audio only variant 
> streams.
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
> #EXT-X-STREAM-INF:BANDWIDTH=140800
> tv_hls_0.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_1.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_2.m3u8
> 
> 
>> Pre-patch - the hls stream I was testing would not play on the iOS 
>> devices I was testing with.
>> 
>> With the patch applied - they now play the stream
>> 
>>  libavformat/hlsenc.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index e36120c..a75853b 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1172,6 +1172,9 @@ static int 

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread


> On 18 Jan 2018, at 17:09, Brendan McGrath  wrote:
> 
> When using an 'agroup' within var_stream_map - the audio stream is
> being added to the master playlist file as both an audio rendition
> and an individual stream (with an AUDIO reference back to itself).
https://patchwork.ffmpeg.org/patch/7229/

Can this patch pass your test case?
> 
> This patch ensures an audio rendition does not also appear within
> the stream info list.
> 
> What follows is an example of the command to create this issue and
> the contents of the master playlist before and after this patch is
> applied:
> 
> ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
> -map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
> "v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
> tv_hls.m3u8 tv_hls_%v.m3u8
> 
> Before:
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
> #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
> tv_hls_0.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_1.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_2.m3u8
> 
> After:
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_1.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_2.m3u8
> 
> Signed-off-by: Brendan McGrath 
> ---
> 
> Pre-patch - the hls stream I was testing would not play on the iOS devices I 
> was testing with.
> 
> With the patch applied - they now play the stream
> 
> libavformat/hlsenc.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e36120c..a75853b 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
> for (i = 0; i < hls->nb_varstreams; i++) {
> vs = &(hls->var_streams[i]);
> 
> +if (!vs->has_video && !vs->has_subtitle && vs->agroup)
> +continue;
> +
> m3u8_name_size = strlen(vs->m3u8_name) + 1;
> m3u8_rel_name = av_malloc(m3u8_name_size);
> if (!m3u8_rel_name) {
> -- 
> 2.7.4
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault)

2018-01-16 Thread

> On 17 Jan 2018, at 11:00, Colin NG  wrote:
> 
> - Add function 'resolve_content_path' to propagate the baseURL from upper 
> level nodes.
> * if no baseURL is available, the path of mpd file will be set as the baseURL.
> - Remove checking for newly established connection.
> - Establish the communication protocol in each connection rather than 
> applying one protocol to all connection.
> ---
> libavformat/dashdec.c | 128 +-
> 1 file changed, 115 insertions(+), 13 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 67a92d6..1d520d4 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -149,6 +149,11 @@ typedef struct DASHContext {
> AVDictionary *avio_opts;
> } DASHContext;
> 
> +static int ishttp(char *url) {
> +const char *proto_name = avio_find_protocol_name(url);
> +return av_strstart(proto_name, "http", NULL);
> +}
> +
> static uint64_t get_current_time_in_sec(void)
> {
> return  av_gettime() / 100;
> @@ -420,7 +425,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
> const char *url,
> else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
> return AVERROR_INVALIDDATA;
> 
> -ret = s->io_open(s, pb, url, AVIO_FLAG_READ, );
> +av_freep(pb);
> +ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, );
> if (ret >= 0) {
> // update cookies on http response with setcookies.
> char *new_cookies = NULL;
> @@ -564,6 +570,7 @@ static struct fragment * get_Fragment(char *range)
> seg->url_offset = strtoll(str_offset, NULL, 10);
> seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset;
> }
> +
> return seg;
> }
> 
> @@ -591,6 +598,7 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
> *s, struct representati
>  rep_id_val,
>  rep_bandwidth_val,
>  initialization_val);
> +
> if (!rep->init_section->url) {
> av_free(rep->init_section);
> xmlFree(initialization_val);
> @@ -665,6 +673,105 @@ static int 
> parse_manifest_segmenttimeline(AVFormatContext *s, struct representat
> return 0;
> }
> 
> +static int resolve_content_path(AVFormatContext *s, const char *url, 
> xmlNodePtr *baseurl_nodes, int n_baseurl_nodes) {
> +
> +char *tmp_str = NULL;
> +char *path = NULL;
> +char *mpdName = NULL;
> +xmlNodePtr node = NULL;
> +char *baseurl = NULL;
> +char *root_url = NULL;
> +char *text = NULL;
> +
> +int isRootHttp = 0;
> +char token ='/';
> +int start =  0;
> +int rootId = 0;
> +int updated = 0;
> +int size = 0;
> +int i;
> +int max_url_size = strlen(url);
> +
> +for (i = n_baseurl_nodes-1; i >= 0 ; i--) {
> +text = xmlNodeGetContent(baseurl_nodes[i]);
> +if (!text)
> +continue;
> +max_url_size += strlen(text);
> +if (ishttp(text)) {
> +xmlFree(text);
> +break;
> +}
> +xmlFree(text);
> +}
> +
> +text = av_mallocz(max_url_size);
> +if (!text) {
> +updated = AVERROR(ENOMEM);
> +goto end;
> +}
> +av_strlcpy(text, url, strlen(url)+1);
> +while (mpdName = av_strtok(text, "/", ))  {
> +size = strlen(mpdName);
> +}
> +
> +path = av_mallocz(max_url_size);
> +tmp_str = av_mallocz(max_url_size);
> +if (!tmp_str || !path) {
> +updated = AVERROR(ENOMEM);
> +goto end;
> +}
> +
> +av_strlcpy (path, url, strlen(url) - size + 1);
> +for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
> +if (!(node = baseurl_nodes[rootId])) {
> +continue;
> +}
> +if (ishttp(xmlNodeGetContent(node))) {
> +break;
> +}
> +}
> +
> +node = baseurl_nodes[rootId];
> +baseurl = xmlNodeGetContent(node);
> +root_url = (av_strcasecmp(baseurl, "")) ? baseurl : path;
> +if (node) {
> +xmlNodeSetContent(node, root_url);
> +updated = 1;
> +}
> +
> +size = strlen(root_url);
> +isRootHttp = ishttp(root_url);
> +
> +if (root_url[size - 1] != token) {
> +av_strlcat(root_url, "/", size + 2);
> +size += 2;
> +}
> +
> +for (i = 0; i < n_baseurl_nodes; ++i) {
> +if (i == rootId) {
> +continue;
> +}
> +text = xmlNodeGetContent(baseurl_nodes[i]);
> +if (text) {
> +memset(tmp_str, 0, strlen(tmp_str));
> +if (!ishttp(text) && isRootHttp) {
> +av_strlcpy(tmp_str, root_url, size + 1);
> +}
> +start = (text[0] == token);
> +av_strlcat(tmp_str, text + start, max_url_size);
> +xmlNodeSetContent(baseurl_nodes[i], tmp_str);

Re: [FFmpeg-devel] [PATCH] libavformat/dashdec: Fix for ticket 6856 (filename limited to 1024)

2018-01-16 Thread

> On 17 Jan 2018, at 06:52, Colin NG  wrote:
> 
> O. I forgot to include on other patches the ticket 6856 fix depended on.
did you have try that patch, can that patch fix the 6856?
> 
> 
> Colin
> 
> 
> PS: the depended patches are
> 
> 0001-libavformat-dashdec-Fix-for-ticket-6658-Dash-demuxer.patch
> 
> 0001-Download-dash-content-with-byte-range-info.patch (not necessary for 
> compilation but needed for the complete solution)
> 
> 
> 
> From: ffmpeg-devel  on behalf of Michael 
> Niedermayer 
> Sent: January 13, 2018 6:56 PM
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/dashdec: Fix for ticket 6856 
> (filename limited to 1024)
> 
> On Fri, Jan 12, 2018 at 10:50:07PM +, Colin NG wrote:
>> ---
>> libavformat/dashdec.c | 87 
>> +--
>> 1 file changed, 56 insertions(+), 31 deletions(-)
> 
> applying: libavformat/dashdec: Fix for ticket 6856 (filename limited to 1024)
> error: sha1 information is lacking or useless (libavformat/dashdec.c).
> error: could not build fake ancestor
> Patch failed at 0001 libavformat/dashdec: Fix for ticket 6856 (filename 
> limited to 1024)
> 
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Asymptotically faster algorithms should always be preferred if you have
> asymptotical amounts of data
> <0001-libavformat-dashdec-Fix-for-ticket-6658-Dash-demuxer.patch><0001-Download-dash-content-with-byte-range-info.patch><0001-libavformat-dashdec-Fix-for-ticket-6856-filename-lim.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 1/1] avformat/hlsenc: closed caption tags in the master playlist

2018-01-09 Thread
>>> 
>> 
>> 
>> I cannot sure use -cc_stream_map_ccgroup option is ok, because the ccgroup 
>> string is not standard, maybe it can be defined bu user.
>> Maybe two ways:
>> 1. use -cc_stream_map_ccgroup ? this way is defined the name by ffmpeg, 
>> cannot modify.
>> 2. parse the closed captions group string by KeyValue way? maybe this is 
>> better.
> 
> Actually, these requirements have been already handled. The parsing is 
> happening based on key value pairs. The keys are ‘ccgroup’, ‘instreamid’, 
> ‘language’. The values for these keys can be set after ‘:’ as given the 
> examples in the patch. 
> I am assuming you are trying to set ccgroup name as closecgroup. In that 
> case, please modify the command as below. Because, the string ‘ccgroup’ is a 
> key value, whatever string that comes after ‘ccgroup:’ is the cc group name.  
> ./ffmpeg -re -f lavfi -i color=red  -g 25  -b:v 1000k -b:a 64k -a53cc 1 -f 
> hls  -cc_stream_map "ccgroup:closecgroup,instreamid:CC1,language:en"   
> -master_pl_name master.m3u8  live/out.m3u8
> 
> To clarify further, consider user wants to set cc group name as ‘mycaptions’, 
> instream id as ‘SERVICE60’ language as Spanish, in that case, the map string 
> would be
> -cc_stream_map "ccgroup:mycaptions,instreamid:SERVICE60,language:sp”  
I understand and i got the point, 
just one question, do you want force the user use ffmpeg must input a string 
“ccgroup” ? if yes, maybe don’t let the user input it use string, maybe use 
-cc_stream_map_ccgroup is better, What do you think about it?


Thanks

Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 1/1] avformat/hlsenc: closed caption tags in the master playlist

2018-01-09 Thread
>> 
> 
> If only copy command of the document, it’s ok,
> If input string by myself, It’s have problem, cannot be used.
> 
> 
> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -re -f lavfi -i color=red  -g 25  -b:v 
> 1000k -b:a 64k -a53cc 1 -f hls  -cc_stream_map 
> "ccgroup:cc,instreamid:CC1,language:en"   -master_pl_name master.m3u8  
> live/out.m3u8
> ffmpeg version N-89757-g42a5fe340f Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
>  configuration: --enable-fontconfig --enable-gpl --enable-libass 
> --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex 
> --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 
> --cc='ccache gcc' --enable-nonfree --enable-videotoolbox
>  libavutil  56.  7.100 / 56.  7.100
>  libavcodec 58.  9.100 / 58.  9.100
>  libavformat58.  3.100 / 58.  3.100
>  libavdevice58.  0.100 / 58.  0.100
>  libavfilter 7. 11.101 /  7. 11.101
>  libswscale  5.  0.101 /  5.  0.101
>  libswresample   3.  0.101 /  3.  0.101
>  libpostproc55.  0.100 / 55.  0.100
> Input #0, lavfi, from 'color=red':
>  Duration: N/A, start: 0.00, bitrate: N/A
>Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 
> 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
> Stream mapping:
>  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
> Press [q] to stop, [?] for help
> [libx264 @ 0x7fadae801600] using SAR=1/1
> [libx264 @ 0x7fadae801600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 
> AVX
> [libx264 @ 0x7fadae801600] profile High, level 2.0
> [libx264 @ 0x7fadae801600] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC 
> codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: 
> cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 
> psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 
> deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 
> sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 
> constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 
> weightb=1 open_gop=0 weightp=2 keyint=25 keyint_min=2 scenecut=40 
> intra_refresh=0 rc_lookahead=25 rc=abr mbtree=1 bitrate=1000 ratetol=1.0 
> qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
> [hls @ 0x7fadae81ec00] Opening 'live/out0.ts' for writing
> Output #0, hls, to 'live/out.m3u8':
>  Metadata:
>encoder : Lavf58.3.100
>Stream #0:0: Video: h264 (libx264), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 
> q=-1--1, 1000 kb/s, 25 fps, 90k tbn, 25 tbc
>Metadata:
>  encoder : Lavc58.9.100 libx264
>Side data:
>  cpb: bitrate max/min/avg: 0/0/100 buffer size: 0 vbv_delay: -1
> [hls @ 0x7fadae81ec00] Opening 'live/out1.ts' for writingte=N/A speed=0.514x
> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
> [hls @ 0x7fadae81ec00] Opening 'live/master.m3u8' for writing
> [hls @ 0x7fadae81ec00] Opening 'live/out2.ts' for writingte=N/A speed=0.71x
> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
> [hls @ 0x7fadae81ec00] Opening 'live/out3.ts' for writingte=N/A speed=0.794x
> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
> [hls @ 0x7fadae81ec00] Opening 'live/out4.ts' for writingte=N/A speed=0.809x
> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
> [hls @ 0x7fadae81ec00] Opening 'live/out.m3u8.tmp' for writing
> frame=  202 fps= 25 q=-1.0 Lsize=N/A time=00:00:08.00 bitrate=N/A speed=0.99x
> video:5kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
> overhead: unknown
> [libx264 @ 0x7fadae801600] frame I:9 Avg QP: 0.44  size:72
> [libx264 @ 0x7fadae801600] frame P:49Avg QP: 0.14  size:22
> [libx264 @ 0x7fadae801600] frame B:144   Avg QP: 0.36  size:16
> [libx264 @ 0x7fadae801600] consecutive B-frames:  5.0%  0.0%  0.0% 95.0%
> [libx264 @ 0x7fadae801600] mb I  I16..4: 100.0%  0.0%  0.0%
> [libx264 @ 0x7fadae801600] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  
> 0.0%  0.0%  0.0%  0.0%skip:100.0%
> [libx264 @ 0x7fadae801600] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  
> 0.0%  0.0%  direct: 0.0%  skip:100.0%
> [libx264 @ 0x7fadae801600] final ratefactor: -27.54
> [libx264 @ 0x7fadae801600] 8x8 transform intra:0.0%
> [libx264 @ 0x7fadae801600] coded y,uvDC,uvAC intra: 0.0% 0.3% 0.0% inter: 
> 0.0% 0.0% 0.0%
> [libx264 @ 0x7fadae801600] i16 v,h,dc,p: 93%  0%  7%  0%
> [libx264 @ 0x7fadae801600] i8c dc,h,v,p: 100%  0%  0%  0%
> [libx264 @ 0x7fadae801600] Weighted P-Frames: Y:0.0% UV:0.0%
> [libx264 @ 0x7fadae801600] kb/s:4.05
> 
> 
> 
> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -re -f lavfi -i color=red  -g 25  -b:v 
> 1000k -b:a 64k -a53cc 1 -f hls  -cc_stream_map 
> "closecgroup:cc,instreamid:CC1,language:en"   -master_pl_name master.m3u8  
> live/out.m3u8
> ffmpeg version N-89757-g42a5fe340f Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM 

Re: [FFmpeg-devel] [PATCH v2 1/1] avformat/hlsenc: closed caption tags in the master playlist

2018-01-09 Thread

> On 9 Jan 2018, at 16:45, vdi...@akamai.com wrote:
> 
> From: Vishwanath Dixit 
> 
> ---
> doc/muxers.texi   |  37 +++
> libavformat/dashenc.c |   2 +-
> libavformat/hlsenc.c  | 155 +-
> libavformat/hlsplaylist.c |   5 +-
> libavformat/hlsplaylist.h |   3 +-
> 5 files changed, 197 insertions(+), 5 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b060c4f..d9a5cc0 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -901,6 +901,43 @@ and they are mapped to the two video only variant 
> streams with audio group names
> 
> By default, a single hls variant containing all the encoded streams is 
> created.
> 
> +@item cc_stream_map
> +Map string which specifies different closed captions groups and their
> +attributes. The closed captions stream groups are separated by space.
> +Expected string format is like this
> +"ccgroup:,instreamid:,language: 
> ".
> +'ccgroup' and 'instreamid' are mandatory attributes. 'language' is an 
> optional
> +attribute.
> +The closed captions groups configured using this option are mapped to 
> different
> +variant streams by providing the same 'ccgroup' name in the
> +@code{var_stream_map} string. If @code{var_stream_map} is not set, then the
> +first available ccgroup in @code{cc_stream_map} is mapped to the output 
> variant
> +stream. The examples for these two use cases are given below.
> +
> +@example
> +ffmpeg -re -i in.ts -b:v 1000k -b:a 64k -a53cc 1 -f hls \
> +  -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en" \
> +  -master_pl_name master.m3u8 \
> +  http://example.com/live/out.m3u8
> +@end example
> +This example adds @code{#EXT-X-MEDIA} tag with @code{TYPE=CLOSED-CAPTIONS} in
> +the master playlist with group name 'cc', langauge 'en' (english) and
> +INSTREAM-ID 'CC1'. Also, it adds @code{CLOSED-CAPTIONS} attribute with group
> +name 'cc' for the output variant stream.
> +@example
> +ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
> +  -a53cc:0 1 -a53cc:1 1\
> +  -map 0:v -map 0:a -map 0:v -map 0:a -f hls \
> +  -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en 
> ccgroup:cc,instreamid:CC2,language:sp" \
> +  -var_stream_map "v:0,a:0,ccgroup:cc v:1,a:1,ccgroup:cc" \
> +  -master_pl_name master.m3u8 \
> +  http://example.com/live/out_%v.m3u8
> +@end example
> +This example adds two @code{#EXT-X-MEDIA} tags with 
> @code{TYPE=CLOSED-CAPTIONS} in
> +the master playlist for the INSTREAM-IDs 'CC1' and 'CC2'. Also, it adds
> +@code{CLOSED-CAPTIONS} attribute with group name 'cc' for the two output 
> variant
> +streams.
> +
> @item master_pl_name
> Create HLS master playlist with the given name.
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 3345b89..39d0afe 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -820,7 +820,7 @@ static int write_manifest(AVFormatContext *s, int final)
> stream_bitrate += max_audio_bitrate;
> }
> get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
> i);
> -ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, 
> agroup);
> +ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, 
> agroup, NULL);
> }
> avio_close(out);
> if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e36120c..4e4b287 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -145,9 +145,16 @@ typedef struct VariantStream {
> unsigned int nb_streams;
> int m3u8_created; /* status of media play-list creation */
> char *agroup; /* audio group name */
> +char *ccgroup; /* closed caption group name */
> char *baseurl;
> } VariantStream;
> 
> +typedef struct ClosedCaptionsStream {
> +char *ccgroup; /* closed caption group name */
> +char *instreamid; /* closed captions INSTREAM-ID */
> +char *language; /* closed captions langauge */
> +} ClosedCaptionsStream;
> +
> typedef struct HLSContext {
> const AVClass *class;  // Class for private options.
> int64_t start_sequence;
> @@ -196,11 +203,14 @@ typedef struct HLSContext {
> 
> VariantStream *var_streams;
> unsigned int nb_varstreams;
> +ClosedCaptionsStream *cc_streams;
> +unsigned int nb_ccstreams;
> 
> int master_m3u8_created; /* status of master play-list creation */
> char *master_m3u8_url; /* URL of the master m3u8 file */
> int version; /* HLS version */
> char *var_stream_map; /* user specified variant stream map string */
> +char *cc_stream_map; /* user specified closed caption streams map string 
> */
> char *master_pl_name;
> unsigned int master_publish_rate;
> int http_persistent;
> @@ -1115,7 +1125,8 @@ static int create_master_playlist(AVFormatContext *s,
> AVDictionary *options = NULL;
> unsigned int i, j;
> int m3u8_name_size, ret, bandwidth;
> -char 

Re: [FFmpeg-devel] [PATCH 6/6] dashdec: Support SegmentTemplate inside Period

2018-01-07 Thread

> On 8 Jan 2018, at 02:46, Stefan _  wrote:
> 
> <0006-dashdec-Support-SegmentTemplate-inside-Period.patch>

>From 89b42dc60156f1e030a30e13636651db41e9f34b Mon Sep 17 00:00:00 2001
From: sfan5 
Date: Fri, 5 Jan 2018 15:32:23 +0100
Subject: [PATCH 6/6] dashdec: Support SegmentTemplate inside Period

---
 libavformat/dashdec.c | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index af8ab5f2f..ac1080b62 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -646,6 +646,7 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
  xmlNodePtr adaptionset_node,
  xmlNodePtr mpd_baseurl_node,
  xmlNodePtr period_baseurl_node,
+ xmlNodePtr 
period_segmenttemplate_node,
  xmlNodePtr fragment_template_node,
  xmlNodePtr content_component_node,
  xmlNodePtr adaptionset_baseurl_node,
@@ -662,7 +663,7 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 xmlNodePtr representation_segmentlist_node = NULL;
 xmlNodePtr segmentlists_tab[2];
 xmlNodePtr fragment_timeline_node = NULL;
-xmlNodePtr fragment_templates_tab[3];
+xmlNodePtr fragment_templates_tab[4];
 char *duration_val = NULL;
 char *presentation_timeoffset_val = NULL;
 char *startnumber_val = NULL;
@@ -702,18 +703,19 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 baseurl_nodes[2] = adaptionset_baseurl_node;
 baseurl_nodes[3] = representation_baseurl_node;
 
-if (representation_segmenttemplate_node || fragment_template_node) {
+if (representation_segmenttemplate_node || fragment_template_node || 
period_segmenttemplate_node) {
 fragment_timeline_node = NULL;
 fragment_templates_tab[0] = representation_segmenttemplate_node;
 fragment_templates_tab[1] = adaptionset_segmentlist_node;
 fragment_templates_tab[2] = fragment_template_node;
+fragment_templates_tab[3] = period_segmenttemplate_node;
 
-presentation_timeoffset_val = 
get_val_from_nodes_tab(fragment_templates_tab, 3, "presentationTimeOffset");
-duration_val = get_val_from_nodes_tab(fragment_templates_tab, 3, 
"duration");
-startnumber_val = get_val_from_nodes_tab(fragment_templates_tab, 
3, "startNumber");
-timescale_val = get_val_from_nodes_tab(fragment_templates_tab, 3, 
"timescale");
-initialization_val = 
get_val_from_nodes_tab(fragment_templates_tab, 3, "initialization");
-media_val = get_val_from_nodes_tab(fragment_templates_tab, 3, 
"media");
+presentation_timeoffset_val = 
get_val_from_nodes_tab(fragment_templates_tab, 4, "presentationTimeOffset");
+duration_val = get_val_from_nodes_tab(fragment_templates_tab, 4, 
"duration");
+startnumber_val = get_val_from_nodes_tab(fragment_templates_tab, 
4, "startNumber");
+timescale_val = get_val_from_nodes_tab(fragment_templates_tab, 4, 
"timescale");
+initialization_val = 
get_val_from_nodes_tab(fragment_templates_tab, 4, "initialization");
+media_val = get_val_from_nodes_tab(fragment_templates_tab, 4, 
"media");
 
 if (initialization_val) {
 rep->init_section = av_mallocz(sizeof(struct fragment));
@@ -866,7 +868,8 @@ end:
 static int parse_manifest_adaptationset(AVFormatContext *s, const char *url,
 xmlNodePtr adaptionset_node,
 xmlNodePtr mpd_baseurl_node,
-xmlNodePtr period_baseurl_node)
+xmlNodePtr period_baseurl_node,
+xmlNodePtr period_segmenttemplate_node)
 {
 int ret = 0;
 xmlNodePtr fragment_template_node = NULL;
@@ -890,6 +893,7 @@ static int parse_manifest_adaptationset(AVFormatContext *s, 
const char *url,
 adaptionset_node,
 mpd_baseurl_node,
 period_baseurl_node,
+period_segmenttemplate_node,
 fragment_template_node,
 content_component_node,
 adaptionset_baseurl_node,
@@ -918,6 +922,7 @@ static int parse_manifest(AVFormatContext *s, const char 
*url, AVIOContext *in)
 xmlNodePtr period_node = NULL;
 xmlNodePtr 

Re: [FFmpeg-devel] [PATCH 5/6] dashdec: Avoid trying to read any segments beyond the last

2018-01-07 Thread

> On 8 Jan 2018, at 02:46, Stefan _  wrote:
> 
> 
> <0005-dashdec-Avoid-trying-to-read-any-segments-beyond-the.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

>From 277c710159849816bff4e4f5ccd1139348518620 Mon Sep 17 00:00:00 2001
From: sfan5 
Date: Fri, 5 Jan 2018 14:19:25 +0100
Subject: [PATCH 5/6] dashdec: Avoid trying to read any segments beyond the
 last

---
 libavformat/dashdec.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 1252d4156..af8ab5f2f 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1505,9 +1505,11 @@ restart:
 if (ret > 0)
 goto end;
 
-if (!v->is_restart_needed)
-v->cur_seq_no++;
-v->is_restart_needed = 1;
+if (c->is_live || v->cur_seq_no < v->last_seq_no) {
+   if (!v->is_restart_needed)
+   v->cur_seq_no++;
+   v->is_restart_needed = 1;
+}
 
 end:
 return ret;
-- 
2.15.1



LGTM

Thanks

Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/6] dashdec: Correct seeking behaviour

2018-01-07 Thread

> On 8 Jan 2018, at 02:46, Stefan _  wrote:
> 
> 
> <0004-dashdec-Correct-seeking-behaviour.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

>From bdf3557a400620fce66ca0237f1ff172c227609b Mon Sep 17 00:00:00 2001
From: sfan5 
Date: Fri, 5 Jan 2018 00:51:32 +0100
Subject: [PATCH 4/6] dashdec: Correct seeking behaviour

dash_read_seek() is called only once to issue a seek
of *all* streams to the specified timestamp. But to
avoid reopening each stream, do a "dry run" for streams
that are in a discarded state.
---
 libavformat/dashdec.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index ac0e6c6f9..1252d4156 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1828,19 +1828,22 @@ static int dash_close(AVFormatContext *s)
 return 0;
 }
 
-static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t 
seek_pos_msec, int flags)
+static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t 
seek_pos_msec, int flags, int dry_run)
 {
 int ret = 0;
 int i = 0;
 int j = 0;
 int64_t duration = 0;
 
-av_log(pls->parent, AV_LOG_VERBOSE, "DASH seek pos[%"PRId64"ms], playlist 
%d\n", seek_pos_msec, pls->rep_idx);
+av_log(pls->parent, AV_LOG_VERBOSE, "DASH seek pos[%"PRId64"ms], playlist 
%d%s\n",
+seek_pos_msec, pls->rep_idx, dry_run ? " (dry)" : "");
 
 // single fragment mode
 if (pls->n_fragments == 1) {
 pls->cur_timestamp = 0;
 pls->cur_seg_offset = 0;
+if (dry_run)
+return 0;
 ff_read_frame_flush(pls->ctx);
 return av_seek_frame(pls->ctx, -1, seek_pos_msec * 1000, flags);
 }
@@ -1885,14 +1888,14 @@ set_seq_num:
 pls->cur_timestamp = 0;
 pls->cur_seg_offset = 0;
 pls->init_sec_buf_read_offset = 0;
-ret = reopen_demux_for_component(s, pls);
+ret = dry_run ? 0 : reopen_demux_for_component(s, pls);
 
 return ret;
 }
 
 static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t 
timestamp, int flags)
 {
-int ret, i;
+int ret = 0, i;
 DASHContext *c = s->priv_data;
 int64_t seek_pos_msec = av_rescale_rnd(timestamp, 1000,

s->streams[stream_index]->time_base.den,
@@ -1901,16 +1904,14 @@ static int dash_read_seek(AVFormatContext *s, int 
stream_index, int64_t timestam
 if ((flags & AVSEEK_FLAG_BYTE) || c->is_live)
 return AVERROR(ENOSYS);
 
-ret = AVERROR_EOF;
+/* Seek in discarded streams with dry_run=1 to avoid reopening them */
 for (i = 0; i < c->n_videos; i++) {
-if (c->videos[i]->stream_index == stream_index) {
-ret = dash_seek(s, c->videos[i], seek_pos_msec, flags);
-}
+if (!ret)
+ret = dash_seek(s, c->videos[i], seek_pos_msec, flags, 
!c->videos[i]->ctx);
 }
 for (i = 0; i < c->n_audios; i++) {
-if (c->audios[i]->stream_index == stream_index) {
-ret = dash_seek(s, c->audios[i], seek_pos_msec, flags);
-}
+if (!ret)
+ret = dash_seek(s, c->audios[i], seek_pos_msec, flags, 
!c->audios[i]->ctx);
 }
 
 return ret;
-- 
2.15.1




LGTM

Thanks

Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/6] dashdec: Search for segment timeline inside AdaptionSets too

2018-01-07 Thread

> On 8 Jan 2018, at 02:46, Stefan _  wrote:
> 
> 
> <0003-dashdec-Search-for-segment-timeline-inside-AdaptionS.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

>From c06d6cbcdc9092428d3764a969604d1f22725e56 Mon Sep 17 00:00:00 2001
From: sfan5 
Date: Fri, 5 Jan 2018 00:19:53 +0100
Subject: [PATCH 3/6] dashdec: Search for segment timeline inside AdaptionSets
 too

---
 libavformat/dashdec.c | 40 +++-
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 676979638..ac0e6c6f9 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -648,7 +648,8 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
  xmlNodePtr period_baseurl_node,
  xmlNodePtr fragment_template_node,
  xmlNodePtr content_component_node,
- xmlNodePtr adaptionset_baseurl_node)
+ xmlNodePtr adaptionset_baseurl_node,
+ xmlNodePtr 
adaptionset_segmentlist_node)
 {
 int32_t ret = 0;
 int32_t audio_rep_idx = 0;
@@ -659,8 +660,9 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 xmlNodePtr representation_segmenttemplate_node = NULL;
 xmlNodePtr representation_baseurl_node = NULL;
 xmlNodePtr representation_segmentlist_node = NULL;
+xmlNodePtr segmentlists_tab[2];
 xmlNodePtr fragment_timeline_node = NULL;
-xmlNodePtr fragment_templates_tab[2];
+xmlNodePtr fragment_templates_tab[3];
 char *duration_val = NULL;
 char *presentation_timeoffset_val = NULL;
 char *startnumber_val = NULL;
@@ -703,14 +705,15 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 if (representation_segmenttemplate_node || fragment_template_node) {
 fragment_timeline_node = NULL;
 fragment_templates_tab[0] = representation_segmenttemplate_node;
-fragment_templates_tab[1] = fragment_template_node;
+fragment_templates_tab[1] = adaptionset_segmentlist_node;
+fragment_templates_tab[2] = fragment_template_node;
 
-presentation_timeoffset_val = 
get_val_from_nodes_tab(fragment_templates_tab, 2, "presentationTimeOffset");
-duration_val = get_val_from_nodes_tab(fragment_templates_tab, 2, 
"duration");
-startnumber_val = get_val_from_nodes_tab(fragment_templates_tab, 
2, "startNumber");
-timescale_val = get_val_from_nodes_tab(fragment_templates_tab, 2, 
"timescale");
-initialization_val = 
get_val_from_nodes_tab(fragment_templates_tab, 2, "initialization");
-media_val = get_val_from_nodes_tab(fragment_templates_tab, 2, 
"media");
+presentation_timeoffset_val = 
get_val_from_nodes_tab(fragment_templates_tab, 3, "presentationTimeOffset");
+duration_val = get_val_from_nodes_tab(fragment_templates_tab, 3, 
"duration");
+startnumber_val = get_val_from_nodes_tab(fragment_templates_tab, 
3, "startNumber");
+timescale_val = get_val_from_nodes_tab(fragment_templates_tab, 3, 
"timescale");
+initialization_val = 
get_val_from_nodes_tab(fragment_templates_tab, 3, "initialization");
+media_val = get_val_from_nodes_tab(fragment_templates_tab, 3, 
"media");
 
 if (initialization_val) {
 rep->init_section = av_mallocz(sizeof(struct fragment));
@@ -756,6 +759,8 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 
 if (!fragment_timeline_node)
 fragment_timeline_node = 
find_child_node_by_name(fragment_template_node, "SegmentTimeline");
+if (!fragment_timeline_node)
+fragment_timeline_node = 
find_child_node_by_name(adaptionset_segmentlist_node, "SegmentTimeline");
 if (fragment_timeline_node) {
 fragment_timeline_node = 
xmlFirstElementChild(fragment_timeline_node);
 while (fragment_timeline_node) {
@@ -784,8 +789,11 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 // TODO: 
https://www.brendanlong.com/the-structure-of-an-mpeg-dash-mpd.html
 // 
http://www-itec.uni-klu.ac.at/dash/ddash/mpdGenerator.php?fragmentlength=15=full
 xmlNodePtr fragmenturl_node = NULL;
-duration_val = xmlGetProp(representation_segmentlist_node, 
"duration");
-timescale_val = xmlGetProp(representation_segmentlist_node, 
"timescale");
+segmentlists_tab[0] = representation_segmentlist_node;
+segmentlists_tab[1] = 

Re: [FFmpeg-devel] [PATCH 1/6] dashdec: Expose bandwidth and representation ID as metadata

2018-01-07 Thread

> On 8 Jan 2018, at 02:46, Stefan _  wrote:
> 
> <0001-dashdec-Expose-bandwidth-and-representation-ID-as-me.patch>

>From ba640900c260f8b5b1919c4274b2c2e3e57e2546 Mon Sep 17 00:00:00 2001
From: sfan5 
Date: Thu, 4 Jan 2018 23:45:26 +0100
Subject: [PATCH 1/6] dashdec: Expose bandwidth and representation ID as
 metadata

---
 libavformat/dashdec.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 0e3afd2a3..1a18ab021 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -84,6 +84,8 @@ struct representation {
 int stream_index;
 
 enum AVMediaType type;
+char id[20];
+int bandwidth;
 
 int n_fragments;
 struct fragment **fragments; /* VOD list of fragment for profile */
@@ -801,6 +803,8 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 if (rep) {
 if (rep->fragment_duration > 0 && !rep->fragment_timescale)
 rep->fragment_timescale = 1;
+rep->bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
+strncpy(rep->id, rep_id_val ? rep_id_val : "", sizeof(rep->id));
 if (type == AVMEDIA_TYPE_VIDEO) {
 rep->rep_idx = video_rep_idx;
 c->cur_video = rep;
@@ -1650,10 +1654,20 @@ static int dash_read_header(AVFormatContext *s)
 }
 
 if (c->cur_video) {
-av_program_add_stream_index(s, 0, c->cur_video->stream_index);
+int stream_index = c->cur_video->stream_index;
+av_program_add_stream_index(s, 0, stream_index);
+if (c->cur_video->bandwidth > 0)
+av_dict_set_int(>streams[stream_index]->metadata, 
"variant_bitrate", c->cur_video->bandwidth, 0);
+if (c->cur_video->id[0])
+av_dict_set(>streams[stream_index]->metadata, "id", 
c->cur_video->id, 0);
 }
 if (c->cur_audio) {
-av_program_add_stream_index(s, 0, c->cur_audio->stream_index);
+int stream_index = c->cur_audio->stream_index;
+av_program_add_stream_index(s, 0, stream_index);
+if (c->cur_audio->bandwidth > 0)
+av_dict_set_int(>streams[stream_index]->metadata, 
"variant_bitrate", c->cur_audio->bandwidth, 0);
+if (c->cur_audio->id[0])
+av_dict_set(>streams[stream_index]->metadata, "id", 
c->cur_audio->id, 0);
 }
 }
 
-- 
2.15.1





LGTM


Thanks
Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault)

2018-01-03 Thread

> On 4 Jan 2018, at 08:42, Colin NG  wrote:
> 
> - Add function 'resolve_content_path' to propagate the baseURL from upper 
> level nodes.
> * if no baseURL is available, the path of mpd file will be set as the baseURL.
> - Remove checking for newly established connection.
> - Establish the communication protocol in each connection rather than 
> applying one protocol to all connection.
> ---
> libavformat/dashdec.c | 126 --
> 1 file changed, 113 insertions(+), 13 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 3798649..5345f91 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -148,6 +148,11 @@ static uint64_t get_current_time_in_sec(void)
> return  av_gettime() / 100;
> }
> 
> +static int ishttp(char *url) {
> +const char *proto_name = avio_find_protocol_name(url);
> +return av_strstart(proto_name, "http", NULL);
> +}
> +
> static uint64_t get_utc_date_time_insec(AVFormatContext *s, const char 
> *datetime)
> {
> struct tm timeinfo;
> @@ -392,7 +397,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
> const char *url,
> else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
> return AVERROR_INVALIDDATA;
> 
> -ret = s->io_open(s, pb, url, AVIO_FLAG_READ, );
> +av_freep(pb);
> +ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, );
> if (ret >= 0) {
> // update cookies on http response with setcookies.
> char *new_cookies = NULL;
> @@ -639,6 +645,103 @@ static int 
> parse_manifest_segmenttimeline(AVFormatContext *s, struct representat
> return 0;
> }
> 
> +static int resolve_content_path(AVFormatContext *s, const char *url, 
> xmlNodePtr *baseurl_nodes, int n_baseurl_nodes) {
> +
> +char *tmp_str = NULL;
> +char *path = NULL;
> +char *mpdName = NULL;
> +xmlNodePtr node = NULL;
> +char *baseurl = NULL;
> +char *root_url = NULL;
> +char *text = NULL;
> +
> +int isRootHttp = 0;
> +char token ='/';
> +int start =  0;
> +int rootId = 0;
> +int updated = 0;
> +int size = 0;
> +int i;
> +int max_url_size = strlen(url);
> +
> +for (i = n_baseurl_nodes-1; i >= 0 ; i--) {
> +text = xmlNodeGetContent(baseurl_nodes[i]);
> +if (!text)
> +continue;
> +max_url_size += strlen(text);
> +if (ishttp(text)) {
> +xmlFree(text);
> +break;
> +}
> +xmlFree(text);
> +}
> +
> +text = av_mallocz(max_url_size);
> +if (!text) {
> +updated = AVERROR(ENOMEM);
> +goto end;
> +}
> +av_strlcpy(text, url, strlen(url)+1);
> +while (mpdName = av_strtok(text, "/", ))  {
> +size = strlen(mpdName);
> +}
> +
> +path = av_mallocz(max_url_size);
> +tmp_str = av_mallocz(max_url_size);
> +if (!tmp_str || !path) {
> +updated = AVERROR(ENOMEM);
> +goto end;
> +}
> +
> +av_strlcpy (path, url, strlen(url) - size + 1);
> +for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
> +if (!(node = baseurl_nodes[rootId])) {
> +continue;
> +}
> +if (ishttp(xmlNodeGetContent(node))) {
> +break;
> +}
> +}
> +
> +node = baseurl_nodes[rootId];
> +baseurl = xmlNodeGetContent(node);
> +root_url = (av_strcasecmp(baseurl, "")) ? baseurl : path;
> +if (node) {
> +xmlNodeSetContent(node, root_url);
> +}
> +
> +size = strlen(root_url);
> +isRootHttp = ishttp(root_url);
> +
> +if (root_url[size - 1] != token) {
> +av_strlcat(root_url, "/", size + 2);
> +size += 2;
> +}
> +
> +for (i = 0; i < n_baseurl_nodes; ++i) {
> +if (i == rootId) {
> +continue;
> +}
> +text = xmlNodeGetContent(baseurl_nodes[i]);
> +if (text) {
> +memset(tmp_str, 0, strlen(tmp_str));
> +if (!ishttp(text) && isRootHttp) {
> +av_strlcpy(tmp_str, root_url, size + 1);
> +}
> +start = (text[0] == token);
> +av_strlcat(tmp_str, text + start, max_url_size);
> +xmlNodeSetContent(baseurl_nodes[i], tmp_str);
> +updated = 1;
> +xmlFree(text);
> +}
> +}
> +
> +end:
> +av_free(path);
> +av_free(tmp_str);
> +return updated;
> +
> +}
> static int parse_manifest_representation(AVFormatContext *s, const char *url,
>  xmlNodePtr node,
>  xmlNodePtr adaptionset_node,
> @@ -698,6 +801,11 @@ static int parse_manifest_representation(AVFormatContext 
> *s, const char *url,
> baseurl_nodes[2] = adaptionset_baseurl_node;
> baseurl_nodes[3] = representation_baseurl_node;
> 
> +ret = resolve_content_path(s, url, baseurl_nodes, 4);
> +if (ret == 

Re: [FFmpeg-devel] [PATCH 1/2] avformat/dashenc: Fix a resource leak when http persistent in enabled

2018-01-02 Thread

> On 2 Jan 2018, at 14:48, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> ---
> libavformat/dashenc.c | 11 +++
> 1 file changed, 11 insertions(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 3345b89..c4c112b 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1,6 +1,7 @@
> /*
>  * MPEG-DASH ISO BMFF segmenter
>  * Copyright (c) 2014 Martin Storsjo
> + * Copyright (c) 2018 Akamai Technologies, Inc.
>  *
>  * This file is part of FFmpeg.
>  *
> @@ -1317,6 +1318,16 @@ static int dash_write_trailer(AVFormatContext *s)
> }
> dash_flush(s, 1, -1);
> 
> +if (c->http_persistent) {
> +int i;
> +for (i = 0; i < s->nb_streams; i++) {
> +OutputStream *os = >streams[i];
> +ff_format_io_close(s, >out);
> +}
> +ff_format_io_close(s, >mpd_out);
> +ff_format_io_close(s, >m3u8_out);
> +}
> +
> if (c->remove_at_exit) {
> char filename[1024];
> int i;
> -- 
> 1.9.1
> 

LGTM

Thanks

Steven



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Signal http end of chunk(http_shutdown) explicitly

2018-01-02 Thread

> On 2 Jan 2018, at 14:48, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> Currently http end of chunk is signalled implicitly in dashenc_io_open().
> This mean playlists http writes would have to wait upto a segment duration to 
> signal end of chunk causing delays.
> This patch will fix that problem and improve performance.
> ---
> libavformat/dashenc.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index c4c112b..c328db2 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -149,7 +149,10 @@ static void dashenc_io_close(AVFormatContext *s, 
> AVIOContext **pb, char *filenam
> ff_format_io_close(s, pb);
> #if CONFIG_HTTP_PROTOCOL
> } else {
> +URLContext *http_url_context = ffio_geturlcontext(*pb);
> +av_assert0(http_url_context);
> avio_flush(*pb);
> +ffurl_shutdown(http_url_context, AVIO_FLAG_WRITE);
> #endif
> }
> }
> -- 
> 1.9.1
> 


LGTM

Thanks
Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] avformat/dashenc: Addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-28 Thread

> On 27 Dec 2017, at 15:26, Steven Liu  wrote:
> 
> 2017-12-26 19:11 GMT+08:00 Karthick J :
>> From: Karthick Jeyapal 
>> 
>> This is required for AV playout from master.m3u8.
>> Otherwise master.m3u8 lists only video-only and/or audio-only streams.
>> ---
>> libavformat/dashenc.c | 24 ++--
>> 1 file changed, 22 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index 478a384..a3eb522 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -737,6 +737,9 @@ static int write_manifest(AVFormatContext *s, int final)
>> 
>> if (c->hls_playlist && !c->master_playlist_created) {
>> char filename_hls[1024];
>> +const char *audio_group = "A1";
>> +int is_default = 1;
>> +int max_audio_bitrate = 0;
>> 
>> if (*c->dirname)
>> snprintf(filename_hls, sizeof(filename_hls), "%s/master.m3u8", 
>> c->dirname);
>> @@ -758,9 +761,26 @@ static int write_manifest(AVFormatContext *s, int final)
>> for (i = 0; i < s->nb_streams; i++) {
>> char playlist_file[64];
>> AVStream *st = s->streams[i];
>> +if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
>> +continue;
>> +get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
>> NULL, i);
>> +ff_hls_write_audio_rendition(out, (char *)audio_group,
>> + playlist_file, i, is_default);
>> +max_audio_bitrate = FFMAX(st->codecpar->bit_rate, 
>> max_audio_bitrate);
>> +is_default = 0;
>> +}
>> +
>> +for (i = 0; i < s->nb_streams; i++) {
>> +char playlist_file[64];
>> +AVStream *st = s->streams[i];
>> +char *agroup = NULL;
>> +int stream_bitrate = st->codecpar->bit_rate;
>> +if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && 
>> max_audio_bitrate) {
>> +agroup = (char *)audio_group;
>> +stream_bitrate += max_audio_bitrate;
>> +}
>> get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
>> NULL, i);
>> -ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
>> -playlist_file, NULL);
>> +ff_hls_write_stream_info(st, out, stream_bitrate, 
>> playlist_file, agroup);
>> }
>> avio_close(out);
>> if (use_rename)
>> --
>> 1.9.1
>> 
> 
> Patchset LGTM

Pushed

Thanks

Steven
> 
> 
> Thanks
> 
> Steven
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Add CODECS attribute to master playlist

2017-12-28 Thread

> On 28 Dec 2017, at 19:19, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> ---
> libavformat/dashenc.c |  2 +-
> libavformat/hlsenc.c  | 67 ++-
> libavformat/hlsplaylist.c |  5 +++-
> libavformat/hlsplaylist.h |  3 ++-
> 4 files changed, 73 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 478a384..8797959 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -760,7 +760,7 @@ static int write_manifest(AVFormatContext *s, int final)
> AVStream *st = s->streams[i];
> get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
> i);
> ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
> -playlist_file, NULL);
> +playlist_file, NULL, NULL);
> }
> avio_close(out);
> if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 74f66ce..1a84799 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -58,6 +58,11 @@ typedef enum {
>   HLS_START_SEQUENCE_AS_FORMATTED_DATETIME = 2,  // MMDDhhmmss
> } StartSequenceSourceType;
> 
> +typedef enum {
> +CODEC_ATTRIBUTE_WRITTEN = 0,
> +CODEC_ATTRIBUTE_WILL_NOT_BE_WRITTEN,
> +} CodecAttributeStatus;
> +
> #define KEYSIZE 16
> #define LINE_BUFFER_SIZE 1024
> #define HLS_MICROSECOND_UNIT   100
> @@ -142,6 +147,8 @@ typedef struct VariantStream {
> int fmp4_init_mode;
> 
> AVStream **streams;
> +char codec_attr[128];
> +CodecAttributeStatus attr_status;
> unsigned int nb_streams;
> int m3u8_created; /* status of media play-list creation */
> char *agroup; /* audio group name */
> @@ -296,6 +303,51 @@ static void set_http_options(AVFormatContext *s, 
> AVDictionary **options, HLSCont
> 
> }
> 
> +static void write_codec_attr(AVStream *st, VariantStream *vs) {
> +int codec_strlen = strlen(vs->codec_attr);
> +char attr[32];
> +
> +if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
> +return;
> +if (vs->attr_status == CODEC_ATTRIBUTE_WILL_NOT_BE_WRITTEN)
> +return;
> +
> +if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
> +uint8_t *data = st->codecpar->extradata;
> +if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 
> 0x1F) == 7) {
> +snprintf(attr, sizeof(attr),
> + "avc1.%02x%02x%02x", data[5], data[6], data[7]);
> +} else {
> +goto fail;
> +}
> +} else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
> +snprintf(attr, sizeof(attr), "mp4a.40.33");
> +} else if (st->codecpar->codec_id == AV_CODEC_ID_MP3) {
> +snprintf(attr, sizeof(attr), "mp4a.40.34");
> +} else if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
> +/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set to 5 
> and 29 respectively */
> +snprintf(attr, sizeof(attr), "mp4a.40.2");
> +} else if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
> +snprintf(attr, sizeof(attr), "ac-3");
> +} else if (st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
> +snprintf(attr, sizeof(attr), "ec-3");
> +} else {
> +goto fail;
> +}
> +// Don't write the same attribute multiple times
> +if (!strstr(vs->codec_attr, attr)) {
Is this use av_stristr?

> +snprintf(vs->codec_attr + codec_strlen,
> + sizeof(vs->codec_attr) - codec_strlen,
> + "%s%s", codec_strlen ? "," : "", attr);
> +}
> +return;
> +
> +fail:
> +vs->codec_attr[0] = '\0';
> +vs->attr_status = CODEC_ATTRIBUTE_WILL_NOT_BE_WRITTEN;
> +return;
> +}
> +
> static int replace_int_data_in_filename(char *buf, int buf_size, const char 
> *filename, char placeholder, int64_t number)
> {
> const char *p;
> @@ -1235,7 +1287,7 @@ static int create_master_playlist(AVFormatContext *s,
> bandwidth += bandwidth / 10;
> 
> ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
> m3u8_rel_name,
> -aud_st ? vs->agroup : NULL);
> +aud_st ? vs->agroup : NULL, vs->codec_attr);
> 
> av_freep(_rel_name);
> }
> @@ -1764,6 +1816,19 @@ static int hls_write_header(AVFormatContext *s)
> continue;
> }
> avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, 
> inner_st->time_base.num, inner_st->time_base.den);
> +write_codec_attr(outer_st, vs);
> +
> +}
> +/* Update the Codec Attr string for the mapped audio groups */
> +if (vs->has_video && vs->agroup) {
> +for (j = 0; j < hls->nb_varstreams; j++) {
> +VariantStream *vs_agroup = &(hls->var_streams[j]);
> +if (!vs_agroup->has_video && !vs_agroup->has_subtitle &&
> +vs_agroup->agroup &&
> +

Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL

2017-12-27 Thread

> On 28 Dec 2017, at 07:04, Michael Niedermayer  wrote:
> 
> On Mon, Nov 20, 2017 at 03:58:59PM +0800, Steven Liu wrote:
>> fix ticket id: #6846
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavformat/avio.c | 10 ++
>> 1 file changed, 6 insertions(+), 4 deletions(-)
> 
> LGTM
> 
> thx


Pushed

Thanks
Steven
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Rewriting code that is poorly written but fully understood is good.
> Rewriting code that one doesnt understand is a sign that one is less smart
> then the original author, trying to rewrite it will not make it better.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/hlsenc: configurable variant stream index position in filenames

2017-12-26 Thread


> On 27 Dec 2017, at 11:43, Vishwanath Dixit <vdi...@akamai.com> wrote:
> 
> 
> 
> On 12/26/17 4:29 PM, 刘歧 wrote:
>> 
>>> On 26 Dec 2017, at 18:38, Vishwanath Dixit <vdi...@akamai.com> wrote:
>>> 
>>> 
>>> 
>>> On 12/26/17 3:37 PM, 刘歧 wrote:
>>>>> On 26 Dec 2017, at 17:53, vdi...@akamai.com wrote:
>>>>> 
>>>>> From: Vishwanath Dixit <vdi...@akamai.com>
>>>>> 
>>>>> ---
>>>>> doc/muxers.texi  |  31 +--
>>>>> libavformat/hlsenc.c | 153 
>>>>> ++-
>>>>> 2 files changed, 127 insertions(+), 57 deletions(-)
>>>>> 
>>>>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>>>>> index 93db549..6af970d 100644
>>>>> --- a/doc/muxers.texi
>>>>> +++ b/doc/muxers.texi
>>>>> @@ -575,6 +575,17 @@ Should a relative path be specified, the path of the 
>>>>> created segment
>>>>> files will be relative to the current working directory.
>>>>> When use_localtime_mkdir is set, the whole expanded value of 
>>>>> @var{filename} will be written into the m3u8 segment list.
>>>>> 
>>>>> +When @code{var_stream_map} is set with two or more variant streams, the
>>>>> +@var{filename} pattern must contain the string "%v", this string 
>>>>> specifies
>>>>> +the position of variant stream index in the generated segment file names.
>>>>> +@example
>>>>> +ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
>>>>> +  -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
>>>>> v:1,a:1" \
>>>>> +  -hls_segment_filename 'file_%v_%03d.ts' out_%v.m3u8
>>>>> +@end example
>>>>> +This example will produce the playlists segment file sets:
>>>>> +@file{file_0_000.ts}, @file{file_0_001.ts}, @file{file_0_002.ts}, etc. 
>>>>> and
>>>>> +@file{file_1_000.ts}, @file{file_1_001.ts}, @file{file_1_002.ts}, etc.
>>>>> 
>>>>> @item use_localtime
>>>>> Use strftime() on @var{filename} to expand the segment filename with 
>>>>> localtime.
>>>>> @@ -701,6 +712,10 @@ the fmp4 files is used in hls after version 7.
>>>>> @item hls_fmp4_init_filename @var{filename}
>>>>> set filename to the fragment files header file, default filename is 
>>>>> @file{init.mp4}.
>>>>> 
>>>>> +When @code{var_stream_map} is set with two or more variant streams, the
>>>>> +@var{filename} pattern must contain the string "%v", this string 
>>>>> specifies
>>>>> +the position of variant stream index in the generated init file names.
>>>>> +
>>>>> @item hls_flags @var{flags}
>>>>> Possible values:
>>>>> 
>>>>> @@ -814,32 +829,36 @@ Expected string format is like this "a:0,v:0 
>>>>> a:1,v:1 ". Here a:, v:, s: are
>>>>> the keys to specify audio, video and subtitle streams respectively.
>>>>> Allowed values are 0 to 9 (limited just based on practical usage).
>>>>> 
>>>>> +When there are two or more variant streams, the output filename pattern 
>>>>> must
>>>>> +contain the string "%v", this string specifies the position of variant 
>>>>> stream
>>>>> +index in the output media playlist filenames.
>>>>> +
>>>>> @example
>>>>> ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
>>>>>   -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
>>>>> v:1,a:1" \
>>>>> -  http://example.com/live/out.m3u8
>>>>> +  http://example.com/live/out_%v.m3u8
>>>>> @end example
>>>>> This example creates two hls variant streams. The first variant stream 
>>>>> will
>>>>> contain video stream of bitrate 1000k and audio stream of bitrate 64k and 
>>>>> the
>>>>> second variant stream will contain video stream of bitrate 256k and audio
>>>>> -stream of bitrate 32k. Here, two media playlist with file names 
>>>>> out_1.m3u8 and
>>>>> -out_2.m3u8 will be created.
>>>>> +stream of bitrate 32k. Here, two media

Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/hlsenc: configurable variant stream index position in filenames

2017-12-26 Thread


> On 26 Dec 2017, at 18:38, Vishwanath Dixit <vdi...@akamai.com> wrote:
> 
> 
> 
> On 12/26/17 3:37 PM, 刘歧 wrote:
>>> On 26 Dec 2017, at 17:53, vdi...@akamai.com wrote:
>>> 
>>> From: Vishwanath Dixit <vdi...@akamai.com>
>>> 
>>> ---
>>> doc/muxers.texi  |  31 +--
>>> libavformat/hlsenc.c | 153 
>>> ++-
>>> 2 files changed, 127 insertions(+), 57 deletions(-)
>>> 
>>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>>> index 93db549..6af970d 100644
>>> --- a/doc/muxers.texi
>>> +++ b/doc/muxers.texi
>>> @@ -575,6 +575,17 @@ Should a relative path be specified, the path of the 
>>> created segment
>>> files will be relative to the current working directory.
>>> When use_localtime_mkdir is set, the whole expanded value of @var{filename} 
>>> will be written into the m3u8 segment list.
>>> 
>>> +When @code{var_stream_map} is set with two or more variant streams, the
>>> +@var{filename} pattern must contain the string "%v", this string specifies
>>> +the position of variant stream index in the generated segment file names.
>>> +@example
>>> +ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
>>> +  -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
>>> v:1,a:1" \
>>> +  -hls_segment_filename 'file_%v_%03d.ts' out_%v.m3u8
>>> +@end example
>>> +This example will produce the playlists segment file sets:
>>> +@file{file_0_000.ts}, @file{file_0_001.ts}, @file{file_0_002.ts}, etc. and
>>> +@file{file_1_000.ts}, @file{file_1_001.ts}, @file{file_1_002.ts}, etc.
>>> 
>>> @item use_localtime
>>> Use strftime() on @var{filename} to expand the segment filename with 
>>> localtime.
>>> @@ -701,6 +712,10 @@ the fmp4 files is used in hls after version 7.
>>> @item hls_fmp4_init_filename @var{filename}
>>> set filename to the fragment files header file, default filename is 
>>> @file{init.mp4}.
>>> 
>>> +When @code{var_stream_map} is set with two or more variant streams, the
>>> +@var{filename} pattern must contain the string "%v", this string specifies
>>> +the position of variant stream index in the generated init file names.
>>> +
>>> @item hls_flags @var{flags}
>>> Possible values:
>>> 
>>> @@ -814,32 +829,36 @@ Expected string format is like this "a:0,v:0 a:1,v:1 
>>> ". Here a:, v:, s: are
>>> the keys to specify audio, video and subtitle streams respectively.
>>> Allowed values are 0 to 9 (limited just based on practical usage).
>>> 
>>> +When there are two or more variant streams, the output filename pattern 
>>> must
>>> +contain the string "%v", this string specifies the position of variant 
>>> stream
>>> +index in the output media playlist filenames.
>>> +
>>> @example
>>> ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
>>>   -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
>>> v:1,a:1" \
>>> -  http://example.com/live/out.m3u8
>>> +  http://example.com/live/out_%v.m3u8
>>> @end example
>>> This example creates two hls variant streams. The first variant stream will
>>> contain video stream of bitrate 1000k and audio stream of bitrate 64k and 
>>> the
>>> second variant stream will contain video stream of bitrate 256k and audio
>>> -stream of bitrate 32k. Here, two media playlist with file names out_1.m3u8 
>>> and
>>> -out_2.m3u8 will be created.
>>> +stream of bitrate 32k. Here, two media playlist with file names out_0.m3u8 
>>> and
>>> +out_1.m3u8 will be created.
>>> @example
>>> ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k \
>>>   -map 0:v -map 0:a -map 0:v -f hls -var_stream_map "v:0 a:0 v:1" \
>>> -  http://example.com/live/out.m3u8
>>> +  http://example.com/live/out_%v.m3u8
>>> @end example
>>> This example creates three hls variant streams. The first variant stream 
>>> will
>>> be a video only stream with video bitrate 1000k, the second variant stream 
>>> will
>>> be an audio only stream with bitrate 64k and the third variant stream will 
>>> be a
>>> video only stream with bitrate 256k. Here, three media playlist with file 
>>> names
>>> -out_1.m3u8, out_2.

Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/hlsenc: configurable variant stream index position in filenames

2017-12-26 Thread

> On 26 Dec 2017, at 17:53, vdi...@akamai.com wrote:
> 
> From: Vishwanath Dixit 
> 
> ---
> doc/muxers.texi  |  31 +--
> libavformat/hlsenc.c | 153 ++-
> 2 files changed, 127 insertions(+), 57 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 93db549..6af970d 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -575,6 +575,17 @@ Should a relative path be specified, the path of the 
> created segment
> files will be relative to the current working directory.
> When use_localtime_mkdir is set, the whole expanded value of @var{filename} 
> will be written into the m3u8 segment list.
> 
> +When @code{var_stream_map} is set with two or more variant streams, the
> +@var{filename} pattern must contain the string "%v", this string specifies
> +the position of variant stream index in the generated segment file names.
> +@example
> +ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
> +  -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
> v:1,a:1" \
> +  -hls_segment_filename 'file_%v_%03d.ts' out_%v.m3u8
> +@end example
> +This example will produce the playlists segment file sets:
> +@file{file_0_000.ts}, @file{file_0_001.ts}, @file{file_0_002.ts}, etc. and
> +@file{file_1_000.ts}, @file{file_1_001.ts}, @file{file_1_002.ts}, etc.
> 
> @item use_localtime
> Use strftime() on @var{filename} to expand the segment filename with 
> localtime.
> @@ -701,6 +712,10 @@ the fmp4 files is used in hls after version 7.
> @item hls_fmp4_init_filename @var{filename}
> set filename to the fragment files header file, default filename is 
> @file{init.mp4}.
> 
> +When @code{var_stream_map} is set with two or more variant streams, the
> +@var{filename} pattern must contain the string "%v", this string specifies
> +the position of variant stream index in the generated init file names.
> +
> @item hls_flags @var{flags}
> Possible values:
> 
> @@ -814,32 +829,36 @@ Expected string format is like this "a:0,v:0 a:1,v:1 
> ". Here a:, v:, s: are
> the keys to specify audio, video and subtitle streams respectively.
> Allowed values are 0 to 9 (limited just based on practical usage).
> 
> +When there are two or more variant streams, the output filename pattern must
> +contain the string "%v", this string specifies the position of variant stream
> +index in the output media playlist filenames.
> +
> @example
> ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
>   -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
> v:1,a:1" \
> -  http://example.com/live/out.m3u8
> +  http://example.com/live/out_%v.m3u8
> @end example
> This example creates two hls variant streams. The first variant stream will
> contain video stream of bitrate 1000k and audio stream of bitrate 64k and the
> second variant stream will contain video stream of bitrate 256k and audio
> -stream of bitrate 32k. Here, two media playlist with file names out_1.m3u8 
> and
> -out_2.m3u8 will be created.
> +stream of bitrate 32k. Here, two media playlist with file names out_0.m3u8 
> and
> +out_1.m3u8 will be created.
> @example
> ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k \
>   -map 0:v -map 0:a -map 0:v -f hls -var_stream_map "v:0 a:0 v:1" \
> -  http://example.com/live/out.m3u8
> +  http://example.com/live/out_%v.m3u8
> @end example
> This example creates three hls variant streams. The first variant stream will
> be a video only stream with video bitrate 1000k, the second variant stream 
> will
> be an audio only stream with bitrate 64k and the third variant stream will be 
> a
> video only stream with bitrate 256k. Here, three media playlist with file 
> names
> -out_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
> +out_0.m3u8, out_1.m3u8 and out_2.m3u8 will be created.
> @example
> ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k  \
>   -map 0:a -map 0:a -map 0:v -map 0:v -f hls \
>   -var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high v:0,agroup:aud_low 
> v:1,agroup:aud_high" \
>   -master_pl_name master.m3u8 \
> -  http://example.com/live/out.m3u8
> +  http://example.com/live/out_%v.m3u8
> @end example
> This example creates two audio only and two video only variant streams. In
> addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index bd43336..76a4110 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1536,7 +1536,7 @@ static const char * 
> get_default_pattern_localtime_fmt(AVFormatContext *s)
> return (HAVE_LIBC_MSVCRT || !strftime(b, sizeof(b), "%s", p) || 
> !strcmp(b, "%s")) ? "-%Y%m%d%H%M%S.ts" : "-%s.ts";
> }
> 
> -static int format_name(char *name, int name_buf_len, int i)
> +static int append_postfix(char *name, int name_buf_len, int i)
> {
> char *p;
> char extension[10] = {'\0'};
> @@ -1555,6 +1555,53 @@ static int 

Re: [FFmpeg-devel] [PATCH v8 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-22 Thread


> On 22 Dec 2017, at 19:05, Dixit, Vishwanath <vdi...@akamai.com> wrote:
> 
> On 12/19/17 11:53 AM, 刘歧 wrote:
>> On 19 Dec 2017, at 14:09, vdi...@akamai.com wrote:
>>> From: Vishwanath Dixit <vdi...@akamai.com>
>>> 
>>> ---
>>> doc/muxers.texi   | 12 +
>>> libavformat/dashenc.c |  3 ++-
>>> libavformat/hlsenc.c  | 64 
>>> ---
>>> libavformat/hlsplaylist.c |  4 ++-
>>> libavformat/hlsplaylist.h |  2 +-
>>> 5 files changed, 79 insertions(+), 6 deletions(-)
>>> 
>>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>>> index 3d0c7bf..93db549 100644
>>> --- a/doc/muxers.texi
>>> +++ b/doc/muxers.texi
>>> @@ -834,6 +834,18 @@ be a video only stream with video bitrate 1000k, the 
>>> second variant stream will
>>> be an audio only stream with bitrate 64k and the third variant stream will 
>>> be a
>>> video only stream with bitrate 256k. Here, three media playlist with file 
>>> names
>>> out_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
>>> +@example
>>> +ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k  \
>>> +  -map 0:a -map 0:a -map 0:v -map 0:v -f hls \
>>> +  -var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high 
>>> v:0,agroup:aud_low v:1,agroup:aud_high" \
>>> +  -master_pl_name master.m3u8 \
>>> +  http://example.com/live/out.m3u8
>>> +@end example
>>> +This example creates two audio only and two video only variant streams. In
>>> +addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
>>> +playlist, #EXT-X-MEDIA tag is also added for the two audio only variant 
>>> streams
>>> +and they are mapped to the two video only variant streams with audio group 
>>> names
>>> +'aud_low' and 'aud_high'.
>>> 
>>> By default, a single hls variant containing all the encoded streams is 
>>> created.
>>> 
>>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>>> index 5687530..f363418 100644
>>> --- a/libavformat/dashenc.c
>>> +++ b/libavformat/dashenc.c
>>> @@ -759,7 +759,8 @@ static int write_manifest(AVFormatContext *s, int final)
>>>char playlist_file[64];
>>>AVStream *st = s->streams[i];
>>>get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
>>> NULL, i);
>>> -ff_hls_write_stream_info(st, out, st->codecpar->bit_rate, 
>>> playlist_file);
>>> +ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
>>> +playlist_file, NULL);
>>>}
>>>avio_close(out);
>>>if (use_rename)
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index e3442c3..53dc835 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -144,6 +144,7 @@ typedef struct VariantStream {
>>>AVStream **streams;
>>>unsigned int nb_streams;
>>>int m3u8_created; /* status of media play-list creation */
>>> +char *agroup; /* audio group name */
>>>char *baseurl;
>>> } VariantStream;
>>> 
>>> @@ -1085,7 +1086,7 @@ static int create_master_playlist(AVFormatContext *s,
>>>  VariantStream * const input_vs)
>>> {
>>>HLSContext *hls = s->priv_data;
>>> -VariantStream *vs;
>>> +VariantStream *vs, *temp_vs;
>>>AVStream *vid_st, *aud_st;
>>>AVDictionary *options = NULL;
>>>unsigned int i, j;
>>> @@ -1117,6 +1118,34 @@ static int create_master_playlist(AVFormatContext *s,
>>> 
>>>ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
>>> 
>>> +/* For audio only variant streams add #EXT-X-MEDIA tag with 
>>> attributes*/
>>> +for (i = 0; i < hls->nb_varstreams; i++) {
>>> +vs = &(hls->var_streams[i]);
>>> +
>>> +if (vs->has_video || vs->has_subtitle || !vs->agroup)
>>> +continue;
>>> +
>>> +m3u8_name_size = strlen(vs->m3u8_name) + 1;
>>> +m3u8_rel_name = av_malloc(m3u8_name_size);
>>> +if (!m3u8_rel_name) {
>>> +ret = AVERROR(ENOMEM);
>>> +goto fail;
>>> +}
>&

Re: [FFmpeg-devel] [PATCH 2/2] avformat/hlsenc: Signal http end of chunk explicitly during hlsenc_io_close()

2017-12-22 Thread

> On 22 Dec 2017, at 15:04, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> Currently http end of chunk is called implicitly in hlsenc_io_open().
> This mean playlists http writes would have to wait upto a segment duration to 
> signal end of chunk causing delays.
> This patch will fix that problem and improve performance.
> ---
> libavformat/hlsenc.c | 5 +
> 1 file changed, 5 insertions(+)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 0095ca4..65182c5 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -268,8 +268,13 @@ static void hlsenc_io_close(AVFormatContext *s, 
> AVIOContext **pb, char *filename
> 
> if (!http_base_proto || !hls->http_persistent || hls->key_info_file || 
> hls->encrypt) {
> ff_format_io_close(s, pb);
> +#if CONFIG_HTTP_PROTOCOL
> } else {
> +URLContext *http_url_context = ffio_geturlcontext(*pb);
> +av_assert0(http_url_context);
> avio_flush(*pb);
> +ff_http_signal_end_of_chunk(http_url_context);
> +#endif
> }
> }
> 
> -- 
> 1.9.1
> 

LGTM, if the libavformat/http no problem.


thanks

Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Fix a memory leak when http_persistent is 1

2017-12-20 Thread


> On 19 Dec 2017, at 16:49, 刘歧 <l...@chinaffmpeg.org> wrote:
> 
>> 
>> On 19 Dec 2017, at 14:58, Karthick J <kjeya...@akamai.com> wrote:
>> 
>> From: Karthick Jeyapal <kjeya...@akamai.com>
>> 
>> ---
>> libavformat/hlsenc.c | 2 ++
>> 1 file changed, 2 insertions(+)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index e3442c3..5ee28ea 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1918,6 +1918,8 @@ static int hls_write_trailer(struct AVFormatContext *s)
>>av_freep(>baseurl);
>>}
>> 
>> +ff_format_io_close(s, >m3u8_out);
>> +ff_format_io_close(s, >sub_m3u8_out);
>>av_freep(>key_basename);
>>av_freep(>var_streams);
>>av_freep(>master_m3u8_url);
>> -- 
>> 1.9.1
>> 
>> 
> 
> 
> LGTM
> 
> 

Pushed

Thanks



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/4] avformat/hlsenc: reindent after previous commits

2017-12-20 Thread


> On 19 Dec 2017, at 11:43, Karthick Jeyapal  wrote:
> 
> 
> 
> On 12/18/17 2:17 PM, Steven Liu wrote:
>> Signed-off-by: Steven Liu 
>> ---
>>  libavformat/hlsenc.c | 24 
>>  1 file changed, 12 insertions(+), 12 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index f51fec1030..0eebcb4462 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1806,14 +1806,14 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  if (!byterange_mode) {
>>  if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>>  if (!vs->init_range_length) {
>> -avio_flush(oc->pb);
>> -range_length = avio_close_dyn_buf(oc->pb, );
>> -avio_write(vs->out, buffer, range_length);
>> -vs->init_range_length = range_length;
>> -avio_open_dyn_buf(>pb);
>> -vs->packets_written = 0;
>> -ff_format_io_close(s, >out);
>> -hlsenc_io_close(s, >out, vs->base_output_dirname);
>> +avio_flush(oc->pb);
>> +range_length = avio_close_dyn_buf(oc->pb, );
>> +avio_write(vs->out, buffer, range_length);
>> +vs->init_range_length = range_length;
>> +avio_open_dyn_buf(>pb);
>> +vs->packets_written = 0;
>> +ff_format_io_close(s, >out);
>> +hlsenc_io_close(s, >out, vs->base_output_dirname);
>>  }
>>  } else {
>>  hlsenc_io_close(s, >pb, oc->filename);
>> @@ -1847,7 +1847,7 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  }
>>  ff_format_io_close(s, >out);
>>  }
>> -ret = hls_append_segment(s, hls, vs, vs->duration, 
>> vs->start_pos, vs->size);
>> +ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
>> vs->size);
>>  vs->start_pos = new_start_pos;
>>  if (ret < 0) {
>>  av_free(old_filename);
>> @@ -1932,7 +1932,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
>>  if (oc->pb) {
>>  vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
>>  if (hls->segment_type != SEGMENT_TYPE_FMP4)
>> -ff_format_io_close(s, >pb);
>> +ff_format_io_close(s, >pb);
>>if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
>>  hls_rename_temp_file(s, oc);
>> @@ -2292,8 +2292,8 @@ static int hls_init(AVFormatContext *s)
>>  }
>>  }
>>  -if ((ret = hls_start(s, vs)) < 0)
>> -goto fail;
>> +if ((ret = hls_start(s, vs)) < 0)
>> +goto fail;
>>  }
>>fail:
> LGTM

Pushed


Thanks

Steven
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] avformat/hlsenc: fix first fragment mp4 do not split bug

2017-12-20 Thread


> On 19 Dec 2017, at 11:51, 刘歧 <l...@chinaffmpeg.org> wrote:
> 
> 
> 
>> On 19 Dec 2017, at 11:42, Karthick Jeyapal <kjeya...@akamai.com> wrote:
>> 
>> 
>> 
>> On 12/18/17 2:17 PM, Steven Liu wrote:
>>> fix ticket id: 6888
>>> 
>>> Signed-off-by: Steven Liu <l...@chinaffmpeg.org>
>>> ---
>>> libavformat/hlsenc.c | 72 
>>> 
>>> 1 file changed, 62 insertions(+), 10 deletions(-)
>>> 
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index e3442c368f..f51fec1030 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -352,6 +352,29 @@ static void write_styp(AVIOContext *pb)
>>> ffio_wfourcc(pb, "msix");
>>> }
>>> +static int flush_dynbuf(VariantStream *vs, int *range_length)
>>> +{
>>> +AVFormatContext *ctx = vs->avf;
>>> +uint8_t *buffer;
>>> +
>>> +if (!ctx->pb) {
>>> +return AVERROR(EINVAL);
>>> +}
>>> +
>>> +// flush
>>> +av_write_frame(ctx, NULL);
>>> +avio_flush(ctx->pb);
>>> +
>>> +// write out to file
>>> +*range_length = avio_close_dyn_buf(ctx->pb, );
>>> +ctx->pb = NULL;
>>> +avio_write(vs->out, buffer, *range_length);
>>> +av_free(buffer);
>>> +
>>> +// re-open buffer
>>> +return avio_open_dyn_buf(>pb);
>>> +}
>>> +
>>> static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>>>VariantStream *vs) {
>>> @@ -677,7 +700,9 @@ static int hls_mux_init(AVFormatContext *s, 
>>> VariantStream *vs)
>>> if ((ret = avio_open_dyn_buf(>pb)) < 0)
>>> return ret;
>>> -if ((ret = s->io_open(s, >out, vs->base_output_dirname, 
>>> AVIO_FLAG_WRITE, )) < 0) {
>>> +ret = hlsenc_io_open(s, >out, vs->base_output_dirname, 
>>> );
>>> +av_dict_free();
>>> +if (ret < 0) {
>>> av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
>>> vs->fmp4_init_filename);
>>> return ret;
>>> }
>>> @@ -1404,9 +1429,10 @@ static int hls_start(AVFormatContext *s, 
>>> VariantStream *vs)
>>> av_dict_free();
>>> if (err < 0)
>>> return err;
>>> -} else
>>> +} else if (c->segment_type != SEGMENT_TYPE_FMP4) {
>>> if ((err = hlsenc_io_open(s, >pb, oc->filename, )) < 0)
>>> goto fail;
>>> +}
>>> if (vs->vtt_basename) {
>>> set_http_options(s, , c);
>>> if ((err = hlsenc_io_open(s, _oc->pb, vtt_oc->filename, 
>>> )) < 0)
>>> @@ -1414,9 +1440,7 @@ static int hls_start(AVFormatContext *s, 
>>> VariantStream *vs)
>>> }
>>> av_dict_free();
>>> -if (c->segment_type == SEGMENT_TYPE_FMP4 && !(c->flags & 
>>> HLS_SINGLE_FILE)) {
>>> -write_styp(oc->pb);
>>> -} else {
>>> +if (c->segment_type != SEGMENT_TYPE_FMP4) {
>>> /* We only require one PAT/PMT per segment. */
>>> if (oc->oformat->priv_class && oc->priv_data) {
>>> char period[21];
>>> @@ -1780,7 +1804,8 @@ static int hls_write_packet(AVFormatContext *s, 
>>> AVPacket *pkt)
>>> vs->size = new_start_pos - vs->start_pos;
>>>   if (!byterange_mode) {
>>> -if (hls->segment_type == SEGMENT_TYPE_FMP4 && 
>>> !vs->init_range_length) {
>>> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>>> +if (!vs->init_range_length) {
>>> avio_flush(oc->pb);
>>> range_length = avio_close_dyn_buf(oc->pb, );
>>> avio_write(vs->out, buffer, range_length);
>>> @@ -1789,6 +1814,7 @@ static int hls_write_packet(AVFormatContext *s, 
>>> AVPacket *pkt)
>>> vs->packets_written = 0;
>>> ff_format_io_close(s, >out);
>>> hlsenc_io_close(s, >out, vs->base_output_dirname);
>>> +}
>>> } else {
>>> h

Re: [FFmpeg-devel] [PATCH] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault) - Add function 'resolve_content_path' to propagate the baseURL from upper level nodes. * if no baseURL is av

2017-12-20 Thread

> On 21 Dec 2017, at 10:39, Colin NG  wrote:
> 
> ---
> libavformat/dashdec.c | 116 --
> 1 file changed, 103 insertions(+), 13 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 3798649..cdb9f67 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -148,6 +148,11 @@ static uint64_t get_current_time_in_sec(void)
> return  av_gettime() / 100;
> }
> 
> +static int ishttp(char *url) {
> +const char *proto_name = avio_find_protocol_name(url);
> +return av_strstart(proto_name, "http", NULL);
> +}
> +
> static uint64_t get_utc_date_time_insec(AVFormatContext *s, const char 
> *datetime)
> {
> struct tm timeinfo;
> @@ -392,7 +397,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
> const char *url,
> else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
> return AVERROR_INVALIDDATA;
> 
> -ret = s->io_open(s, pb, url, AVIO_FLAG_READ, );
> +av_freep(pb);
> +ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, );
> +
> if (ret >= 0) {
> // update cookies on http response with setcookies.
> char *new_cookies = NULL;
> @@ -639,6 +646,91 @@ static int 
> parse_manifest_segmenttimeline(AVFormatContext *s, struct representat
> return 0;
> }
> 
> +static int resolve_content_path(AVFormatContext *s, const char *url,  
> xmlNodePtr *baseurl_nodes,  int n_baseurl_nodes) {
> +
> +char *tmp_str = av_mallocz(MAX_URL_SIZE);
> +char *tmp_str_2= av_mallocz(MAX_URL_SIZE);
> +char *path = av_mallocz(MAX_URL_SIZE);
> +char *mpdName = NULL;
> +xmlNodePtr  node = NULL;
> +char *baseurl = NULL;
> +char *root_url = NULL;
> +char *text = NULL;
> +
> +int isRootHttp = 0;
> +char token ='/';
> +int start =  0;
> +int rootId = 0;
> +int updated = 0;
> +int size = 0;
> +int i;
> +
> +if (!tmp_str || !tmp_str_2 || !path) {
> +updated = AVERROR(ENOMEM);
> +goto end;
> +}
> +
> +av_strlcpy(tmp_str, url, strlen(url)+1);
space code style
> +mpdName = strtok (tmp_str," /");
> +
> +while ((mpdName =strtok (NULL, "/"))) {
> +size = strlen(mpdName);
> +}
> +
> +av_strlcpy (path, url, strlen(url)-size+1);
strlen(url) -  size + 1;  *space code style*,
> +
> +for (rootId = n_baseurl_nodes-1; rootId >0; rootId--) {
> +if (!(node = baseurl_nodes[rootId])) {
> +continue;
> +}
> +if (ishttp(xmlNodeGetContent(node))) {
> +break;
> +}
> +}
> +
> +node = baseurl_nodes[rootId];
> +baseurl = xmlNodeGetContent(node);
> +root_url = (!av_strcasecmp(baseurl, ""))? path: baseurl;
root_url = av_strcasecmp(baseurl, “") ? baseurl : path;

> +
> +if (node) {
> +xmlNodeSetContent(node, root_url);
> +}
> +
> +size = strlen(root_url);
> +isRootHttp= ishttp(root_url);
> +
> +if (root_url[size-1]==token) {

if (root_url[size - 1] == token) {

> +av_strlcat(root_url, "/", size+2);
> +size+=2;
av_strlcat(root_url, “/“, size + 2);
size += 2;

> +}
> +
> +for (i = 0; i < n_baseurl_nodes; ++i) {
> +if (i==rootId) {
i == rootId

> +continue;
> +}
> +text = xmlNodeGetContent(baseurl_nodes[i]);
> +if (text) {
> +memset(tmp_str, 0, strlen(tmp_str));
this line maybe no need, because you have use av_mallocz, that can memset the 
tmp_str to 0;

> +
> +if (!ishttp(text) && isRootHttp) {
> +av_strlcpy(tmp_str, root_url, size+1);
> +}
> +start = (text[0]==token) ? 1: 0;
> +memset(tmp_str_2, 0, strlen(tmp_str_2));
ditto.

> +av_strlcat(tmp_str, text+start, MAX_URL_SIZE);
> +xmlNodeSetContent(baseurl_nodes[i], tmp_str);
> +updated = 1;
> +xmlFree(text);
> +}
> +}
> +
> +end:
> +av_free(path);
> +av_free(tmp_str);
> +av_free(tmp_str_2);
> +return updated;
> +
> +}
> static int parse_manifest_representation(AVFormatContext *s, const char *url,
>  xmlNodePtr node,
>  xmlNodePtr adaptionset_node,
> @@ -698,6 +790,12 @@ static int parse_manifest_representation(AVFormatContext 
> *s, const char *url,
> baseurl_nodes[2] = adaptionset_baseurl_node;
> baseurl_nodes[3] = representation_baseurl_node;
> 
> +ret = resolve_content_path(s, url, baseurl_nodes, 4);
> +
> +if (ret == AVERROR(ENOMEM) || ret == 0) {
can this use if (ret <= 0) { ?
> +goto end;
> +}
> +
> if (representation_segmenttemplate_node || fragment_template_node) {
> fragment_timeline_node = NULL;
> fragment_templates_tab[0] = representation_segmenttemplate_node;
> @@ -993,6 +1091,9 @@ static int parse_manifest(AVFormatContext 

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Fix a memory leak when http_persistent is 1

2017-12-19 Thread

> On 19 Dec 2017, at 14:58, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> ---
> libavformat/hlsenc.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e3442c3..5ee28ea 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1918,6 +1918,8 @@ static int hls_write_trailer(struct AVFormatContext *s)
> av_freep(>baseurl);
> }
> 
> +ff_format_io_close(s, >m3u8_out);
> +ff_format_io_close(s, >sub_m3u8_out);
> av_freep(>key_basename);
> av_freep(>var_streams);
> av_freep(>master_m3u8_url);
> -- 
> 1.9.1
> 
> 


LGTM

Thanks

Steven

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: give a debug message if attrs unsupported.

2017-12-18 Thread

> On 19 Dec 2017, at 14:25, Jun Zhao  wrote:
> 
> <0001-lavc-vaapi_encode-give-a-debug-message-if-attrs-unsu.patch>

I saw you using AV_LOG_DEBUG, What about use AV_LOG_WARNING? Because that 
message is tell user attrs unsupported.

Thanks



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v8 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-18 Thread
On 19 Dec 2017, at 14:09, vdi...@akamai.com wrote:
> 
> From: Vishwanath Dixit 
> 
> ---
> doc/muxers.texi   | 12 +
> libavformat/dashenc.c |  3 ++-
> libavformat/hlsenc.c  | 64 ---
> libavformat/hlsplaylist.c |  4 ++-
> libavformat/hlsplaylist.h |  2 +-
> 5 files changed, 79 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 3d0c7bf..93db549 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -834,6 +834,18 @@ be a video only stream with video bitrate 1000k, the 
> second variant stream will
> be an audio only stream with bitrate 64k and the third variant stream will be 
> a
> video only stream with bitrate 256k. Here, three media playlist with file 
> names
> out_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
> +@example
> +ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k  \
> +  -map 0:a -map 0:a -map 0:v -map 0:v -f hls \
> +  -var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high v:0,agroup:aud_low 
> v:1,agroup:aud_high" \
> +  -master_pl_name master.m3u8 \
> +  http://example.com/live/out.m3u8
> +@end example
> +This example creates two audio only and two video only variant streams. In
> +addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
> +playlist, #EXT-X-MEDIA tag is also added for the two audio only variant 
> streams
> +and they are mapped to the two video only variant streams with audio group 
> names
> +'aud_low' and 'aud_high'.
> 
> By default, a single hls variant containing all the encoded streams is 
> created.
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 5687530..f363418 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -759,7 +759,8 @@ static int write_manifest(AVFormatContext *s, int final)
>char playlist_file[64];
>AVStream *st = s->streams[i];
>get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
> i);
> -ff_hls_write_stream_info(st, out, st->codecpar->bit_rate, 
> playlist_file);
> +ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
> +playlist_file, NULL);
>}
>avio_close(out);
>if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e3442c3..53dc835 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -144,6 +144,7 @@ typedef struct VariantStream {
>AVStream **streams;
>unsigned int nb_streams;
>int m3u8_created; /* status of media play-list creation */
> +char *agroup; /* audio group name */
>char *baseurl;
> } VariantStream;
> 
> @@ -1085,7 +1086,7 @@ static int create_master_playlist(AVFormatContext *s,
>  VariantStream * const input_vs)
> {
>HLSContext *hls = s->priv_data;
> -VariantStream *vs;
> +VariantStream *vs, *temp_vs;
>AVStream *vid_st, *aud_st;
>AVDictionary *options = NULL;
>unsigned int i, j;
> @@ -1117,6 +1118,34 @@ static int create_master_playlist(AVFormatContext *s,
> 
>ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
> 
> +/* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/
> +for (i = 0; i < hls->nb_varstreams; i++) {
> +vs = &(hls->var_streams[i]);
> +
> +if (vs->has_video || vs->has_subtitle || !vs->agroup)
> +continue;
> +
> +m3u8_name_size = strlen(vs->m3u8_name) + 1;
> +m3u8_rel_name = av_malloc(m3u8_name_size);
> +if (!m3u8_rel_name) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
> +ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
> +   m3u8_rel_name, m3u8_name_size);
> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
> +goto fail;
> +}
> +
> +avio_printf(hls->m3u8_out, 
> "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
> +vs->agroup);
> +avio_printf(hls->m3u8_out, 
> ",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
> +m3u8_rel_name);
> +av_freep(_rel_name);
> +}
> +
>/* For variant streams with video add #EXT-X-STREAM-INF tag with 
> attributes*/
>for (i = 0; i < hls->nb_varstreams; i++) {
>vs = &(hls->var_streams[i]);
> @@ -1149,6 +1178,25 @@ static int create_master_playlist(AVFormatContext *s,
>continue;
>}
> 
> +/**
> + * Traverse through the list of audio only rendition streams and find
> + * the rendition which has highest bitrate in the same audio group
> + */
> +if (vs->agroup) {
> +for (j = 0; j < hls->nb_varstreams; j++) {
> +temp_vs = &(hls->var_streams[j]);
> +if (!temp_vs->has_video && 

Re: [FFmpeg-devel] [PATCH 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread


> On 19 Dec 2017, at 12:11, Karthick Jeyapal <kjeya...@akamai.com> wrote:
> 
> 
> 
> On 12/19/17 9:29 AM, 刘歧 wrote:
>> 
>>> On 19 Dec 2017, at 11:55, Karthick Jeyapal <kjeya...@akamai.com> wrote:
>>> 
>>> 
>>> 
>>> On 12/18/17 2:17 PM, Steven Liu wrote:
>>>> Signed-off-by: Steven Liu <l...@chinaffmpeg.org>
>>>> ---
>>>>  libavformat/hlsenc.c | 23 ---
>>>>  1 file changed, 12 insertions(+), 11 deletions(-)
>>>> 
>>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>>> index 0eebcb4462..0cb75ff198 100644
>>>> --- a/libavformat/hlsenc.c
>>>> +++ b/libavformat/hlsenc.c
>>>> @@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>>>> HLSContext *hls,
>>>>  av_dict_set(, "method", "DELETE", 0);
>>>>  if ((ret = vs->avf->io_open(vs->avf, , path, 
>>>> AVIO_FLAG_WRITE, )) < 0)
>>>>  goto fail;
>>>> -ff_format_io_close(vs->avf, );
>>>> +hlsenc_io_close(vs->avf, , path);
>>> Will not actually close, when http_persistent is 1. I think it is better to 
>>> leave this as ff_format_io_close
>>>>  } else if (unlink(path) < 0) {
>>>>  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
>>>> %s\n",
>>>>   path, strerror(errno));
>>>> @@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>>>> HLSContext *hls,
>>>>  av_free(sub_path);
>>>>  goto fail;
>>>>  }
>>>> -ff_format_io_close(vs->avf, );
>>>> +hlsenc_io_close(vs->avf, , sub_path);
>>> Will not actually close, when http_persistent is 1.
>>>>  } else if (unlink(sub_path) < 0) {
>>>>  av_log(hls, AV_LOG_ERROR, "failed to delete old segment 
>>>> %s: %s\n",
>>>>   sub_path, strerror(errno));
>>>> @@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, 
>>>> VariantStream *vs)
>>>>  }
>>>>ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
>>>> -if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, 
>>>> NULL)) < 0)
>>>> -return ret;
>>>> +ret = hlsenc_io_open(s, , hls->key_file, NULL);
>>> We needn't call hlsenc_io_open if we are not planning to use a persistent 
>>> connection for it. In this case pb is uninitialized and hlsenc_io_open will 
>>> most probably cause a crash or undefined behavior. You can get around that 
>>> issue by initializing pb to NULL. But I think that is unnecessary and are 
>>> better placed with s->io_open().
>>>> +if (ret < 0) {
>>>> +return ret;;
>>> Extra semicolon
>>>> +}
>>>>  avio_seek(pb, 0, SEEK_CUR);
>>>>  avio_write(pb, key, KEYSIZE);
>>>>  avio_close(pb);
>>>> @@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
>>>>  ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
>>>>  hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
>>>>  -ff_format_io_close(s, );
>>>> +hlsenc_io_close(s, , hls->key_info_file);
>>>>if (!*hls->key_uri) {
>>>>  av_log(hls, AV_LOG_ERROR, "no key URI specified in key info 
>>>> file\n");
>>>> @@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
>>>>  }
>>>>ret = avio_read(pb, key, sizeof(key));
>>>> -ff_format_io_close(s, );
>>>> +hlsenc_io_close(s, , hls->key_file);
>>> Will not actually close, when http_persistent is 1.
>>>>  if (ret != sizeof(key)) {
>>>>  av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
>>>> hls->key_file);
>>>>  if (ret >= 0 || ret == AVERROR_EOF)
>>>> @@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, 
>>>> AVPacket *pkt)
>>>>  vs->init_range_length

Re: [FFmpeg-devel] [PATCH 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread


> On 19 Dec 2017, at 11:55, Karthick Jeyapal  wrote:
> 
> 
> 
> On 12/18/17 2:17 PM, Steven Liu wrote:
>> Signed-off-by: Steven Liu 
>> ---
>>  libavformat/hlsenc.c | 23 ---
>>  1 file changed, 12 insertions(+), 11 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 0eebcb4462..0cb75ff198 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>> HLSContext *hls,
>>  av_dict_set(, "method", "DELETE", 0);
>>  if ((ret = vs->avf->io_open(vs->avf, , path, 
>> AVIO_FLAG_WRITE, )) < 0)
>>  goto fail;
>> -ff_format_io_close(vs->avf, );
>> +hlsenc_io_close(vs->avf, , path);
> Will not actually close, when http_persistent is 1. I think it is better to 
> leave this as ff_format_io_close
>>  } else if (unlink(path) < 0) {
>>  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
>> %s\n",
>>   path, strerror(errno));
>> @@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>> HLSContext *hls,
>>  av_free(sub_path);
>>  goto fail;
>>  }
>> -ff_format_io_close(vs->avf, );
>> +hlsenc_io_close(vs->avf, , sub_path);
> Will not actually close, when http_persistent is 1.
>>  } else if (unlink(sub_path) < 0) {
>>  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
>> %s\n",
>>   sub_path, strerror(errno));
>> @@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
>> *vs)
>>  }
>>ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
>> -if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, 
>> NULL)) < 0)
>> -return ret;
>> +ret = hlsenc_io_open(s, , hls->key_file, NULL);
> We needn't call hlsenc_io_open if we are not planning to use a persistent 
> connection for it. In this case pb is uninitialized and hlsenc_io_open will 
> most probably cause a crash or undefined behavior. You can get around that 
> issue by initializing pb to NULL. But I think that is unnecessary and are 
> better placed with s->io_open().
>> +if (ret < 0) {
>> +return ret;;
> Extra semicolon
>> +}
>>  avio_seek(pb, 0, SEEK_CUR);
>>  avio_write(pb, key, KEYSIZE);
>>  avio_close(pb);
>> @@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
>>  ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
>>  hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
>>  -ff_format_io_close(s, );
>> +hlsenc_io_close(s, , hls->key_info_file);
>>if (!*hls->key_uri) {
>>  av_log(hls, AV_LOG_ERROR, "no key URI specified in key info 
>> file\n");
>> @@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
>>  }
>>ret = avio_read(pb, key, sizeof(key));
>> -ff_format_io_close(s, );
>> +hlsenc_io_close(s, , hls->key_file);
> Will not actually close, when http_persistent is 1.
>>  if (ret != sizeof(key)) {
>>  av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
>> hls->key_file);
>>  if (ret >= 0 || ret == AVERROR_EOF)
>> @@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->init_range_length = range_length;
>>  avio_open_dyn_buf(>pb);
>>  vs->packets_written = 0;
>> -ff_format_io_close(s, >out);
>>  hlsenc_io_close(s, >out, vs->base_output_dirname);
>>  }
>>  } else {
>> @@ -1845,7 +1846,7 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  if (ret < 0) {
>>  return ret;
>>  }
>> -ff_format_io_close(s, >out);
>> +hlsenc_io_close(s, >out, vs->avf->filename);
>>  }
>>  ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
>> vs->size);
>>  vs->start_pos = new_start_pos;
>> @@ -1925,14 +1926,14 @@ static int hls_write_trailer(struct AVFormatContext 
>> *s)
>>  if (ret < 0) {
>>  return ret;
>>  }
>> -ff_format_io_close(s, >out);
>> +hlsenc_io_close(s, >out, vs->avf->filename);
> Will not actually close, when http_persistent is 1. hls_write_trailer should 
> always call ff_format_io_close()
>>  }
>>av_write_trailer(oc);
>>  if (oc->pb) {
>>  vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
>>  if (hls->segment_type != SEGMENT_TYPE_FMP4)
>> -ff_format_io_close(s, >pb);
>> +hlsenc_io_close(s, >pb, oc->filename);
> Will not actually close, when 

Re: [FFmpeg-devel] [PATCH v7 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-18 Thread

> On 18 Dec 2017, at 20:52, vdi...@akamai.com wrote:
> 
> From: Vishwanath Dixit 
> 
> ---
> doc/muxers.texi   | 12 +
> libavformat/dashenc.c |  3 ++-
> libavformat/hlsenc.c  | 62 ---
> libavformat/hlsplaylist.c |  4 ++-
> libavformat/hlsplaylist.h |  2 +-
> 5 files changed, 77 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 3d0c7bf..93db549 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -834,6 +834,18 @@ be a video only stream with video bitrate 1000k, the 
> second variant stream will
> be an audio only stream with bitrate 64k and the third variant stream will be 
> a
> video only stream with bitrate 256k. Here, three media playlist with file 
> names
> out_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
> +@example
> +ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k  \
> +  -map 0:a -map 0:a -map 0:v -map 0:v -f hls \
> +  -var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high v:0,agroup:aud_low 
> v:1,agroup:aud_high" \
> +  -master_pl_name master.m3u8 \
> +  http://example.com/live/out.m3u8
> +@end example
> +This example creates two audio only and two video only variant streams. In
> +addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
> +playlist, #EXT-X-MEDIA tag is also added for the two audio only variant 
> streams
> +and they are mapped to the two video only variant streams with audio group 
> names
> +'aud_low' and 'aud_high'.
> 
> By default, a single hls variant containing all the encoded streams is 
> created.
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 5687530..f363418 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -759,7 +759,8 @@ static int write_manifest(AVFormatContext *s, int final)
> char playlist_file[64];
> AVStream *st = s->streams[i];
> get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
> i);
> -ff_hls_write_stream_info(st, out, st->codecpar->bit_rate, 
> playlist_file);
> +ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
> +playlist_file, NULL);
> }
> avio_close(out);
> if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e3442c3..2903e4e 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -144,6 +144,7 @@ typedef struct VariantStream {
> AVStream **streams;
> unsigned int nb_streams;
> int m3u8_created; /* status of media play-list creation */
> +char *agroup; /* audio group name */
> char *baseurl;
> } VariantStream;
> 
> @@ -1085,7 +1086,7 @@ static int create_master_playlist(AVFormatContext *s,
>   VariantStream * const input_vs)
> {
> HLSContext *hls = s->priv_data;
> -VariantStream *vs;
> +VariantStream *vs, *temp_vs;
> AVStream *vid_st, *aud_st;
> AVDictionary *options = NULL;
> unsigned int i, j;
> @@ -1117,6 +1118,34 @@ static int create_master_playlist(AVFormatContext *s,
> 
> ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
> 
> +/* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/
> +for (i = 0; i < hls->nb_varstreams; i++) {
> +vs = &(hls->var_streams[i]);
> +
> +if (vs->has_video || vs->has_subtitle || !vs->agroup)
> +continue;
> +
> +m3u8_name_size = strlen(vs->m3u8_name) + 1;
> +m3u8_rel_name = av_malloc(m3u8_name_size);
> +if (!m3u8_rel_name) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
> +ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
> +   m3u8_rel_name, m3u8_name_size);
> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
> +goto fail;
> +}
> +
> +avio_printf(hls->m3u8_out, 
> "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
> +vs->agroup);
> +avio_printf(hls->m3u8_out, 
> ",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
> +m3u8_rel_name);
> +av_freep(_rel_name);
> +}
> +
> /* For variant streams with video add #EXT-X-STREAM-INF tag with 
> attributes*/
> for (i = 0; i < hls->nb_varstreams; i++) {
> vs = &(hls->var_streams[i]);
> @@ -1149,6 +1178,25 @@ static int create_master_playlist(AVFormatContext *s,
> continue;
> }
> 
> +/**
> + * Traverse through the list of audio only rendition streams and find
> + * the rendition which has highest bitrate in the same audio group
> + */
> +if (vs->agroup) {
> +for (j = 0; j < hls->nb_varstreams; j++) {
> +temp_vs = &(hls->var_streams[j]);
> +if 

Re: [FFmpeg-devel] [PATCH 1/4] avformat/hlsenc: fix first fragment mp4 do not split bug

2017-12-18 Thread


> On 19 Dec 2017, at 11:42, Karthick Jeyapal  wrote:
> 
> 
> 
> On 12/18/17 2:17 PM, Steven Liu wrote:
>> fix ticket id: 6888
>> 
>> Signed-off-by: Steven Liu 
>> ---
>>  libavformat/hlsenc.c | 72 
>> 
>>  1 file changed, 62 insertions(+), 10 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index e3442c368f..f51fec1030 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -352,6 +352,29 @@ static void write_styp(AVIOContext *pb)
>>  ffio_wfourcc(pb, "msix");
>>  }
>>  +static int flush_dynbuf(VariantStream *vs, int *range_length)
>> +{
>> +AVFormatContext *ctx = vs->avf;
>> +uint8_t *buffer;
>> +
>> +if (!ctx->pb) {
>> +return AVERROR(EINVAL);
>> +}
>> +
>> +// flush
>> +av_write_frame(ctx, NULL);
>> +avio_flush(ctx->pb);
>> +
>> +// write out to file
>> +*range_length = avio_close_dyn_buf(ctx->pb, );
>> +ctx->pb = NULL;
>> +avio_write(vs->out, buffer, *range_length);
>> +av_free(buffer);
>> +
>> +// re-open buffer
>> +return avio_open_dyn_buf(>pb);
>> +}
>> +
>>  static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>> VariantStream *vs) {
>>  @@ -677,7 +700,9 @@ static int hls_mux_init(AVFormatContext *s, 
>> VariantStream *vs)
>>  if ((ret = avio_open_dyn_buf(>pb)) < 0)
>>  return ret;
>>  -if ((ret = s->io_open(s, >out, vs->base_output_dirname, 
>> AVIO_FLAG_WRITE, )) < 0) {
>> +ret = hlsenc_io_open(s, >out, vs->base_output_dirname, 
>> );
>> +av_dict_free();
>> +if (ret < 0) {
>>  av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
>> vs->fmp4_init_filename);
>>  return ret;
>>  }
>> @@ -1404,9 +1429,10 @@ static int hls_start(AVFormatContext *s, 
>> VariantStream *vs)
>>  av_dict_free();
>>  if (err < 0)
>>  return err;
>> -} else
>> +} else if (c->segment_type != SEGMENT_TYPE_FMP4) {
>>  if ((err = hlsenc_io_open(s, >pb, oc->filename, )) < 0)
>>  goto fail;
>> +}
>>  if (vs->vtt_basename) {
>>  set_http_options(s, , c);
>>  if ((err = hlsenc_io_open(s, _oc->pb, vtt_oc->filename, 
>> )) < 0)
>> @@ -1414,9 +1440,7 @@ static int hls_start(AVFormatContext *s, VariantStream 
>> *vs)
>>  }
>>  av_dict_free();
>>  -if (c->segment_type == SEGMENT_TYPE_FMP4 && !(c->flags & 
>> HLS_SINGLE_FILE)) {
>> -write_styp(oc->pb);
>> -} else {
>> +if (c->segment_type != SEGMENT_TYPE_FMP4) {
>>  /* We only require one PAT/PMT per segment. */
>>  if (oc->oformat->priv_class && oc->priv_data) {
>>  char period[21];
>> @@ -1780,7 +1804,8 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->size = new_start_pos - vs->start_pos;
>>if (!byterange_mode) {
>> -if (hls->segment_type == SEGMENT_TYPE_FMP4 && 
>> !vs->init_range_length) {
>> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>> +if (!vs->init_range_length) {
>>  avio_flush(oc->pb);
>>  range_length = avio_close_dyn_buf(oc->pb, );
>>  avio_write(vs->out, buffer, range_length);
>> @@ -1789,6 +1814,7 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->packets_written = 0;
>>  ff_format_io_close(s, >out);
>>  hlsenc_io_close(s, >out, vs->base_output_dirname);
>> +}
>>  } else {
>>  hlsenc_io_close(s, >pb, oc->filename);
>>  }
>> @@ -1807,7 +1833,20 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->number--;
>>  }
>>  -if (!vs->fmp4_init_mode || byterange_mode)
>> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>> +ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
> Will it be better if you call "set_http_options()" here itself, instead of a 
> separate patch 4/4? In that way this patch would be self contained.
set_http_options is add option to http operation, so separate two patches.
And this patch just fix ticket
>> +if (ret < 0) {
>> +av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n",
>> +vs->avf->filename);
>> +return ret;
>> +}
>> +write_styp(vs->out);
>> +ret = flush_dynbuf(vs, _length);
>> +if (ret < 0) {
>> +return ret;
>> +}
>> +ff_format_io_close(s, >out);
> Again is it better to call hlsenc_io_close() here itself instead of patch 
> 3/4. Again just from self-containment perspective.
Replace API to hlsenc_io_close is a new operation, so separate two patch
And this patch just fix 

Re: [FFmpeg-devel] [PATCH 3/3] avformat/hlsenc: Extend persistent http connections to playlists

2017-12-14 Thread

> On 14 Dec 2017, at 16:07, Karthick Jeyapal  wrote:
> 
> 
> 
>> On Nov 30, 2017, at 2:36 PM, Karthick J  wrote:
>> 
>> 
>> From: Karthick Jeyapal 
>> 
>> 
>> Before this patch persistent http connections would work only for media 
>> segments.
>> The playlists were still opening a new connection everytime.
>> This patch extends persistent http connections to playlists as well.
>> ---
>> libavformat/hlsenc.c | 46 ++
>> 1 file changed, 22 insertions(+), 24 deletions(-)
>> 
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index ff982c5..350836d 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -201,6 +201,8 @@ typedef struct HLSContext {
>> char *master_pl_name;
>> unsigned int master_publish_rate;
>> int http_persistent;
>> + AVIOContext *m3u8_out;
>> + AVIOContext *sub_m3u8_out;
>> } HLSContext;
>> 
>> 
>> static int mkdir_p(const char *path) {
>> @@ -1081,7 +1083,6 @@ static int create_master_playlist(AVFormatContext *s,
>> HLSContext *hls = s->priv_data;
>> VariantStream *vs;
>> AVStream *vid_st, *aud_st;
>> - AVIOContext *master_pb = 0;
>> AVDictionary *options = NULL;
>> unsigned int i, j;
>> int m3u8_name_size, ret, bandwidth;
>> @@ -1102,8 +1103,7 @@ static int create_master_playlist(AVFormatContext *s,
>> 
>> 
>> set_http_options(s, , hls);
>> 
>> 
>> - ret = s->io_open(s, _pb, hls->master_m3u8_url, AVIO_FLAG_WRITE,\
>> - );
>> + ret = hlsenc_io_open(s, >m3u8_out, hls->master_m3u8_url, );
>> av_dict_free();
>> if (ret < 0) {
>> av_log(NULL, AV_LOG_ERROR, "Failed to open master play list file '%s'\n",
>> @@ -,7 +,7 @@ static int create_master_playlist(AVFormatContext *s,
>> goto fail;
>> }
>> 
>> 
>> - ff_hls_write_playlist_version(master_pb, hls->version);
>> + ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
>> 
>> 
>> /* For variant streams with video add #EXT-X-STREAM-INF tag with attributes*/
>> for (i = 0; i < hls->nb_varstreams; i++) {
>> @@ -1152,7 +1152,7 @@ static int create_master_playlist(AVFormatContext *s,
>> bandwidth += aud_st->codecpar->bit_rate;
>> bandwidth += bandwidth / 10;
>> 
>> 
>> - ff_hls_write_stream_info(vid_st, master_pb, bandwidth, m3u8_rel_name);
>> + ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, m3u8_rel_name);
>> 
>> 
>> av_freep(_rel_name);
>> }
>> @@ -1160,7 +1160,7 @@ fail:
>> if(ret >=0)
>> hls->master_m3u8_created = 1;
>> av_freep(_rel_name);
>> - ff_format_io_close(s, _pb);
>> + hlsenc_io_close(s, >m3u8_out, hls->master_m3u8_url);
>> return ret;
>> }
>> 
>> 
>> @@ -1170,8 +1170,6 @@ static int hls_window(AVFormatContext *s, int last, 
>> VariantStream *vs)
>> HLSSegment *en;
>> int target_duration = 0;
>> int ret = 0;
>> - AVIOContext *out = NULL;
>> - AVIOContext *sub_out = NULL;
>> char temp_filename[1024];
>> int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - vs->nb_entries);
>> const char *proto = avio_find_protocol_name(s->filename);
>> @@ -1203,7 +1201,7 @@ static int hls_window(AVFormatContext *s, int last, 
>> VariantStream *vs)
>> 
>> 
>> set_http_options(s, , hls);
>> snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : "%s", 
>> vs->m3u8_name);
>> - if ((ret = s->io_open(s, , temp_filename, AVIO_FLAG_WRITE, )) 
>> < 0)
>> + if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, )) < 0)
>> goto fail;
>> 
>> 
>> for (en = vs->segments; en; en = en->next) {
>> @@ -1212,33 +1210,33 @@ static int hls_window(AVFormatContext *s, int last, 
>> VariantStream *vs)
>> }
>> 
>> 
>> vs->discontinuity_set = 0;
>> - ff_hls_write_playlist_header(out, hls->version, hls->allowcache,
>> + ff_hls_write_playlist_header(hls->m3u8_out, hls->version, hls->allowcache,
>> target_duration, sequence, hls->pl_type);
>> 
>> 
>> if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
>> vs->discontinuity_set==0 ){
>> - avio_printf(out, "#EXT-X-DISCONTINUITY\n");
>> + avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
>> vs->discontinuity_set = 1;
>> }
>> if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
>> - avio_printf(out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
>> + avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
>> }
>> for (en = vs->segments; en; en = en->next) {
>> if ((hls->encrypt || hls->key_info_file) && (!key_uri || strcmp(en->key_uri, 
>> key_uri) ||
>> av_strcasecmp(en->iv_string, iv_string))) {
>> - avio_printf(out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
>> + avio_printf(hls->m3u8_out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", 
>> en->key_uri);
>> if (*en->iv_string)
>> - avio_printf(out, ",IV=0x%s", en->iv_string);
>> - avio_printf(out, "\n");
>> + avio_printf(hls->m3u8_out, ",IV=0x%s", en->iv_string);
>> + avio_printf(hls->m3u8_out, "\n");
>> key_uri = en->key_uri;
>> iv_string = en->iv_string;
>> }
>> 
>> 
>> if ((hls->segment_type == SEGMENT_TYPE_FMP4) && (en == vs->segments)) {
>> - 

Re: [FFmpeg-devel] [PATCH v6 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-29 Thread
Where can i find the v6 2/2 ?
> 在 2017年11月29日,16:52,Karthick J  写道:
> 
> ---
> libavformat/Makefile  |   2 +-
> libavformat/hlsenc.c  | 115 +++---
> libavformat/hlsplaylist.c | 138 ++
> libavformat/hlsplaylist.h |  51 +
> 4 files changed, 211 insertions(+), 95 deletions(-)
> create mode 100644 libavformat/hlsplaylist.c
> create mode 100644 libavformat/hlsplaylist.h
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index b1e7b19..fd8b9f9 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -215,7 +215,7 @@ OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
> OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
> OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
> OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
> -OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o
> +OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o
> OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
> OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
> OBJS-$(CONFIG_ICO_MUXER) += icoenc.o
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index d5c732f..f63b08d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -46,6 +46,7 @@
> #include "avformat.h"
> #include "avio_internal.h"
> #include "http.h"
> +#include "hlsplaylist.h"
> #include "internal.h"
> #include "os_support.h"
> 
> @@ -97,13 +98,6 @@ typedef enum {
> SEGMENT_TYPE_FMP4,
> } SegmentType;
> 
> -typedef enum {
> -PLAYLIST_TYPE_NONE,
> -PLAYLIST_TYPE_EVENT,
> -PLAYLIST_TYPE_VOD,
> -PLAYLIST_TYPE_NB,
> -} PlaylistType;
> -
> typedef struct VariantStream {
> unsigned number;
> int64_t sequence;
> @@ -1055,19 +1049,6 @@ static void hls_free_segments(HLSSegment *p)
> }
> }
> 
> -static void write_m3u8_head_block(HLSContext *hls, AVIOContext *out, int 
> version,
> -  int target_duration, int64_t sequence)
> -{
> -avio_printf(out, "#EXTM3U\n");
> -avio_printf(out, "#EXT-X-VERSION:%d\n", version);
> -if (hls->allowcache == 0 || hls->allowcache == 1) {
> -avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", hls->allowcache == 0 ? 
> "NO" : "YES");
> -}
> -avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
> -avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
> -av_log(hls, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", 
> sequence);
> -}
> -
> static void hls_rename_temp_file(AVFormatContext *s, AVFormatContext *oc)
> {
> size_t len = strlen(oc->filename);
> @@ -1133,8 +1114,7 @@ static int create_master_playlist(AVFormatContext *s,
> goto fail;
> }
> 
> -avio_printf(master_pb, "#EXTM3U\n");
> -avio_printf(master_pb, "#EXT-X-VERSION:%d\n", hls->version);
> +ff_hls_write_playlist_version(master_pb, hls->version);
> 
> /* For variant streams with video add #EXT-X-STREAM-INF tag with 
> attributes*/
> for (i = 0; i < hls->nb_varstreams; i++) {
> @@ -1175,18 +1155,7 @@ static int create_master_playlist(AVFormatContext *s,
> bandwidth += aud_st->codecpar->bit_rate;
> bandwidth += bandwidth / 10;
> 
> -if (!bandwidth) {
> -av_log(NULL, AV_LOG_WARNING,
> -"Bandwidth info not available, set audio and video 
> bitrates\n");
> -av_freep(_rel_name);
> -continue;
> -}
> -
> -avio_printf(master_pb, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth);
> -if (vid_st && vid_st->codecpar->width > 0 && 
> vid_st->codecpar->height > 0)
> -avio_printf(master_pb, ",RESOLUTION=%dx%d", 
> vid_st->codecpar->width,
> -vid_st->codecpar->height);
> -avio_printf(master_pb, "\n%s\n\n", m3u8_rel_name);
> +ff_hls_write_stream_info(vid_st, master_pb, bandwidth, 
> m3u8_rel_name);
> 
> av_freep(_rel_name);
> }
> @@ -1215,6 +1184,7 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> char *iv_string = NULL;
> AVDictionary *options = NULL;
> double prog_date_time = vs->initial_prog_date_time;
> +double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
> _date_time : NULL;
> int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size 
> > 0);
> 
> hls->version = 3;
> @@ -1245,12 +1215,8 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> }
> 
> vs->discontinuity_set = 0;
> -write_m3u8_head_block(hls, out, hls->version, target_duration, sequence);
> -if (hls->pl_type == PLAYLIST_TYPE_EVENT) {
> -avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
> -} else if (hls->pl_type == PLAYLIST_TYPE_VOD) {
> -avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
> -}
> +ff_hls_write_playlist_header(out, hls->version, hls->allowcache,
> + 

Re: [FFmpeg-devel] [PATCH v3 3/3] libavformat/hlsenc: Persistent HTTP connections supported as an option

2017-11-28 Thread

> 在 2017年11月29日,14:19,Karthick J  写道:
> 
> ---
> doc/muxers.texi  |  3 +++
> libavformat/hlsenc.c | 48 +---
> 2 files changed, 44 insertions(+), 7 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 9d9ca31..8ec48c2 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -854,6 +854,9 @@ ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 \
> This example creates HLS master playlist with name master.m3u8 and keep
> publishing it repeatedly every after 30 segments i.e. every after 60s.
> 
> +@item http_persistent
> +Use persistent HTTP connections. Applicable only for HTTP output.
> +
> @end table
> 
> @anchor{ico}
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 6997a5c..d5c732f 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -45,6 +45,7 @@
> 
> #include "avformat.h"
> #include "avio_internal.h"
> +#include "http.h"
> #include "internal.h"
> #include "os_support.h"
> 
> @@ -205,6 +206,7 @@ typedef struct HLSContext {
> char *var_stream_map; /* user specified variant stream map string */
> char *master_pl_name;
> unsigned int master_publish_rate;
> +int http_persistent;
> } HLSContext;
> 
> static int get_int_from_double(double val)
> @@ -245,10 +247,38 @@ static int mkdir_p(const char *path) {
> return ret;
> }
> 
> +static int is_http_proto(char *filename) {
> +const char *proto = avio_find_protocol_name(filename);
> +return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, 
> "https")) : 0;
> +}
> +
> +static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char 
> *filename,
> +  AVDictionary **options) {
> +HLSContext *hls = s->priv_data;
> +int http_base_proto = is_http_proto(filename);
> +int err;
> +if (!*pb || !http_base_proto || !hls->http_persistent) {
> +err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options);
> +} else {
> +URLContext *http_url_context = ffio_geturlcontext(*pb);
> +av_assert0(http_url_context);
> +err = ff_http_do_new_request(http_url_context, filename);
> +}
> +return err;
> +}
> +
> +static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char 
> *filename) {
> +HLSContext *hls = s->priv_data;
> +int http_base_proto = is_http_proto(filename);
> +
> +if (!http_base_proto || !hls->http_persistent || hls->key_info_file || 
> hls->encrypt) {
> +ff_format_io_close(s, pb);
> +}
> +}
> +
> static void set_http_options(AVFormatContext *s, AVDictionary **options, 
> HLSContext *c)
> {
> -const char *proto = avio_find_protocol_name(s->filename);
> -int http_base_proto = proto ? (!av_strcasecmp(proto, "http") || 
> !av_strcasecmp(proto, "https")) : 0;
> +int http_base_proto = is_http_proto(s->filename);
> 
> if (c->method) {
> av_dict_set(options, "method", c->method, 0);
> @@ -258,6 +288,8 @@ static void set_http_options(AVFormatContext *s, 
> AVDictionary **options, HLSCont
> }
> if (c->user_agent)
> av_dict_set(options, "user_agent", c->user_agent, 0);
> +if (c->http_persistent)
> +av_dict_set_int(options, "multiple_requests", 1, 0);
> 
> }
> 
> @@ -1437,17 +1469,17 @@ static int hls_start(AVFormatContext *s, 
> VariantStream *vs)
> err = AVERROR(ENOMEM);
> goto fail;
> }
> -err = s->io_open(s, >pb, filename, AVIO_FLAG_WRITE, );
> +err = hlsenc_io_open(s, >pb, filename, );
> av_free(filename);
> av_dict_free();
> if (err < 0)
> return err;
> } else
> -if ((err = s->io_open(s, >pb, oc->filename, AVIO_FLAG_WRITE, 
> )) < 0)
> +if ((err = hlsenc_io_open(s, >pb, oc->filename, )) < 0)
> goto fail;
> if (vs->vtt_basename) {
> set_http_options(s, , c);
> -if ((err = s->io_open(s, _oc->pb, vtt_oc->filename, 
> AVIO_FLAG_WRITE, )) < 0)
> +if ((err = hlsenc_io_open(s, _oc->pb, vtt_oc->filename, 
> )) < 0)
> goto fail;
> }
> av_dict_free();
> @@ -2165,11 +2197,12 @@ static int hls_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
> avio_open_dyn_buf(>pb);
> vs->packets_written = 0;
> ff_format_io_close(s, >out);
> +hlsenc_io_close(s, >out, vs->base_output_dirname);
> } else {
> -ff_format_io_close(s, >pb);
> +hlsenc_io_close(s, >pb, oc->filename);
> }
> if (vs->vtt_avf) {
> -ff_format_io_close(s, >vtt_avf->pb);
> +hlsenc_io_close(s, >vtt_avf->pb, vs->vtt_avf->filename);
> }
> }
> if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
> @@ -2355,6 +2388,7 @@ static const AVOption options[] = {
> {"var_stream_map", "Variant stream map string", OFFSET(var_stream_map), 
> 

Re: [FFmpeg-devel] [PATCH v2 3/3] libavformat/hlsenc: Persistent HTTP connections supported as an option

2017-11-28 Thread

> 在 2017年11月29日,12:05,Jeyapal, Karthick <kjeya...@akamai.com> 写道:
> 
> 
> On 11/24/17, 3:49 PM, "Jeyapal, Karthick" <kjeya...@akamai.com> wrote:
>> 
>> On 11/24/17, 3:40 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>> 
>>>> 在 2017年11月24日,18:02,Jeyapal, Karthick <kjeya...@akamai.com> 写道:
>>>> 
>>>> On 11/22/17, 1:27 PM, "Jeyapal, Karthick" <kjeya...@akamai.com> wrote:
>>>> 
>>>>>> On 11/22/17, 9:32 AM, "刘歧" <l...@chinaffmpeg.org> wrote:
>>>>>> 
>>>>>> This patch is ok, but i see it need an API: ffio_geturlcontext
>>>>>> 
>>>>>> it in the other patch, i see it have some thing need talk? If that is 
>>>>>> ok, this patch should be apply.
>>> Is this ok?
>> Yes, ffio_geturlcontext has already been accepted by Nicolas.
>> http://ffmpeg.org/pipermail/ffmpeg-devel/2017-November/220014.html
>> He had concerns on calling prot->url_write directly from hlsenc, which has 
>> been removed on new patchset(v2).
>> Also av_assert0 has been added as suggested by him
> A gentle reminder. 
> 7 days have gone by since the last version of this patchset was submitted. 
> And no objections so far.
> Could this patchset be pushed, please? Thanks.
Can you resubmit a new version of this patchiest, There have too many version 
and ignore version patches.


Thanks
>>> 
>>> Thanks
>>>>> Thanks for the reply. 
>>>>> All concerns raised by Nicolas has been addressed in this latest patch 
>>>>> set.
>>>>> Let us wait for few days to check if anyone still has any objections.
>>>> Looks like nobody has anymore objections to this patchset. 
>>>> Well, it has already passed through multiple rounds of reviews.
>>>> Could somebody please push this to the master. 
>>>> I have few more patches waiting to be submitted, dependent on this feature.
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Added context to av_log calls

2017-11-24 Thread

> 在 2017年11月24日,19:03,Moritz Barsnick  写道:
> 
> On Fri, Nov 24, 2017 at 15:42:30 +0530, Karthick J wrote:
>> if (av_strncasecmp(master_url, media_url, base_len)) {
>> -av_log(NULL, AV_LOG_WARNING, "Unable to find relative url\n");
>> return AVERROR(EINVAL);
> 
> Was it intention to remove this one?
I think yes, because he move the av_log out of this call.
> 
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Added context to av_log calls

2017-11-24 Thread

> 在 2017年11月24日,18:12,Karthick J  写道:
> 
> ---
> libavformat/hlsenc.c | 9 -
> 1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 30ccf73..379a4ec 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1057,7 +1057,6 @@ static int get_relative_url(const char *master_url, 
> const char *media_url,
> if (p) {
> base_len = FFABS(p - master_url);
> if (av_strncasecmp(master_url, media_url, base_len)) {
> -av_log(NULL, AV_LOG_WARNING, "Unable to find relative url\n");
> return AVERROR(EINVAL);
> }
> }
> @@ -1096,7 +1095,7 @@ static int create_master_playlist(AVFormatContext *s,
>  );
> av_dict_free();
> if (ret < 0) {
> -av_log(NULL, AV_LOG_ERROR, "Failed to open master play list file 
> '%s'\n",
> +av_log(s, AV_LOG_ERROR, "Failed to open master play list file 
> '%s'\n",
> hls->master_m3u8_url);
> goto fail;
> }
> @@ -1118,7 +1117,7 @@ static int create_master_playlist(AVFormatContext *s,
> ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
>m3u8_rel_name, m3u8_name_size);
> if (ret < 0) {
> -av_log(NULL, AV_LOG_ERROR, "Unable to find relative URL\n");
> +av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
> goto fail;
> }
> 
> @@ -1132,7 +1131,7 @@ static int create_master_playlist(AVFormatContext *s,
> }
> 
> if (!vid_st && !aud_st) {
> -av_log(NULL, AV_LOG_WARNING, "Media stream not found\n");
> +av_log(s, AV_LOG_WARNING, "Media stream not found\n");
> continue;
> }
> 
> @@ -1144,7 +1143,7 @@ static int create_master_playlist(AVFormatContext *s,
> bandwidth += bandwidth / 10;
> 
> if (!bandwidth) {
> -av_log(NULL, AV_LOG_WARNING,
> +av_log(s, AV_LOG_WARNING,
> "Bandwidth info not available, set audio and video 
> bitrates\n");
> av_freep(_rel_name);
> continue;
> -- 
> 1.9.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


LGTM


Thanks

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 3/3] libavformat/hlsenc: Persistent HTTP connections supported as an option

2017-11-24 Thread

> 在 2017年11月24日,18:02,Jeyapal, Karthick <kjeya...@akamai.com> 写道:
> 
> On 11/22/17, 1:27 PM, "Jeyapal, Karthick" <kjeya...@akamai.com> wrote:
> 
>>> On 11/22/17, 9:32 AM, "刘歧" <l...@chinaffmpeg.org> wrote:
>>> 
>>> This patch is ok, but i see it need an API: ffio_geturlcontext
>>> 
>>> it in the other patch, i see it have some thing need talk? If that is ok, 
>>> this patch should be apply.
Is this ok?

Thanks
>> Thanks for the reply. 
>> All concerns raised by Nicolas has been addressed in this latest patch set.
>> Let us wait for few days to check if anyone still has any objections.
> Looks like nobody has anymore objections to this patchset. 
> Well, it has already passed through multiple rounds of reviews.
> Could somebody please push this to the master. 
> I have few more patches waiting to be submitted, dependent on this feature.
>>> 
>>> Thanks
> 
> regards,
> Karthick
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-23 Thread

> 在 2017年11月24日,11:55,Karthick J  写道:
> 
> ---
> libavformat/hlsenc.c | 238 +++
> libavformat/hlsenc.h |  68 +++
> 2 files changed, 194 insertions(+), 112 deletions(-)
> create mode 100644 libavformat/hlsenc.h
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 30ccf73..5c4f459 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -45,6 +45,7 @@
> 
> #include "avformat.h"
> #include "avio_internal.h"
> +#include "hlsenc.h"
> #include "internal.h"
> #include "os_support.h"
> 
> @@ -73,36 +74,11 @@ typedef struct HLSSegment {
> struct HLSSegment *next;
> } HLSSegment;
> 
> -typedef enum HLSFlags {
> -// Generate a single media file and use byte ranges in the playlist.
> -HLS_SINGLE_FILE = (1 << 0),
> -HLS_DELETE_SEGMENTS = (1 << 1),
> -HLS_ROUND_DURATIONS = (1 << 2),
> -HLS_DISCONT_START = (1 << 3),
> -HLS_OMIT_ENDLIST = (1 << 4),
> -HLS_SPLIT_BY_TIME = (1 << 5),
> -HLS_APPEND_LIST = (1 << 6),
> -HLS_PROGRAM_DATE_TIME = (1 << 7),
> -HLS_SECOND_LEVEL_SEGMENT_INDEX = (1 << 8), // include segment index in 
> segment filenames when use_localtime  e.g.: %%03d
> -HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), // include segment 
> duration (microsec) in segment filenames when use_localtime  e.g.: %%09t
> -HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size 
> (bytes) in segment filenames when use_localtime  e.g.: %%014s
> -HLS_TEMP_FILE = (1 << 11),
> -HLS_PERIODIC_REKEY = (1 << 12),
> -HLS_INDEPENDENT_SEGMENTS = (1 << 13),
> -} HLSFlags;
> -
> typedef enum {
> SEGMENT_TYPE_MPEGTS,
> SEGMENT_TYPE_FMP4,
> } SegmentType;
> 
> -typedef enum {
> -PLAYLIST_TYPE_NONE,
> -PLAYLIST_TYPE_EVENT,
> -PLAYLIST_TYPE_VOD,
> -PLAYLIST_TYPE_NB,
> -} PlaylistType;
> -
> typedef struct VariantStream {
> unsigned number;
> int64_t sequence;
> @@ -207,6 +183,113 @@ typedef struct HLSContext {
> unsigned int master_publish_rate;
> } HLSContext;
> 
> +void ff_hls_write_playlist_version(AVIOContext *out, int version) {
> +if (!out)
> +return;
> +avio_printf(out, "#EXTM3U\n");
> +avio_printf(out, "#EXT-X-VERSION:%d\n", version);
> +}
> +
> +void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
> +  int bandwidth, char *filename) {
> +if (!out || !filename)
> +return;
> +
> +if (!bandwidth) {
> +av_log(NULL, AV_LOG_WARNING,
> +"Bandwidth info not available, set audio and video 
> bitrates\n");
> +return;
> +}
> +
> +avio_printf(out, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth);
> +if (st && st->codecpar->width > 0 && st->codecpar->height > 0)
> +avio_printf(out, ",RESOLUTION=%dx%d", st->codecpar->width,
> +st->codecpar->height);
> +avio_printf(out, "\n%s\n\n", filename);
> +}
> +
> +void ff_hls_write_playlist_header(AVIOContext *out, int version, int 
> allowcache,
> +  int target_duration, int64_t sequence,
> +  uint32_t playlist_type) {
> +if (!out)
> +return;
> +ff_hls_write_playlist_version(out, version);
> +if (allowcache == 0 || allowcache == 1) {
> +avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", allowcache == 0 ? "NO" : 
> "YES");
> +}
> +avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
> +avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
> +av_log(NULL, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", 
> sequence);
> +
> +if (playlist_type == PLAYLIST_TYPE_EVENT) {
> +avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
> +} else if (playlist_type == PLAYLIST_TYPE_VOD) {
> +avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
> +}
> +}
> +
> +void ff_hls_write_init_file(AVIOContext *out, char *filename,
> +int byterange_mode, int64_t size, int64_t pos) {
> +avio_printf(out, "#EXT-X-MAP:URI=\"%s\"", filename);
> +if (byterange_mode) {
> +avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", size, pos);
> +}
> +avio_printf(out, "\n");
> +}
> +
> +void ff_hls_write_file_entry(AVIOContext *out, int insert_discont,
> +int byterange_mode, uint32_t flags, double 
> duration,
> +int64_t size, int64_t pos, //Used only if 
> HLS_SINGLE_FILE flag is set
> +char *baseurl, //Ignored if NULL
> +char *filename, double *prog_date_time) {
> +if (!out || !filename)
> +return;
> +
> +if (insert_discont) {
> +avio_printf(out, "#EXT-X-DISCONTINUITY\n");
> +}
> +if (flags & HLS_ROUND_DURATIONS)
> +avio_printf(out, "#EXTINF:%ld,\n",  lrint(duration));
> +else
> +avio_printf(out, "#EXTINF:%f,\n", duration);
> +if 

Re: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: Minor fix in setting http options for master playlist

2017-11-22 Thread

> 在 2017年11月22日,16:08,Karthick J  写道:
> 
> ---
> libavformat/hlsenc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 3c47ced..525605b 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1089,8 +1089,7 @@ static int create_master_playlist(AVFormatContext *s,
> return 0;
> }
> 
> -if (hls->user_agent)
> -  av_dict_set(, "user-agent", hls->user_agent, 0);
> +set_http_options(s, , hls);
> 
> ret = s->io_open(s, _pb, hls->master_m3u8_url, AVIO_FLAG_WRITE,\
>  );
> -- 
> 1.9.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

LGTM

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/1] avformat/dashenc: Associate mpd extension with dash muxer

2017-11-22 Thread

> 在 2017年11月22日,16:20,Karthick J  写道:
> 
> ---
> libavformat/dashenc.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 201668a..0fee3cd 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1219,6 +1219,7 @@ static const AVClass dash_class = {
> AVOutputFormat ff_dash_muxer = {
> .name   = "dash",
> .long_name  = NULL_IF_CONFIG_SMALL("DASH Muxer"),
> +.extensions = "mpd",
> .priv_data_size = sizeof(DASHContext),
> .audio_codec= AV_CODEC_ID_AAC,
> .video_codec= AV_CODEC_ID_H264,
> -- 
> 1.9.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

LGTM


Thanks

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: Modularized playlist creation to allow reuse

2017-11-22 Thread

> 在 2017年11月22日,14:53,Karthick J  写道:
> 
> ---
> libavformat/hlsenc.c | 130 +++---
> libavformat/hlsenc.h | 158 +++
> 2 files changed, 177 insertions(+), 111 deletions(-)
> create mode 100644 libavformat/hlsenc.h
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 3c47ced..4e017eb 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -45,6 +45,7 @@
> 
> #include "avformat.h"
> #include "avio_internal.h"
> +#include "hlsenc.h"
> #include "internal.h"
> #include "os_support.h"
> 
> @@ -73,35 +74,11 @@ typedef struct HLSSegment {
> struct HLSSegment *next;
> } HLSSegment;
> 
> -typedef enum HLSFlags {
> -// Generate a single media file and use byte ranges in the playlist.
> -HLS_SINGLE_FILE = (1 << 0),
> -HLS_DELETE_SEGMENTS = (1 << 1),
> -HLS_ROUND_DURATIONS = (1 << 2),
> -HLS_DISCONT_START = (1 << 3),
> -HLS_OMIT_ENDLIST = (1 << 4),
> -HLS_SPLIT_BY_TIME = (1 << 5),
> -HLS_APPEND_LIST = (1 << 6),
> -HLS_PROGRAM_DATE_TIME = (1 << 7),
> -HLS_SECOND_LEVEL_SEGMENT_INDEX = (1 << 8), // include segment index in 
> segment filenames when use_localtime  e.g.: %%03d
> -HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), // include segment 
> duration (microsec) in segment filenames when use_localtime  e.g.: %%09t
> -HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size 
> (bytes) in segment filenames when use_localtime  e.g.: %%014s
> -HLS_TEMP_FILE = (1 << 11),
> -HLS_PERIODIC_REKEY = (1 << 12),
> -} HLSFlags;
> -
> typedef enum {
> SEGMENT_TYPE_MPEGTS,
> SEGMENT_TYPE_FMP4,
> } SegmentType;
> 
> -typedef enum {
> -PLAYLIST_TYPE_NONE,
> -PLAYLIST_TYPE_EVENT,
> -PLAYLIST_TYPE_VOD,
> -PLAYLIST_TYPE_NB,
> -} PlaylistType;
> -
> typedef struct VariantStream {
> unsigned number;
> int64_t sequence;
> @@ -1022,19 +999,6 @@ static void hls_free_segments(HLSSegment *p)
> }
> }
> 
> -static void write_m3u8_head_block(HLSContext *hls, AVIOContext *out, int 
> version,
> -  int target_duration, int64_t sequence)
> -{
> -avio_printf(out, "#EXTM3U\n");
> -avio_printf(out, "#EXT-X-VERSION:%d\n", version);
> -if (hls->allowcache == 0 || hls->allowcache == 1) {
> -avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", hls->allowcache == 0 ? 
> "NO" : "YES");
> -}
> -avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
> -avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
> -av_log(hls, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", 
> sequence);
> -}
> -
> static void hls_rename_temp_file(AVFormatContext *s, AVFormatContext *oc)
> {
> size_t len = strlen(oc->filename);
> @@ -1101,8 +1065,7 @@ static int create_master_playlist(AVFormatContext *s,
> goto fail;
> }
> 
> -avio_printf(master_pb, "#EXTM3U\n");
> -avio_printf(master_pb, "#EXT-X-VERSION:%d\n", hls->version);
> +hls_write_playlist_version(master_pb, hls->version);
> 
> /* For variant streams with video add #EXT-X-STREAM-INF tag with 
> attributes*/
> for (i = 0; i < hls->nb_varstreams; i++) {
> @@ -1143,18 +1106,7 @@ static int create_master_playlist(AVFormatContext *s,
> bandwidth += aud_st->codecpar->bit_rate;
> bandwidth += bandwidth / 10;
> 
> -if (!bandwidth) {
> -av_log(NULL, AV_LOG_WARNING,
> -"Bandwidth info not available, set audio and video 
> bitrates\n");
> -av_freep(_rel_name);
> -continue;
> -}
> -
> -avio_printf(master_pb, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth);
> -if (vid_st && vid_st->codecpar->width > 0 && 
> vid_st->codecpar->height > 0)
> -avio_printf(master_pb, ",RESOLUTION=%dx%d", 
> vid_st->codecpar->width,
> -vid_st->codecpar->height);
> -avio_printf(master_pb, "\n%s\n\n", m3U8_rel_name);
> +hls_write_stream_info(vid_st, master_pb, bandwidth, m3U8_rel_name);
> 
> av_freep(_rel_name);
> }
> @@ -1209,12 +1161,8 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> }
> 
> vs->discontinuity_set = 0;
> -write_m3u8_head_block(hls, out, hls->version, target_duration, sequence);
> -if (hls->pl_type == PLAYLIST_TYPE_EVENT) {
> -avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
> -} else if (hls->pl_type == PLAYLIST_TYPE_VOD) {
> -avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
> -}
> +hls_write_playlist_header(out, hls->version, hls->allowcache,
> +  target_duration, sequence, hls->pl_type);
> 
> if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
> vs->discontinuity_set==0 ){
> avio_printf(out, "#EXT-X-DISCONTINUITY\n");
> @@ -1231,74 +1179,34 @@ static int hls_window(AVFormatContext *s, int last, 
> 

Re: [FFmpeg-devel] [PATCH 2/2] avformat/hlsenc: Refactor an inconsistent variable name

2017-11-22 Thread

> 在 2017年11月22日,16:08,Karthick J  写道:
> 
> ---
> libavformat/hlsenc.c | 18 +-
> 1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 525605b..611cc99 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1074,7 +1074,7 @@ static int create_master_playlist(AVFormatContext *s,
> AVDictionary *options = NULL;
> unsigned int i, j;
> int m3u8_name_size, ret, bandwidth;
> -char *m3U8_rel_name;
> +char *m3u8_rel_name;
> 
> input_vs->m3u8_created = 1;
> if (!hls->master_m3u8_created) {
> @@ -1108,14 +1108,14 @@ static int create_master_playlist(AVFormatContext *s,
> vs = &(hls->var_streams[i]);
> 
> m3u8_name_size = strlen(vs->m3u8_name) + 1;
> -m3U8_rel_name = av_malloc(m3u8_name_size);
> -if (!m3U8_rel_name) {
> +m3u8_rel_name = av_malloc(m3u8_name_size);
> +if (!m3u8_rel_name) {
> ret = AVERROR(ENOMEM);
> goto fail;
> }
> -av_strlcpy(m3U8_rel_name, vs->m3u8_name, m3u8_name_size);
> +av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
> ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
> -   m3U8_rel_name, m3u8_name_size);
> +   m3u8_rel_name, m3u8_name_size);
> if (ret < 0) {
> av_log(NULL, AV_LOG_ERROR, "Unable to find relative URL\n");
> goto fail;
> @@ -1145,7 +1145,7 @@ static int create_master_playlist(AVFormatContext *s,
> if (!bandwidth) {
> av_log(NULL, AV_LOG_WARNING,
> "Bandwidth info not available, set audio and video 
> bitrates\n");
> -av_freep(_rel_name);
> +av_freep(_rel_name);
> continue;
> }
> 
> @@ -1153,14 +1153,14 @@ static int create_master_playlist(AVFormatContext *s,
> if (vid_st && vid_st->codecpar->width > 0 && vid_st->codecpar->height 
> > 0)
> avio_printf(master_pb, ",RESOLUTION=%dx%d", 
> vid_st->codecpar->width,
> vid_st->codecpar->height);
> -avio_printf(master_pb, "\n%s\n\n", m3U8_rel_name);
> +avio_printf(master_pb, "\n%s\n\n", m3u8_rel_name);
> 
> -av_freep(_rel_name);
> +av_freep(_rel_name);
> }
> fail:
> if(ret >=0)
> hls->master_m3u8_created = 1;
> -av_freep(_rel_name);
> +av_freep(_rel_name);
> ff_format_io_close(s, _pb);
> return ret;
> }
> -- 
> 1.9.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

patchset LGTM



Thanks



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 3/3] libavformat/hlsenc: Persistent HTTP connections supported as an option

2017-11-21 Thread

> 在 2017年11月22日,11:39,Jeyapal, Karthick  写道:
> 
>> On 11/21/17, 8:24 PM, "Steven Liu"  wrote:
>> 
> […]
>>> +if (*pb == NULL || !http_base_proto || !hls->http_persistent) {
>> What about !*pb ?
> 
> Thanks for your comments. 
> I have modified the patch as per your suggestion and have attached the same.
> 
This patch is ok, but i see it need an API: ffio_geturlcontext

it in the other patch, i see it have some thing need talk? If that is ok, this 
patch should be apply.

Thanks
> Regards,
> Karthick
> 
> 
> <0003-libavformat-hlsenc-Persistent-HTTP-connections-suppo.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/1] avformat/dashenc: Added configuration to override HTTP User-Agent

2017-11-20 Thread


> 在 2017年11月20日,19:31,Jeyapal, Karthick <kjeya...@akamai.com> 写道:
> 
>> On 11/20/17, 1:47 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
> 
> 
>>> 在 2017年11月20日,15:59,Jeyapal, Karthick <kjeya...@akamai.com> 写道:
>>> 
>>>> On 11/20/17, 1:01 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>>>>> 在 2017年11月8日,17:22,Karthick J <kjeya...@akamai.com> 写道:
>>>>> +{ "http_user_agent", "override User-Agent field in HTTP header", 
>>>>> OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
>>>> What about dash_user_agent? The reason is http_user_agent maybe get mean 
>>>> HTTP Protocol user_agent, but this is used in dashenc.
>>> 
>>> I kept http_user_agent to maintain uniformity with hlsenc option. 
>>> http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215642.html
>>> 
>>> In that way, irrespective of hls or dash output format, http_user_agent 
>>> would apply for both.
>> that should modify to hls_user_agent too. because that is clarified the 
>> option is used in dash or hls, isn’t it?
> 
> Sure. I am ok with dash_user_agent as well. 
> I have attached a new patch with the option renamed to dash_user_agent.
> 
> Thanks and regards,
> Karthick
> 
> 
> 
> 
> <0001-avformat-dashenc-Added-configuration-to-override-HTT.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

should be ok

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vaapi: add the fourcc of I420 format map.

2017-11-20 Thread

> 在 2017年11月20日,08:36,Jun Zhao  写道:
> 
> <0002-hwcontext_vaapi-add-the-fourcc-of-I420-format-map.patch>
From f31e492201b7a8c59bdf7c266c2df016057897c4 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Sat, 18 Nov 2017 11:57:41 +0800
Subject: [PATCH 2/2] hwcontext_vaapi: add the fourcc of I420 format map.

VA-API 2.0 have enable the I420, so enable this map.

Signed-off-by: Jun Zhao 
---
libavutil/hwcontext_vaapi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index f246639021..d536bc93a1 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -101,7 +101,9 @@ static const struct {
MAP(NV12, YUV420,  NV12),
MAP(YV12, YUV420,  YUV420P), // With U/V planes swapped.
MAP(IYUV, YUV420,  YUV420P),
-  //MAP(I420, YUV420,  YUV420P), // Not in libva but used by Intel driver.
+#ifdef VA_FOURCC_I420
+MAP(I420, YUV420,  YUV420P),
+#endif
#ifdef VA_FOURCC_YV16
MAP(YV16, YUV422,  YUV422P), // With U/V planes swapped.
#endif
-- 
2.14.1



LGTM


Thanks

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg: add return value check to suppress the build warning.

2017-11-20 Thread

> 在 2017年11月20日,08:40,Jun Zhao  写道:
> 
> 
> <0001-ffmpeg-add-return-value-check-to-supress-the-build-w.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

From 01a66eb4559fb3fec0765ee03417a65ef5e06fe1 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Sat, 18 Nov 2017 13:24:24 +0800
Subject: [PATCH] ffmpeg: add return value check to supress the build warning.

add return value check to supress the build warning message like
"warning: ignoring return value" when use attribute -Wunused-result.

Signed-off-by: Jun Zhao 
---
 fftools/ffmpeg.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index babd85f7bc..0c16e75ab0 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -220,13 +220,18 @@ static void sub2video_push_ref(InputStream *ist, int64_t 
pts)
 {
 AVFrame *frame = ist->sub2video.frame;
 int i;
+int ret;
 
 av_assert1(frame->data[0]);
 ist->sub2video.last_pts = frame->pts = pts;
-for (i = 0; i < ist->nb_filters; i++)
-av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
- AV_BUFFERSRC_FLAG_KEEP_REF |
- AV_BUFFERSRC_FLAG_PUSH);
+for (i = 0; i < ist->nb_filters; i++) {
+ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
+   AV_BUFFERSRC_FLAG_KEEP_REF |
+   AV_BUFFERSRC_FLAG_PUSH);
+if (ret != AVERROR_EOF && ret < 0)
+av_log(NULL, AV_LOG_WARNING, "Error while add the frame to buffer 
source(%s).\n",
+   av_err2str(ret));
+}
 }
 
 void sub2video_update(InputStream *ist, AVSubtitle *sub)
@@ -295,11 +300,15 @@ static void sub2video_heartbeat(InputStream *ist, int64_t 
pts)
 static void sub2video_flush(InputStream *ist)
 {
 int i;
+int ret;
 
 if (ist->sub2video.end_pts < INT64_MAX)
 sub2video_update(ist, NULL);
-for (i = 0; i < ist->nb_filters; i++)
-av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
+for (i = 0; i < ist->nb_filters; i++) {
+ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
+if (ret != AVERROR_EOF && ret < 0)
+av_log(NULL, AV_LOG_WARNING, "Flush the frame error.\n");
+}
 }
 
 /* end of sub2video hack */
@@ -327,13 +336,14 @@ static int main_return_code = 0;
 static void
 sigterm_handler(int sig)
 {
+int ret;
 received_sigterm = sig;
 received_nb_signals++;
 term_exit_sigsafe();
 if(received_nb_signals > 3) {
-write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard 
exiting\n",
-   strlen("Received > 3 system signals, hard 
exiting\n"));
-
+ret = write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard 
exiting\n",
+strlen("Received > 3 system signals, hard exiting\n"));
+if (ret < 0) { /* Do nothing */ };
 exit(123);
 }
 }
-- 
2.14.1




LGTM

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/1] avformat/dashenc: Added configuration to override HTTP User-Agent

2017-11-20 Thread


> 在 2017年11月20日,15:59,Jeyapal, Karthick <kjeya...@akamai.com> 写道:
> 
>> On 11/20/17, 1:01 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>>> 在 2017年11月8日,17:22,Karthick J <kjeya...@akamai.com> 写道:
>>> +{ "http_user_agent", "override User-Agent field in HTTP header", 
>>> OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
>> What about dash_user_agent? The reason is http_user_agent maybe get mean 
>> HTTP Protocol user_agent, but this is used in dashenc.
> 
> I kept http_user_agent to maintain uniformity with hlsenc option. 
> http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215642.html
> 
> In that way, irrespective of hls or dash output format, http_user_agent would 
> apply for both.
that should modify to hls_user_agent too. because that is clarified the option 
is used in dash or hls, isn’t it?
 
> 
> Regards,
> Karthick
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL

2017-11-19 Thread


> 在 2017年11月20日,15:43,Jun Zhao <mypopy...@gmail.com> 写道:
> 
> 
> 
> On 2017/11/20 15:35, 刘歧 wrote:
>> 
>>> 在 2017年11月20日,15:23,Jun Zhao <mypopy...@gmail.com> 写道:
>>> 
>>> 
>>> 
>>> On 2017/11/20 14:45, Steven Liu wrote:
>>>> fix ticket id: #6846
>>>> 
>>>> Signed-off-by: Steven Liu <l...@chinaffmpeg.org>
>>>> ---
>>>> libavformat/avio.c | 8 
>>>> 1 file changed, 8 insertions(+)
>>>> 
>>>> diff --git a/libavformat/avio.c b/libavformat/avio.c
>>>> index 4dc468350c..e719326660 100644
>>>> --- a/libavformat/avio.c
>>>> +++ b/libavformat/avio.c
>>>> @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h)
>>>> 
>>>> int ffurl_get_file_handle(URLContext *h)
>>>> {
>>>> +if (!h)
>>>> +return AVERROR(EINVAL);
>>>>if (!h->prot->url_get_file_handle)
>>> I think (!h && !h->prot && !h->prot->url_get_file_handle) more better
>>> than this
>> maybe you mean (!h || !h->port || !h->prot->url_get_file_handle) , is it?
> No, I means
> if (!h && !h->prot && !h->prot->url_get_file_handle)
>  Do somthing
will segmentation failed if !h is true, that is when h = NULL, and then get 
h->prot or h->prot->url_get_file_handle will in EXC_BAD_ACCESS.
So i this the better is (!h || !h->port || !h->prot->url_get_file_handle) 
return error.
> else
> return error;
> 
>>>>return -1;
>>>>return h->prot->url_get_file_handle(h);
>>>> @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h)
>>>> 
>>>> int ffurl_get_multi_file_handle(URLContext *h, int **handles, int 
>>>> *numhandles)
>>>> {
>>>> +if (!h)
>>>> +return AVERROR(EINVAL);
>>>>if (!h->prot->url_get_multi_file_handle) {
>>>>if (!h->prot->url_get_file_handle)
>>>>return AVERROR(ENOSYS);
>>>> @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int 
>>>> **handles, int *numhandles)
>>>> 
>>>> int ffurl_get_short_seek(URLContext *h)
>>>> {
>>>> +if (!h)
>>>> +return AVERROR(EINVAL);
>>>>if (!h->prot->url_get_short_seek)
>>>>return AVERROR(ENOSYS);
>>>>return h->prot->url_get_short_seek(h);
>>>> @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h)
>>>> 
>>>> int ffurl_shutdown(URLContext *h, int flags)
>>>> {
>>>> +if (!h)
>>>> +return AVERROR(EINVAL);
>>>>if (!h->prot->url_shutdown)
>>>>return AVERROR(EINVAL);
>>>>return h->prot->url_shutdown(h, flags);
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL

2017-11-19 Thread


> 在 2017年11月20日,15:23,Jun Zhao  写道:
> 
> 
> 
> On 2017/11/20 14:45, Steven Liu wrote:
>> fix ticket id: #6846
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavformat/avio.c | 8 
>> 1 file changed, 8 insertions(+)
>> 
>> diff --git a/libavformat/avio.c b/libavformat/avio.c
>> index 4dc468350c..e719326660 100644
>> --- a/libavformat/avio.c
>> +++ b/libavformat/avio.c
>> @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h)
>> 
>> int ffurl_get_file_handle(URLContext *h)
>> {
>> +if (!h)
>> +return AVERROR(EINVAL);
>> if (!h->prot->url_get_file_handle)
> I think (!h && !h->prot && !h->prot->url_get_file_handle) more better
> than this
maybe you mean (!h || !h->port || !h->prot->url_get_file_handle) , is it?
> 
>> return -1;
>> return h->prot->url_get_file_handle(h);
>> @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h)
>> 
>> int ffurl_get_multi_file_handle(URLContext *h, int **handles, int 
>> *numhandles)
>> {
>> +if (!h)
>> +return AVERROR(EINVAL);
>> if (!h->prot->url_get_multi_file_handle) {
>> if (!h->prot->url_get_file_handle)
>> return AVERROR(ENOSYS);
>> @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int 
>> **handles, int *numhandles)
>> 
>> int ffurl_get_short_seek(URLContext *h)
>> {
>> +if (!h)
>> +return AVERROR(EINVAL);
>> if (!h->prot->url_get_short_seek)
>> return AVERROR(ENOSYS);
>> return h->prot->url_get_short_seek(h);
>> @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h)
>> 
>> int ffurl_shutdown(URLContext *h, int flags)
>> {
>> +if (!h)
>> +return AVERROR(EINVAL);
>> if (!h->prot->url_shutdown)
>> return AVERROR(EINVAL);
>> return h->prot->url_shutdown(h, flags);



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/1] avformat/dashenc: Added configuration to override HTTP User-Agent

2017-11-19 Thread

> 在 2017年11月8日,17:22,Karthick J  写道:
> 
> ---
> doc/muxers.texi   |  2 ++
> libavformat/dashenc.c | 22 +++---
> 2 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 91bbe67..412fede 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -247,6 +247,8 @@ DASH-templated name to used for the initialization 
> segment. Default is "init-str
> DASH-templated name to used for the media segments. Default is 
> "chunk-stream$RepresentationID$-$Number%05d$.m4s"
> @item -utc_timing_url @var{utc_url}
> 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.
> @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 7813f44..a68f7fb 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -100,6 +100,7 @@ typedef struct DASHContext {
> const char *init_seg_name;
> const char *media_seg_name;
> const char *utc_timing_url;
> +const char *user_agent;
> } DASHContext;
> 
> static struct codec_string {
> @@ -210,6 +211,12 @@ static int flush_dynbuf(OutputStream *os, int 
> *range_length)
> return avio_open_dyn_buf(>ctx->pb);
> }
> 
> +static void set_http_options(AVDictionary **options, DASHContext *c)
> +{
> +if (c->user_agent)
> +av_dict_set(options, "user_agent", c->user_agent, 0);
> +}
> +
> static int flush_init_segment(AVFormatContext *s, OutputStream *os)
> {
> DASHContext *c = s->priv_data;
> @@ -575,16 +582,19 @@ static int write_manifest(AVFormatContext *s, int final)
> int use_rename = proto && !strcmp(proto, "file");
> static unsigned int warned_non_file = 0;
> AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
> +AVDictionary *opts = NULL;
> 
> if (!use_rename && !warned_non_file++)
> av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, this 
> may lead to races and temporary partial files\n");
> 
> snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
> "%s", s->filename);
> -ret = s->io_open(s, , temp_filename, AVIO_FLAG_WRITE, NULL);
> +set_http_options(, c);
> +ret = s->io_open(s, , temp_filename, AVIO_FLAG_WRITE, );
> if (ret < 0) {
> av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
> temp_filename);
> return ret;
> }
> +av_dict_free();
> avio_printf(out, "\n");
> avio_printf(out, " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n;
> "\txmlns=\"urn:mpeg:dash:schema:mpd:2011\"\n"
> @@ -768,9 +778,11 @@ static int dash_init(AVFormatContext *s)
> ff_dash_fill_tmpl_params(os->initfile, sizeof(os->initfile), 
> c->init_seg_name, i, 0, os->bit_rate, 0);
> }
> snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
> os->initfile);
> -ret = s->io_open(s, >out, filename, AVIO_FLAG_WRITE, NULL);
> +set_http_options(, c);
> +ret = s->io_open(s, >out, filename, AVIO_FLAG_WRITE, );
> if (ret < 0)
> return ret;
> +av_dict_free();
> os->init_start_pos = 0;
> 
> if (!strcmp(os->format_name, "mp4")) {
> @@ -974,12 +986,15 @@ static int dash_flush(AVFormatContext *s, int final, 
> int stream)
> }
> 
> if (!c->single_file) {
> +AVDictionary *opts = NULL;
> ff_dash_fill_tmpl_params(filename, sizeof(filename), 
> c->media_seg_name, i, os->segment_index, os->bit_rate, os->start_pts);
> snprintf(full_path, sizeof(full_path), "%s%s", c->dirname, 
> filename);
> snprintf(temp_path, sizeof(temp_path), use_rename ? "%s.tmp" : 
> "%s", full_path);
> -ret = s->io_open(s, >out, temp_path, AVIO_FLAG_WRITE, NULL);
> +set_http_options(, c);
> +ret = s->io_open(s, >out, temp_path, AVIO_FLAG_WRITE, );
> if (ret < 0)
> break;
> +av_dict_free();
> if (!strcmp(os->format_name, "mp4"))
> write_styp(os->ctx->pb);
> } else {
> @@ -1188,6 +1203,7 @@ static const AVOption options[] = {
> { "init_seg_name", "DASH-templated name to used for the initialization 
> segment", OFFSET(init_seg_name), AV_OPT_TYPE_STRING, {.str = 
> "init-stream$RepresentationID$.m4s"}, 0, 0, E },
> { "media_seg_name", "DASH-templated name to used for the media segments", 
> OFFSET(media_seg_name), AV_OPT_TYPE_STRING, {.str = 
> "chunk-stream$RepresentationID$-$Number%05d$.m4s"}, 0, 0, E },
> { "utc_timing_url", "URL of the page that will return the UTC 

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-19 Thread

> 在 2017年11月16日,17:01,Dixit, Vishwanath <vdi...@akamai.com> 写道:
> 
> 
> 
>> On 11/16/17, 12:09 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>> 
>>   FATE test passed:  Ubuntu, OS X, qemu+MIPS Linux,  wine MingW, qemu+ARM 
>> Linux, Thanks.
>> 
>> +if (p) {
>>   +strcpy(extension, p);
>>   What about use av_strlcpy ?
>> 
>> +while (q < varstr + strlen(varstr)) {
>>  +if (!strncmp(q, "a:", 2) || !strncmp(q, "v:", 2) ||
>>  +!strncmp(q, "s:", 2))
>>  What about use av_strcasecmp ?
>> 
>> +} else {
>>   +av_log(s, AV_LOG_ERROR, "Invalid keyval %s\n", keyval);
>>   +return -1;
>>   What about use return AVERROR(EINVAL)?
>> 
>> +} else {
>>  +av_log(s, AV_LOG_ERROR, "Unable to map stream at %s\n", 
>> keyval);
>>  +return -1;
>>  same as above.
>> 
>> +strrchr(master_url, '\\');
>>   +if (p) {
>>   +base_len = abs(p - master_url);
>>   use FFABS
>> 
>>  +if (strncmp(master_url, media_url, base_len)) {
>>  use av_strcasecmp
> 
> I have made updates for all the review comments. Please find the updated 
> patch set in the attachment.
> 
> 
> <0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch><0002-avformat-hlsenc-creation-of-hls-master-playlist-file.patch><0003-tests-fate-addition-of-test-case-for-hls-variant-str.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

pushed!




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Download dash content with byte range info

2017-11-18 Thread

> 在 2017年11月18日,07:13,Colin NG  写道:
> 
> ---
> libavformat/dashdec.c | 39 +--
> 1 file changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 0e3afd2..671ae9d 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -522,6 +522,25 @@ static enum AVMediaType get_content_type(xmlNodePtr node)
> return type;
> }
> 
> +static struct fragment * get_Fragment(char *range)
static struct fragment *get_fragment(char *range)
> +{
> +struct fragment * seg =  av_mallocz(sizeof(struct fragment));
> +
> +if (!seg)
> +return NULL;
> +
> +memset(seg, 0, sizeof(struct fragment));
remove memset.
> +seg->size = -1;
> +if (range)  {
> +char *str_end_offset;
> +char *str_offset = av_strtok(range, "-", _end_offset);
> +seg->url_offset = strtoll(str_offset, NULL, 10);
> +seg->size = strtoll(str_end_offset, NULL, 10) -seg->url_offset;
> +}
> +
> +return seg;
> +}
> +
> static int parse_manifest_segmenturlnode(AVFormatContext *s, struct 
> representation *rep,
>  xmlNodePtr fragmenturl_node,
>  xmlNodePtr *baseurl_nodes,
> @@ -530,33 +549,40 @@ static int 
> parse_manifest_segmenturlnode(AVFormatContext *s, struct representati
> {
> char *initialization_val = NULL;
> char *media_val = NULL;
> +char *range_val = NULL;
> 
> if (!av_strcasecmp(fragmenturl_node->name, (const char 
> *)"Initialization")) {
> initialization_val = xmlGetProp(fragmenturl_node, "sourceURL");
> -if (initialization_val) {
> -rep->init_section = av_mallocz(sizeof(struct fragment));
> +range_val = xmlGetProp(fragmenturl_node, "range");
> +if (initialization_val || range_val) {
> +rep->init_section = get_Fragment(range_val);
> if (!rep->init_section) {
> xmlFree(initialization_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> rep->init_section->url = get_content_url(baseurl_nodes, 4,
>  rep_id_val,
>  rep_bandwidth_val,
>  initialization_val);
> +
> if (!rep->init_section->url) {
> av_free(rep->init_section);
> xmlFree(initialization_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> -rep->init_section->size = -1;
> xmlFree(initialization_val);
> +xmlFree(range_val);
> }
> } else if (!av_strcasecmp(fragmenturl_node->name, (const char 
> *)"SegmentURL")) {
> media_val = xmlGetProp(fragmenturl_node, "media");
> -if (media_val) {
> -struct fragment *seg = av_mallocz(sizeof(struct fragment));
> +range_val = xmlGetProp(fragmenturl_node, "mediaRange");
> +if (media_val || range_val) {
> +struct fragment *seg =  get_Fragment(range_val);
> if (!seg) {
> xmlFree(media_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> seg->url = get_content_url(baseurl_nodes, 4,
> @@ -566,11 +592,12 @@ static int 
> parse_manifest_segmenturlnode(AVFormatContext *s, struct representati
> if (!seg->url) {
> av_free(seg);
> xmlFree(media_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> -seg->size = -1;
> dynarray_add(>fragments, >n_fragments, seg);
> xmlFree(media_val);
> +xmlFree(range_val);
> }
> }
> 
> -- 
> 2.7.4
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-16 Thread

> 在 2017年11月16日,17:28,Bang He <hezhanb...@gmail.com> 写道:
> 
> how to use the feature
1st, apply the patch into your ffmpeg project,
2nd, use the command looks like bellow:

./ffmpeg -f lavfi -i color=red -f lavfi –I anullsrc -g 25 -r 25 -b:v:0 1000k 
-b:v:1 256k -b:a:1 64k -b:a:1 32k  -map 0:v -map 1:a -map 0:v -map 1:a -f hls 
-var_stream_map "v:0,a:0  v:1,a:1" -master_pl_name  master.m3u8 -t 10 -hls_time 
2 output_sl.m3u8


> 
> On Thu, Nov 16, 2017 at 5:10 PM, 刘歧 <l...@chinaffmpeg.org> wrote:
> 
>> 
>>> 在 2017年11月16日,17:01,Dixit, Vishwanath <vdi...@akamai.com> 写道:
>>> 
>>> 
>>> 
>>>> On 11/16/17, 12:09 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>>>> 
>>>> FATE test passed:  Ubuntu, OS X, qemu+MIPS Linux,  wine MingW,
>> qemu+ARM Linux, Thanks.
>>>> 
>>>> +if (p) {
>>>> +strcpy(extension, p);
>>>> What about use av_strlcpy ?
>>>> 
>>>> +while (q < varstr + strlen(varstr)) {
>>>> +if (!strncmp(q, "a:", 2) || !strncmp(q, "v:", 2) ||
>>>> +!strncmp(q, "s:", 2))
>>>> What about use av_strcasecmp ?
>>>> 
>>>> +} else {
>>>> +av_log(s, AV_LOG_ERROR, "Invalid keyval %s\n",
>> keyval);
>>>> +return -1;
>>>> What about use return AVERROR(EINVAL)?
>>>> 
>>>> +} else {
>>>> +av_log(s, AV_LOG_ERROR, "Unable to map stream at
>> %s\n", keyval);
>>>> +return -1;
>>>> same as above.
>>>> 
>>>> +strrchr(master_url, '\\');
>>>> +if (p) {
>>>> +base_len = abs(p - master_url);
>>>> use FFABS
>>>> 
>>>> +if (strncmp(master_url, media_url, base_len)) {
>>>> use av_strcasecmp
>>> 
>>> I have made updates for all the review comments. Please find the updated
>> patch set in the attachment.
>>> 
>>> 
>>> <0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch><0002-
>> avformat-hlsenc-creation-of-hls-master-playlist-file.
>> patch><0003-tests-fate-addition-of-test-case-for-hls-
>> variant-str.patch>___
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> Patchset LGTM, i will apply these patch after 24 hours if there have no
>> objections
>> 
>> Thanks
>> 
>> 
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-16 Thread

> 在 2017年11月16日,17:15,Dixit, Vishwanath <vdi...@akamai.com> 写道:
> 
> 
>> On 11/16/17, 2:41 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>> 
>>   Patchset LGTM, i will apply these patch after 24 hours if there have no 
>> objections
> Thank you for the approval..
This is an awesome function, it is very useful :D
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-16 Thread

> 在 2017年11月16日,17:01,Dixit, Vishwanath <vdi...@akamai.com> 写道:
> 
> 
> 
>> On 11/16/17, 12:09 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>> 
>>   FATE test passed:  Ubuntu, OS X, qemu+MIPS Linux,  wine MingW, qemu+ARM 
>> Linux, Thanks.
>> 
>> +if (p) {
>>   +strcpy(extension, p);
>>   What about use av_strlcpy ?
>> 
>> +while (q < varstr + strlen(varstr)) {
>>  +if (!strncmp(q, "a:", 2) || !strncmp(q, "v:", 2) ||
>>  +!strncmp(q, "s:", 2))
>>  What about use av_strcasecmp ?
>> 
>> +} else {
>>   +av_log(s, AV_LOG_ERROR, "Invalid keyval %s\n", keyval);
>>   +return -1;
>>   What about use return AVERROR(EINVAL)?
>> 
>> +} else {
>>  +av_log(s, AV_LOG_ERROR, "Unable to map stream at %s\n", 
>> keyval);
>>  +return -1;
>>  same as above.
>> 
>> +strrchr(master_url, '\\');
>>   +if (p) {
>>   +base_len = abs(p - master_url);
>>   use FFABS
>> 
>>  +if (strncmp(master_url, media_url, base_len)) {
>>  use av_strcasecmp
> 
> I have made updates for all the review comments. Please find the updated 
> patch set in the attachment.
> 
> 
> <0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch><0002-avformat-hlsenc-creation-of-hls-master-playlist-file.patch><0003-tests-fate-addition-of-test-case-for-hls-variant-str.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patchset LGTM, i will apply these patch after 24 hours if there have no 
objections

Thanks



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-15 Thread

> 在 2017年11月15日,21:48,Dixit, Vishwanath <vdi...@akamai.com> 写道:
> 
> 
>> On 11/15/17, 9:56 AM, "刘歧" <l...@chinaffmpeg.org> wrote:
>>   all test info bellow:
>> 
>>   1st, look at the ffmpeg.exe banner 
>>   2nd, test with fate-filter-hls-append
>>   3nd, test with filter-hls-vs-with-master
>> 
>> 
>> /home/liuqi/ffmpeg/tests/fate-run.sh: 1: eval: ffmpeg.exe: not found
>>   make: *** [fate-filter-hls-vs-with-master] Error 1
>>   liuqi@localhost:~/ffmpeg/windows$
> 
> I have fixed the issue. Please find the updated patches in the attachment. 
> The following updates are made,
> 1. An additional FATE ‘run’ command was needed in the test to resolve 
> ‘ffmpeg.exe: not found’ issue.
> 2. Line splitter ‘\’ in make file was creating some sort of un-certainty in 
> test results between linux and windows. I have removed line splitter and have 
> made it a single line command. 
> 3. There are minor updates to resolve the compile time warnings.
> 
> <0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch><0002-avformat-hlsenc-creation-of-hls-master-playlist-file.patch><0003-tests-fate-addition-of-test-case-for-hls-variant-str.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

FATE test passed:  Ubuntu, OS X, qemu+MIPS Linux,  wine MingW, qemu+ARM Linux, 
Thanks.


> 0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch:

+static int format_name(char *name, int name_buf_len, int i)
+{
+char *p;
+char extension[10] = {'\0'};
+
+p = strrchr(name, '.');
+if (p) {
+strcpy(extension, p);
What about use av_strlcpy ?


+*p = '\0';
+}
+
+snprintf(name + strlen(name), name_buf_len - strlen(name), 
POSTFIX_PATTERN, i);
+
+if (strlen(extension))
+av_strlcat(name, extension, name_buf_len);
+
+return 0;
+}
+
+static int get_nth_codec_stream_index(AVFormatContext *s,
+  enum AVMediaType codec_type,
+  int stream_id)
+{
+unsigned int stream_index, cnt;
+if (stream_id < 0 || stream_id > s->nb_streams - 1)
+return -1;
+cnt = 0;
+for (stream_index = 0; stream_index < s->nb_streams; stream_index++) {
+if (s->streams[stream_index]->codecpar->codec_type != codec_type)
+continue;
+if (cnt == stream_id)
+return stream_index;
+cnt++;
+}
+return -1;
+}
+
+static int parse_variant_stream_mapstring(AVFormatContext *s)
+{
+HLSContext *hls = s->priv_data;
+VariantStream *vs;
+int stream_index;
+enum AVMediaType codec_type;
+int nb_varstreams, nb_streams;
+char *p, *q, *saveptr1, *saveptr2, *varstr, *keyval;
+const char *val;
+
+/**
+ * Expected format for var_stream_map string is as below:
+ * "a:0,v:0 a:1,v:1"
+ * This string specifies how to group the audio, video and subtitle streams
+ * into different variant streams. The variant stream groups are separated
+ * by space.
+ *
+ * a:, v:, s: are keys to specify audio, video and subtitle streams
+ * respectively. Allowed values are 0 to 9 digits (limited just based on
+ * practical usage)
+ *
+ */
+p = av_strdup(hls->var_stream_map);
+q = p;
+while(av_strtok(q, " \t", )) {
+q = NULL;
+hls->nb_varstreams++;
+}
+av_freep();
+
+hls->var_streams = av_mallocz(sizeof(*hls->var_streams) * 
hls->nb_varstreams);
+if (!hls->var_streams)
+return AVERROR(ENOMEM);
+
+p = hls->var_stream_map;
+nb_varstreams = 0;
+while (varstr = av_strtok(p, " \t", )) {
+p = NULL;
+
+if (nb_varstreams < hls->nb_varstreams)
+vs = &(hls->var_streams[nb_varstreams++]);
+else
+return -1;
+
+q = varstr;
+while (q < varstr + strlen(varstr)) {
+if (!strncmp(q, "a:", 2) || !strncmp(q, "v:", 2) ||
+!strncmp(q, "s:", 2))
What about use av_strcasecmp ?


+vs->nb_streams++;
+q++;
+}
+vs->streams = av_mallocz(sizeof(AVStream *) * vs->nb_streams);
+if (!vs->streams)
+return AVERROR(ENOMEM);
+
+nb_streams = 0;
+while (keyval = av_strtok(varstr, ",", )) {
+varstr = NULL;
+
+if (av_strstart(keyval, "v:", )) {
+codec_type = AVMEDIA_TYPE_VIDEO;
+} else if (av_strstart(keyval, "a:", )) {
+codec_type = AVMEDIA_TYPE_AUDIO;
+} else if (av_strstart(keyval, "s:", )) {
+codec_typ

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-14 Thread

> 在 2017年11月15日,07:14,Carl Eugen Hoyos <ceffm...@gmail.com> 写道:
> 
> 2017-11-14 11:25 GMT+01:00 刘歧 <l...@chinaffmpeg.org>:
> 
>> make fate failed:
>> 
>> ../configure --enable-gpl --enable-memory-poisoning --enable-avresample 
>> --cc='ccache arm-linux-gnueabi-gcc' --target-exec='qemu-arm -L 
>> /usr/arm-linux-gnueabi/' --arch=armv5te --cpu=armv5te --enable-cross-compile 
>> --target-os=linux --cross-prefix=/usr/arm-linux-gnueabi/bin/
>> 
>> root@localhost:~/ffmpeg/xxx# make fate-filter-hls-vs-with-master
>> GEN tests/data/hls-vs-with-master.m3u8
>> make: *** [tests/data/hls-vs-with-master.m3u8] Error 1
> 
> It seems to work here.
> 
> Could you run make V=1 fate-filter-hls-vs-with-master and
> test the resulting command manually so the error is shown?
> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


all test info bellow:

1st, look at the ffmpeg.exe banner 
2nd, test with fate-filter-hls-append
3nd, test with filter-hls-vs-with-master

liuqi@localhost:~/ffmpeg/windows$ ./ffmpeg.exe
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
err:systray:initialize_systray Could not create tray window
ffmpeg version N-89040-g58cf31c Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8 (GCC)
  configuration: --cc='ccache x86_64-w64-mingw32-gcc' --arch=x86_64 
--target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --disable-yasm 
--target_exec=wine
  libavutil  56.  0.100 / 56.  0.100
  libavcodec 58.  3.101 / 58.  3.101
  libavformat58.  2.102 / 58.  2.102
  libavdevice58.  0.100 / 58.  0.100
  libavfilter 7.  0.101 /  7.  0.101
  libswscale  5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] 
outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
liuqi@localhost:~/ffmpeg/windows$ make V=1 fate-filter-hls-append
TESTfilter-hls-append
/home/liuqi/ffmpeg/tests/fate-run.sh fate-filter-hls-append "" "wine " 
"/home/liuqi/ffmpeg/windows" 'framecrc -flags +bitexact -i 
/home/liuqi/ffmpeg/windows/tests/data/hls-list-append.m3u8 -af asetpts=RTCTIME' 
'' '' '' '1' '' '' '' '' '' '' '' '' ''
wine  /home/liuqi/ffmpeg/windows/ffmpeg -nostdin -nostats -cpuflags all -flags 
+bitexact -hwaccel none -threads 1 -thread_type frame+slice -i 
/home/liuqi/ffmpeg/windows/tests/data/hls-list-append.m3u8 -af asetpts=RTCTIME 
-flags +bitexact -fflags +bitexact -f framecrc -
liuqi@localhost:~/ffmpeg/windows$
liuqi@localhost:~/ffmpeg/windows$ make V=1 fate-filter-hls-vs-with-master
wine  /home/liuqi/ffmpeg/windows/ffmpeg.exe \
-f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -flags 
+bitexact -codec:a:0 mp2fixed -b:a:0 32k -codec:a:1 mp2fixed -b:a:1 128k -map 0 
-map 0 \
-f hls -var_stream_map "a:0 a:1" -hls_time 10 
-master_pl_name hls-master.m3u8 -hls_segment_filename 
/home/liuqi/ffmpeg/windows/tests/data/hls-vs-with-master-%03d.ts \
/home/liuqi/ffmpeg/windows/tests/data/hls-vs.m3u8 2>/dev/null
TESTfilter-hls-vs-with-master
/home/liuqi/ffmpeg/tests/fate-run.sh fate-filter-hls-vs-with-master "" "wine " 
"/home/liuqi/ffmpeg/windows" 'run ffmpeg.exe -nostdin -nostats -cpuflags all 
-flags +bitexact -hwaccel none -threads 1 -thread_type frame+slice -i 
/home/liuqi/ffmpeg/windows/tests/data/hls-vs_0.m3u8 -af asetpts=RTCTIME -flags 
+bitexact -fflags +bitexact -f framecrc - ; ffmpeg.exe -nostdin -nostats 
-cpuflags all \
  -flags +bitexact -hwaccel none -threads 1 -thread_type 
frame+slice \
  -i /home/liuqi/ffmpeg/windows/tests/data/hls-vs_1.m3u8 -af 
asetpts=RTCTIME -flags +bitexact -fflags +bitexact -f framecrc - ; cat 
/home/liuqi/ffmpeg/windows/tests/data/hls-master.m3u8' '' '' '' '1' '' '' '' '' 
'' '' '' '' ''
wine  /home/liuqi/ffmpeg/windows/ffmpeg.exe -nostdin -nostats -cpuflags all 
-flags +bitexact -hwaccel none -threads 1 -thread_type frame+slice -i 
/home/liuqi/ffmpeg/windows/tests/data/hls-vs_0.m3u8 -af asetpts=RTCTIME -flags 
+bitexact -fflags +bitexact -f framecrc -
--- /home/liuqi/ffmpeg/tests/ref/fate/filter-hls-vs-with-master 2017-11-14 
20:16:27.054005000 -0800
+++ tests/data/fate/filter-hls-vs-with-master   2017-11-14 20:24:07.358005000 
-0800
@@ -770,778 +770,6 @@
 0, 878976, 878976, 1152, 2304, 0xc52c95a6
 0, 880128, 880128, 1152, 2304, 0xde3f6929
 0, 881280, 881280, 1152, 2304, 0x5a798f16
-#tb 0: 1/44100
-#media_type 0: audio
-#codec_id 0: pcm_s16le
-#sample_rate 0: 44100
-#channel_layout

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-14 Thread

> 在 2017年11月14日,19:38,Dixit, Vishwanath <vdi...@akamai.com> 写道:
> 
> 
> 
>> On 11/14/17, 3:55 PM, "刘歧" <l...@chinaffmpeg.org> wrote: 
>>   make fate failed:
>> 
>>   ../configure --enable-gpl --enable-memory-poisoning --enable-avresample 
>> --cc='ccache arm-linux-gnueabi-gcc' --target-exec='qemu-arm -L 
>> /usr/arm-linux-gnueabi/' --arch=armv5te --cpu=armv5te --enable-cross-compile 
>> --target-os=linux --cross->prefix=/usr/arm-linux-gnueabi/bin/
>> 
>>   root@localhost:~/ffmpeg/xxx# make fate-filter-hls-vs-with-master
>>   GENtests/data/hls-vs-with-master.m3u8
>>   make: *** [tests/data/hls-vs-with-master.m3u8] Error 1
>>   root@localhost:~/ffmpeg/xxx#
> 
> I have tested it on x86 64bit Ubuntu platform.   The fate test passes. 
> 
> ./configure --enable-gpl --enable-memory-poisoning --enable-avresample
> sudo make -j4
> make fate-filter-hls-vs-with-master
> GEN   tests/data/hls-vs-with-master.m3u8
> TESTfilter-hls-vs-with-master
> 
> Currently, I do not have access to arm platform, so could you please help to 
> resolve this issue? If I am not asking too much, can you please provide error 
> file and report files generated, I will analyze them and find why the test is 
> failing.

https://trac.ffmpeg.org/wiki/CompilationGuide

need test passed on ARM Linux、   wine+MinGW 、 Ubuntu 、 MIPS Linux 、 OS X;  

> 
> Thanks & Regards,
> Vishwanath
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-14 Thread

> 在 2017年11月14日,14:42,Dixit, Vishwanath <vdi...@akamai.com> 写道:
> 
> 
> 
>> On 11/13/17, 3:28 PM, "刘歧" <l...@chinaffmpeg.org> wrote:
>> root@localhost:~/ffmpeg# patch -p1 < 
>> ~/0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch
>>   patching file doc/muxers.texi
>>   patching file libavformat/hlsenc.c
>>   Hunk #47 FAILED at 1622.
>>   1 out of 58 hunks FAILED -- saving rejects to file libavformat/hlsenc.c.rej
>>   patching file libavformat/version.h
>>   Hunk #1 FAILED at 33.
>>   1 out of 1 hunk FAILED -- saving rejects to file libavformat/version.h.rej
>>   liuqideMBP:ffmpeg liuqi$ git reset --hard
>>   HEAD is now at 43171a2a73 Fix missing used attribute for inline assembly 
>> variables
>>   liuqideMBP:ffmpeg liuqi$ git am 
>> ~/0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch
>>   fatal: previous rebase directory .git/rebase-apply still exists but mbox 
>> given.
>>   liuqideMBP:ffmpeg liuqi$
> 
> I have re-based the patches. Please find the updated patches in the 
> attachment.
> 
> <0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch><0002-avformat-hlsenc-creation-of-hls-master-playlist-file.patch><0003-tests-fate-addition-of-test-case-for-hls-variant-str.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

make fate failed:

../configure --enable-gpl --enable-memory-poisoning --enable-avresample 
--cc='ccache arm-linux-gnueabi-gcc' --target-exec='qemu-arm -L 
/usr/arm-linux-gnueabi/' --arch=armv5te --cpu=armv5te --enable-cross-compile 
--target-os=linux --cross-prefix=/usr/arm-linux-gnueabi/bin/

root@localhost:~/ffmpeg/xxx# make fate-filter-hls-vs-with-master
GEN tests/data/hls-vs-with-master.m3u8
make: *** [tests/data/hls-vs-with-master.m3u8] Error 1
root@localhost:~/ffmpeg/xxx#





___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: write fmp4 init header after first AV frame

2017-11-13 Thread

> 在 2017年11月13日,06:35,Aman Gupta  写道:
> 
> On Sun, Nov 12, 2017 at 5:29 AM, Steven Liu  wrote:
> 
>> fix ticket id: 6825
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavformat/hlsenc.c | 28 +---
>> 1 file changed, 25 insertions(+), 3 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 5ea9d216a4..3a4c8d65be 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -108,6 +108,9 @@ typedef struct HLSContext {
>> uint32_t start_sequence_source_type;  // enum StartSequenceSourceType
>> AVOutputFormat *oformat;
>> AVOutputFormat *vtt_oformat;
>> +AVIOContext *out;
>> +int packets_written;
>> +int init_range_length;
>> 
>> AVFormatContext *avf;
>> AVFormatContext *vtt_avf;
>> @@ -607,9 +610,14 @@ static int hls_mux_init(AVFormatContext *s)
>> av_log(s, AV_LOG_WARNING, "Multi-file byterange mode is
>> currently unsupported in the HLS muxer.\n");
>> return AVERROR_PATCHWELCOME;
>> }
>> +hls->packets_written = 0;
>> +hls->init_range_length = 0;
>> hls->fmp4_init_mode = !byterange_mode;
>> set_http_options(s, , hls);
>> -if ((ret = s->io_open(s, >pb, hls->base_output_dirname,
>> AVIO_FLAG_WRITE, )) < 0) {
>> +if ((ret = avio_open_dyn_buf(>pb)) < 0)
>> +return ret;
>> +
>> +if ((ret = s->io_open(s, >out, hls->base_output_dirname,
>> AVIO_FLAG_WRITE, )) < 0) {
>> av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n",
>> hls->fmp4_init_filename);
>> return ret;
>> }
>> @@ -634,6 +642,7 @@ static int hls_mux_init(AVFormatContext *s)
>> av_dict_free();
>> return AVERROR(EINVAL);
>> }
>> +avio_flush(oc->pb);
>> av_dict_free();
>> }
>> return 0;
>> @@ -1600,6 +1609,8 @@ static int hls_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> int is_ref_pkt = 1;
>> int ret = 0, can_split = 1;
>> int stream_index = 0;
>> +int range_length = 0;
>> +uint8_t *buffer = NULL;
>> 
>> if (hls->sequence - hls->nb_entries > hls->start_sequence &&
>> hls->init_time > 0) {
>> /* reset end_pts, hls->recording_time at end of the init hls list
>> */
>> @@ -1645,7 +1656,7 @@ static int hls_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> }
>> 
>> }
>> -if (hls->fmp4_init_mode || can_split && av_compare_ts(pkt->pts -
>> hls->start_pts, st->time_base,
>> +if (hls->packets_written && can_split && av_compare_ts(pkt->pts -
>> hls->start_pts, st->time_base,
>>end_pts, AV_TIME_BASE_Q) >= 0) {
>> int64_t new_start_pos;
>> char *old_filename = av_strdup(hls->avf->filename);
>> @@ -1661,7 +1672,17 @@ static int hls_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> hls->size = new_start_pos - hls->start_pos;
>> 
>> if (!byterange_mode) {
>> -ff_format_io_close(s, >pb);
>> +if (hls->segment_type == SEGMENT_TYPE_FMP4 &&
>> !hls->init_range_length) {
>> +avio_flush(oc->pb);
>> +range_length = avio_close_dyn_buf(oc->pb, );
>> +avio_write(hls->out, buffer, range_length);
>> +hls->init_range_length = range_length;
>> +avio_open_dyn_buf(>pb);
>> +hls->packets_written = 0;
>> +ff_format_io_close(s, >out);
>> +} else {
>> +ff_format_io_close(s, >pb);
>> +}
>> if (hls->vtt_avf) {
>> ff_format_io_close(s, >vtt_avf->pb);
>> }
>> @@ -1719,6 +1740,7 @@ static int hls_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> }
>> }
>> 
>> +hls->packets_written++;
>> ret = ff_write_chained(oc, stream_index, pkt, s, 0);
>> 
>> return ret;
>> 
> 
> Patch LGTM. I confirmed it fixes the issue in ticket 6825
Pushed



Thanks
> 
> 
>> --
>> 2.11.0 (Apple Git-81)
>> 
>> 
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-13 Thread

> 在 2017年11月8日,18:02,Dixit, Vishwanath  写道:
> 
> I have added the copyright statement as per our legal team requirements. I 
> have updated the patches again. Please consider the patches in this mail 
> attachment as latest. Sorry for any inconvenience.
> 
> Regards,
> Vishwanath
> 
> <0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch><0002-avformat-hlsenc-creation-of-hls-master-playlist-file.patch><0003-tests-fate-addition-of-test-case-for-hls-variant-str.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


root@localhost:~/ffmpeg# patch -p1 < 
~/0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch
patching file doc/muxers.texi
patching file libavformat/hlsenc.c
Hunk #47 FAILED at 1622.
1 out of 58 hunks FAILED -- saving rejects to file libavformat/hlsenc.c.rej
patching file libavformat/version.h
Hunk #1 FAILED at 33.
1 out of 1 hunk FAILED -- saving rejects to file libavformat/version.h.rej
liuqideMBP:ffmpeg liuqi$ git reset --hard
HEAD is now at 43171a2a73 Fix missing used attribute for inline assembly 
variables
liuqideMBP:ffmpeg liuqi$ git am 
~/0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch
fatal: previous rebase directory .git/rebase-apply still exists but mbox given.
liuqideMBP:ffmpeg liuqi$


Thanks

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/dashdec: fix memleak of rep_dest->parent null

2017-11-09 Thread

> 在 2017年11月9日,16:28,Carl Eugen Hoyos  写道:
> 
> Hi!
> 
>> Am 09.11.2017 um 00:52 schrieb Steven Liu :
>> 
>> fix ticket id: #6820
> 
> I find the commit message misleading.
> 
>> use the current DASHContext for the rep_dest
> 
> This may be better imo.
ok, i will use this line to make commit message leading “use the current 
DASHContext for the rep_dest”

> 
> Thank you, Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-08 Thread

> 在 2017年11月8日,18:02,Dixit, Vishwanath  写道:
> 
> I have added the copyright statement as per our legal team requirements. I 
> have updated the patches again. Please consider the patches in this mail 
> attachment as latest. Sorry for any inconvenience.
Add  Aman Gupta, DeHackEd, Hendrik Leppkes, Bela Bodecs, Nicolas George etc. 
and me too :D 

Thanks
> 
> Regards,
> Vishwanath
> 
> <0001-avformat-hlsenc-creation-of-hls-variant-streams-in-a.patch><0002-avformat-hlsenc-creation-of-hls-master-playlist-file.patch><0003-tests-fate-addition-of-test-case-for-hls-variant-str.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: creation of hls variant streams with master playlist in a single hlsenc instance

2017-11-03 Thread

> 在 2017年11月3日,18:20,Dixit, Vishwanath  写道:
> 
>> On 11/3/17, 3:24 PM, "Steven Liu"  wrote:
>> make fate-filter-hls-append
>> 
>>   you can grep hls append in the file
> I think that is also a test for hls decoder. Basically, I am trying to find, 
> if there are any basic tests available for hls encoder.
look at your mail title please!
and read the test case which i write for the fate-filter-hls-append
> 
> Regards,
> Vishwanath
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return valueafter reading a metadata packet

2017-10-26 Thread
-- Original --
From:  "Carl Eugen Hoyos";
Date:  Fri, Oct 27, 2017 04:22 AM
To:  "FFmpeg development discussions and patches";
Subject:  Re: [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return 
valueafter reading a metadata packet
 
2017-09-05 18:38 GMT+02:00 Steven Liu :
> COPY FROM libav Martin Storsjö 

This should have been the author information of the patch
instead of part of the commit message, you removed it
completely from the actual commit;-(

Imo, the best solution is that you revert this patch and commit
a patch with the correct author information and push both.

have revert and commit by author Martin Storsjö 
and pushed!

Thanks

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v15] avformat/dashdec: add dash demuxer base version

2017-08-30 Thread

> 在 2017年8月30日,16:15,samsamsam <samsam...@o2.pl> 写道:
> 
> Sorry, my fault. Such simple check proposed by me is incorrect.
> It not handle basic "%05d" format.
That’s no matter samsamsam, if the string is not standard as specification 
describe, the result maybe need give an error.
So that is not a generic template, so fix it later :P
> 
> Dnia 30 sierpnia 2017 09:56 samsamsam <samsam...@o2.pl> napisał(a):
> 
> What will happen when $Number%02s%08d$
> 
> Error will be returned because this format is not valid in the sense of dash 
> spec.
> 
> Dnia 30 sierpnia 2017 09:39 刘歧 <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月30日,15:32,刘歧 <l...@chinaffmpeg.org> 写道:
> 
> 
> 在 2017年8月30日,14:38,samsamsam <samsam...@o2.pl> 写道:
> 
> But you do not added this:
> static int get_repl_pattern_and_format(const char *i_url, const char 
> *i_marker, char **o_pattern, char **o_format)
> {
> ...
> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
> need to check this condition :P */
> +if (*ptr != '0') {
> What will happen when $Number%02s%08d$
> 
> Test passed, now i have use a new function named get_segment_filename and the 
> get_current_fragment,
> that would check the file name ok or not.
> +   // Unknown format add log here
> +goto finish;
> +}
> +}
> format_len = end - start - marker_len - 1 + strlen(PRId64);
> *o_format = av_mallocz(format_len+1);
> strncpy(*o_format, start + marker_len, end - start - marker_len -1);
> strcat(*o_format, PRId64);
> …
> }
> 
> modification. Right?
> 
> Dnia 30 sierpnia 2017 00:04 Liu Steven <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月30日,上午3:30,samsamsam <samsam...@o2.pl> 写道:
> 
> and think about the safety :
> %02c%lld
> %s%d%d%d%d
> 
> What? With my solution this is not problem.
> Why you think %s%d%d%d%d or %02c%lld give any problem?
> 
> localhost:dash StevenLiu$ ./ffmpeg -i /tmp/dash.mpd
> ffmpeg version N-87079-g257f0d09f7 Copyright (c) 2000-2017 the FFmpeg 
> developers
> built with Apple LLVM version 8.1.0 (clang-802.0.42)
> configuration: --enable-libass --enable-opengl --enable-libx264 
> --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local 
> --enable-libopencv --enable-libtesseract --enable-libspeex 
> --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac 
> --enable-videotoolbox --enable-libxml2
> libavutil  55. 74.100 / 55. 74.100
> libavcodec 57.103.101 / 57.103.101
> libavformat57. 78.100 / 57. 78.100
> libavdevice57.  7.101 / 57.  7.101
> libavfilter 6.100.100 /  6.100.100
> libswscale  4.  7.103 /  4.  7.103
> libswresample   2.  8.100 /  2.  8.100
> libpostproc54.  6.100 / 54.  6.100
> [dash @ 0x7ffb76802a00] 11
> Segmentation fault: 11ted 1 times
> localhost:dash StevenLiu$ grep -r "%s%05d" /tmp/dash.mpd
> /tmp/dash.mpd: initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1">
> localhost:dash StevenLiu$
> 
> reproduce:
> ffmpeg -i input -c copy -f dash /tmp/dash.mpd
> vim /tmp/dash.mpd
> seek to `media="chunk-stream$RepresentationID`
> the context is `  initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1”>`
> modify to:
>  initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1”>
> 
> use your solution:
> ./ffmpeg -i /tmp/dash.mpd
> 
> 
> 
> 
> Dnia 28 sierpnia 2017 12:27 刘歧 <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月28日,18:12,samsamsam <samsam...@o2.pl> 写道:
> 
> Validation will be very simple. I am talking about something like this:
> static int get_repl_pattern_and_format(const char *i_url, const char 
> *i_marker, char **o_pattern, char **o_format)
> {
> ...
> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
> need to check this condition :P */
> +if (*ptr != '0') {
> +   // Unknown format add log here
> +goto finish;
> +}
> +}
> format_len = end - start - marker_len - 1 + strlen(PRId64);
> *o_format = av_mallocz(format_len+1);
> strncpy(*o_format, start + marker_len, end - start - marker_len -1);
> strcat(*o_format, PRId64);
> …
> }
> maybe more complex than this way, for example:
> %d
> %lld
> %04lld
> %PRId64
> %P

Re: [FFmpeg-devel] [PATCH v15] avformat/dashdec: add dash demuxer base version

2017-08-30 Thread

> 在 2017年8月30日,15:52,samsamsam <samsam...@o2.pl> 写道:
> 
> What will happen when $Number%02s%08d$
> 
> Exacly. Such format is not allowed by dash specification. So, such validation 
> is sufficient.
> 
> Please check DASH specification format like that $Number%02s%08d$ is not 
> allowed. 
> So what for you want to allow it?
No, you have not get the point.
The hackers won’t refer to specification and just broke the rule to get root 
shell.

Anyway, merge your code and will update a new version patch later.

> 
> Dnia 30 sierpnia 2017 09:32 刘歧 <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月30日,14:38,samsamsam <samsam...@o2.pl> 写道:
> 
> But you do not added this:
> static int get_repl_pattern_and_format(const char *i_url, const char 
> *i_marker, char **o_pattern, char **o_format)
> {
> ...
> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
> need to check this condition :P */
> +if (*ptr != '0') {
> What will happen when $Number%02s%08d$
> +   // Unknown format add log here
> +goto finish;
> +}
> +}
>  format_len = end - start - marker_len - 1 + strlen(PRId64);
>  *o_format = av_mallocz(format_len+1);
>  strncpy(*o_format, start + marker_len, end - start - marker_len -1);
>  strcat(*o_format, PRId64);
> …
> }
> 
> modification. Right?
> 
> Dnia 30 sierpnia 2017 00:04 Liu Steven <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月30日,上午3:30,samsamsam <samsam...@o2.pl> 写道:
> 
> and think about the safety :
> %02c%lld
> %s%d%d%d%d
> 
> What? With my solution this is not problem.
> Why you think %s%d%d%d%d or %02c%lld give any problem?
> 
> localhost:dash StevenLiu$ ./ffmpeg -i /tmp/dash.mpd
> ffmpeg version N-87079-g257f0d09f7 Copyright (c) 2000-2017 the FFmpeg 
> developers
> built with Apple LLVM version 8.1.0 (clang-802.0.42)
> configuration: --enable-libass --enable-opengl --enable-libx264 
> --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local 
> --enable-libopencv --enable-libtesseract --enable-libspeex 
> --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac 
> --enable-videotoolbox --enable-libxml2
> libavutil  55. 74.100 / 55. 74.100
> libavcodec 57.103.101 / 57.103.101
> libavformat57. 78.100 / 57. 78.100
> libavdevice57.  7.101 / 57.  7.101
> libavfilter 6.100.100 /  6.100.100
> libswscale  4.  7.103 /  4.  7.103
> libswresample   2.  8.100 /  2.  8.100
> libpostproc54.  6.100 / 54.  6.100
> [dash @ 0x7ffb76802a00] 11
> Segmentation fault: 11ted 1 times
> localhost:dash StevenLiu$ grep -r "%s%05d" /tmp/dash.mpd
> /tmp/dash.mpd: initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1">
> localhost:dash StevenLiu$
> 
> reproduce:
> ffmpeg -i input -c copy -f dash /tmp/dash.mpd
> vim /tmp/dash.mpd
> seek to `media="chunk-stream$RepresentationID`
> the context is `  initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1”>`
> modify to:
>  initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1”>
> 
> use your solution:
> ./ffmpeg -i /tmp/dash.mpd
> 
> 
> 
> 
> Dnia 28 sierpnia 2017 12:27 刘歧 <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月28日,18:12,samsamsam <samsam...@o2.pl> 写道:
> 
> Validation will be very simple. I am talking about something like this:
> static int get_repl_pattern_and_format(const char *i_url, const char 
> *i_marker, char **o_pattern, char **o_format)
> {
> ...
> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
> need to check this condition :P */
> +if (*ptr != '0') {
> +   // Unknown format add log here
> +goto finish;
> +}
> +}
>  format_len = end - start - marker_len - 1 + strlen(PRId64);
>  *o_format = av_mallocz(format_len+1);
>  strncpy(*o_format, start + marker_len, end - start - marker_len -1);
>  strcat(*o_format, PRId64);
> …
> }
> maybe more complex than this way, for example:
> %d
> %lld
> %04lld
> %PRId64
> %PRId32
> %PRId16
> 
> and think about the safety :
> %02c%lld
> %s%d%d%d%d
> 
> and so on,blablabla.
> 
> maybe we need to think a perfect solution.
> 
> 
> 
> 
> Dnia 28 sierpnia 2017 11:30 Rodger Combs <rodger.co...@gmail.co

Re: [FFmpeg-devel] [PATCH v15] avformat/dashdec: add dash demuxer base version

2017-08-30 Thread

> 在 2017年8月30日,15:32,刘歧 <l...@chinaffmpeg.org> 写道:
> 
> 
>> 在 2017年8月30日,14:38,samsamsam <samsam...@o2.pl> 写道:
>> 
>> But you do not added this:
>> static int get_repl_pattern_and_format(const char *i_url, const char 
>> *i_marker, char **o_pattern, char **o_format)
>> {
>> ...
>> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
>> need to check this condition :P */
>> +if (*ptr != '0') {
> What will happen when $Number%02s%08d$ 

Test passed, now i have use a new function named get_segment_filename and the 
get_current_fragment,
that would check the file name ok or not.
>> +   // Unknown format add log here
>> +goto finish;
>> +}
>> +}
>>  format_len = end - start - marker_len - 1 + strlen(PRId64);
>>  *o_format = av_mallocz(format_len+1);
>>  strncpy(*o_format, start + marker_len, end - start - marker_len -1);
>>  strcat(*o_format, PRId64);
>> …
>> }
>> 
>> modification. Right?
>> 
>> Dnia 30 sierpnia 2017 00:04 Liu Steven <l...@chinaffmpeg.org> napisał(a):
>> 
>> 在 2017年8月30日,上午3:30,samsamsam <samsam...@o2.pl> 写道:
>> 
>> and think about the safety :
>> %02c%lld
>> %s%d%d%d%d
>> 
>> What? With my solution this is not problem.
>> Why you think %s%d%d%d%d or %02c%lld give any problem?
>> 
>> localhost:dash StevenLiu$ ./ffmpeg -i /tmp/dash.mpd
>> ffmpeg version N-87079-g257f0d09f7 Copyright (c) 2000-2017 the FFmpeg 
>> developers
>> built with Apple LLVM version 8.1.0 (clang-802.0.42)
>> configuration: --enable-libass --enable-opengl --enable-libx264 
>> --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local 
>> --enable-libopencv --enable-libtesseract --enable-libspeex 
>> --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac 
>> --enable-videotoolbox --enable-libxml2
>> libavutil  55. 74.100 / 55. 74.100
>> libavcodec 57.103.101 / 57.103.101
>> libavformat57. 78.100 / 57. 78.100
>> libavdevice57.  7.101 / 57.  7.101
>> libavfilter 6.100.100 /  6.100.100
>> libswscale  4.  7.103 /  4.  7.103
>> libswresample   2.  8.100 /  2.  8.100
>> libpostproc54.  6.100 / 54.  6.100
>> [dash @ 0x7ffb76802a00] 11
>> Segmentation fault: 11ted 1 times
>> localhost:dash StevenLiu$ grep -r "%s%05d" /tmp/dash.mpd
>> /tmp/dash.mpd:   > initialization="init-stream$RepresentationID$.m4s" 
>> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1">
>> localhost:dash StevenLiu$
>> 
>> reproduce:
>> ffmpeg -i input -c copy -f dash /tmp/dash.mpd
>> vim /tmp/dash.mpd
>> seek to `media="chunk-stream$RepresentationID`
>> the context is ` > initialization="init-stream$RepresentationID$.m4s" 
>> media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1”>`
>> modify to:
>> > initialization="init-stream$RepresentationID$.m4s" 
>> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1”>
>> 
>> use your solution:
>> ./ffmpeg -i /tmp/dash.mpd
>> 
>> 
>> 
>> 
>> Dnia 28 sierpnia 2017 12:27 刘歧 <l...@chinaffmpeg.org> napisał(a):
>> 
>> 在 2017年8月28日,18:12,samsamsam <samsam...@o2.pl> 写道:
>> 
>> Validation will be very simple. I am talking about something like this:
>> static int get_repl_pattern_and_format(const char *i_url, const char 
>> *i_marker, char **o_pattern, char **o_format)
>> {
>> ...
>> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
>> need to check this condition :P */
>> +if (*ptr != '0') {
>> +   // Unknown format add log here
>> +goto finish;
>> +}
>> +}
>>  format_len = end - start - marker_len - 1 + strlen(PRId64);
>>  *o_format = av_mallocz(format_len+1);
>>  strncpy(*o_format, start + marker_len, end - start - marker_len -1);
>>  strcat(*o_format, PRId64);
>> …
>> }
>> maybe more complex than this way, for example:
>> %d
>> %lld
>> %04lld
>> %PRId64
>> %PRId32
>> %PRId16
>> 
>> and think about the safety :
>> %02c%lld
>> %s%d%d%d%d
>> 
>> and so on,blablabla.
>> 
>> maybe we need to think a perfect solution.
>> 
>> 
>> 
>> 
>> Dnia 28 sierpnia 2017 11:30

Re: [FFmpeg-devel] [PATCH v15] avformat/dashdec: add dash demuxer base version

2017-08-30 Thread

> 在 2017年8月30日,14:38,samsamsam <samsam...@o2.pl> 写道:
> 
> But you do not added this:
> static int get_repl_pattern_and_format(const char *i_url, const char 
> *i_marker, char **o_pattern, char **o_format)
> {
> ...
> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
> need to check this condition :P */
> +if (*ptr != '0') {
What will happen when $Number%02s%08d$ 
> +   // Unknown format add log here
> +goto finish;
> +}
> +}
>   format_len = end - start - marker_len - 1 + strlen(PRId64);
>   *o_format = av_mallocz(format_len+1);
>   strncpy(*o_format, start + marker_len, end - start - marker_len -1);
>   strcat(*o_format, PRId64);
> …
> }
> 
> modification. Right?
> 
> Dnia 30 sierpnia 2017 00:04 Liu Steven <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月30日,上午3:30,samsamsam <samsam...@o2.pl> 写道:
> 
> and think about the safety :
> %02c%lld
> %s%d%d%d%d
> 
> What? With my solution this is not problem.
> Why you think %s%d%d%d%d or %02c%lld give any problem?
> 
> localhost:dash StevenLiu$ ./ffmpeg -i /tmp/dash.mpd
> ffmpeg version N-87079-g257f0d09f7 Copyright (c) 2000-2017 the FFmpeg 
> developers
> built with Apple LLVM version 8.1.0 (clang-802.0.42)
> configuration: --enable-libass --enable-opengl --enable-libx264 
> --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local 
> --enable-libopencv --enable-libtesseract --enable-libspeex 
> --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac 
> --enable-videotoolbox --enable-libxml2
> libavutil  55. 74.100 / 55. 74.100
> libavcodec 57.103.101 / 57.103.101
> libavformat57. 78.100 / 57. 78.100
> libavdevice57.  7.101 / 57.  7.101
> libavfilter 6.100.100 /  6.100.100
> libswscale  4.  7.103 /  4.  7.103
> libswresample   2.  8.100 /  2.  8.100
> libpostproc54.  6.100 / 54.  6.100
> [dash @ 0x7ffb76802a00] 11
> Segmentation fault: 11ted 1 times
> localhost:dash StevenLiu$ grep -r "%s%05d" /tmp/dash.mpd
> /tmp/dash.mpd: initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1">
> localhost:dash StevenLiu$
> 
> reproduce:
> ffmpeg -i input -c copy -f dash /tmp/dash.mpd
> vim /tmp/dash.mpd
> seek to `media="chunk-stream$RepresentationID`
> the context is `  initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1”>`
> modify to:
>  initialization="init-stream$RepresentationID$.m4s" 
> media="chunk-stream$RepresentationID$-$Number%s%05d$.m4s" startNumber="1”>
> 
> use your solution:
> ./ffmpeg -i /tmp/dash.mpd
> 
> 
> 
> 
> Dnia 28 sierpnia 2017 12:27 刘歧 <l...@chinaffmpeg.org> napisał(a):
> 
> 在 2017年8月28日,18:12,samsamsam <samsam...@o2.pl> 写道:
> 
> Validation will be very simple. I am talking about something like this:
> static int get_repl_pattern_and_format(const char *i_url, const char 
> *i_marker, char **o_pattern, char **o_format)
> {
> ...
> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
> need to check this condition :P */
> +if (*ptr != '0') {
> +   // Unknown format add log here
> +goto finish;
> +}
> +}
>   format_len = end - start - marker_len - 1 + strlen(PRId64);
>   *o_format = av_mallocz(format_len+1);
>   strncpy(*o_format, start + marker_len, end - start - marker_len -1);
>   strcat(*o_format, PRId64);
> …
> }
> maybe more complex than this way, for example:
> %d
> %lld
> %04lld
> %PRId64
> %PRId32
> %PRId16
> 
> and think about the safety :
> %02c%lld
> %s%d%d%d%d
> 
> and so on,blablabla.
> 
> maybe we need to think a perfect solution.
> 
> 
> 
> 
> Dnia 28 sierpnia 2017 11:30 Rodger Combs <rodger.co...@gmail.com> napisał(a):
> 
> I would expect parsing the number internally and using the additional arg to 
> be simpler and easier to verify than format string validation.
> 
> On Aug 28, 2017, at 04:28, samsamsam <samsam...@o2.pl> wrote:
> 
> OK. I will.
> What about adding validation of format instead of adding "something like 
> `"%0*"PRId64`"?
> 
> Dnia 28 sierpnia 2017 03:30 Rodger Combs <rodger.co...@gmail.com> napisał(a):
> 
> If you know of such a vulnerability, report it to ffmpeg-secur...@ffmpeg.org. 
> New code with known vulnerabilities will not be accepted.
&g

Re: [FFmpeg-devel] [PATCH v15] avformat/dashdec: add dash demuxer base version

2017-08-28 Thread

> 在 2017年8月28日,18:12,samsamsam  写道:
> 
> Validation will be very simple. I am talking about something like this:
> static int get_repl_pattern_and_format(const char *i_url, const char 
> *i_marker, char **o_pattern, char **o_format) 
> {
> ...
> +for(ptr=start + marker_len; ptr < (end - 1); ++ptr) {  /*there is 
> need to check this condition :P */
> +if (*ptr != '0') {
> +   // Unknown format add log here 
> +goto finish;
> +}
> +}
> format_len = end - start - marker_len - 1 + strlen(PRId64);
> *o_format = av_mallocz(format_len+1);
> strncpy(*o_format, start + marker_len, end - start - marker_len -1);
> strcat(*o_format, PRId64);
> …
> }
maybe more complex than this way, for example:
%d
%lld
%04lld
%PRId64
%PRId32
%PRId16

and think about the safety :
%02c%lld
%s%d%d%d%d

and so on,blablabla.

maybe we need to think a perfect solution.


> 
> 
> Dnia 28 sierpnia 2017 11:30 Rodger Combs  napisał(a):
> 
> I would expect parsing the number internally and using the additional arg to 
> be simpler and easier to verify than format string validation.
> 
>> On Aug 28, 2017, at 04:28, samsamsam  wrote:
>> 
>> OK. I will.
>> What about adding validation of format instead of adding "something like 
>> `"%0*"PRId64`"?
>> 
>> Dnia 28 sierpnia 2017 03:30 Rodger Combs  napisał(a):
>> 
>> If you know of such a vulnerability, report it to 
>> ffmpeg-secur...@ffmpeg.org. New code with known vulnerabilities will not be 
>> accepted.
>> 
>> Sent from my iPhone
>> 
>> On Aug 27, 2017, at 14:04, samsamsam  wrote:
>>> get_repl_pattern_and_format, you should have a fixed value of something 
>>> like `"%0*"PRId64`
>>> 
>>> If you afraid about safety then the only thing which need to be added to 
>>> get_repl_pattern_and_format is validation of format.
>>> Simple loop to validate format will be enough. Do you agree? 
>>> 
>>> Anyway we are talking about safety but parser for mp4 atoms missing 
>>> checking and there is quite easy to make segfault of the libavformat when 
>>> try to prepared mp4 file.
>>> 
>>> I understand that you want to have maximum safety with new code but I hope 
>>> you know that ffmpeg at all is not safety.
>>> 
>>> Regards,
>>> SSS
>>> 
>>> Dnia 27 sierpnia 2017 16:34 Rodger Combs  
>>> napisał(a):
>>> 
>>> You're still calling snprintf with a string derived from the XML, which is 
>>> still not safe. Rather than having a format copied from the source in 
>>> get_repl_pattern_and_format, you should have a fixed value of something 
>>> like `"%0*"PRId64`, and specify an additional "precision" argument you 
>>> parse from the XML yourself. I can't reiterate this enough: _never pass 
>>> data from the XML into the format-string arg of a printf-family function_.
>>> 
>>> Also, rather than calling snprintf() twice with an av_malloc() in between, 
>>> you can just call av_asprintf(). That's what it does internally anyway.
>>> 
>>> On Aug 27, 2017, at 09:19, Steven Liu  wrote:
>>> 
>>> ffmpeg need a dash demuxer for demux the dash formats base on
>>> https://github.com/samsamsam-iptvplayer/exteplayer3/blob/master/tmp/ffmpeg/patches/3.2.2/01_add_dash_demux.patch
>>> 
>>> TODO:
>>> 1. support multi bitrate dash
>>> 
>>> v2 fixed:
>>> 1. from autodetect to disabled
>>> 2. from camelCase code style to ffmpeg code style
>>> 3. from RepType to AVMediaType
>>> 4. fix variable typo
>>> 5. change time value from uint32_t to uint64_t
>>> 6. removed be used once API
>>> 7. change 'time(NULL)`, except it is not 2038-safe.' to av_gettime and 
>>> av_timegm
>>> 8. merge complex free operation to free_fragment
>>> 9. use API from snprintf to av_asprintf
>>> 
>>> v3 fixed:
>>> 1. fix typo from --enabled-xml2 to --enable-xml2
>>> 
>>> v4 fixed:
>>> 1. from --enable-xml2 to --enable-libxml2
>>> 2. move system includes to top
>>> 3. remove nouse includes
>>> 4. rename enum name
>>> 5. add a trailing comma for the last entry enum
>>> 6. fix comment typo
>>> 7. add const to DASHContext class front
>>> 8. check sscanf if return arguments and give warning message when error
>>> 9. check validity before free seg->url and seg
>>> 10. check if the val is null, before use atoll
>>> 
>>> v5 fixed:
>>> 1. fix typo from mainifest to manifest
>>> 
>>> v6 fixed:
>>> 1. from realloc to av_realloc
>>> 2. from free to av_free
>>> 
>>> v7 fixed:
>>> 1. remove the -lxml2 from configure when require_pkg_config
>>> 
>>> v8 fixed:
>>> 1. fix replace filename template by av_asprintf secure problem
>>> 
>>> v9 modified:
>>> 1. make manifest parser clearly
>>> 
>>> v10 fixed:
>>> 1. fix function API name code style
>>> 2. remove redundant strreplace call
>>> 3. remove redundant memory operation and check return value from 
>>> get_content_url()
>>> 4. add space between ) and {
>>> 5. remove no need to log the 

Re: [FFmpeg-devel] [PATCH V2] examples/vaapi_dec: Add a VA-APIhwaccel decoding example

2017-07-10 Thread

> On Jul 11, 2017, at 12:49 PM, liyoubdu <liyou...@qq.com> wrote:
> 
> where is your media file for testinfg
me?
> 
> 
> 
> ---Original---
> From: "刘歧"<l...@chinaffmpeg.org>
> Date: 2017/7/11 12:39:31
> To: "and patches development discussions FFmpeg"<ffmpeg-devel@ffmpeg.org>;
> Cc: "wm4"<nfx...@googlemail.com>;"Mark 
> Thompson"<s...@jkqxz.net>;"刘歧"<l...@chinaffmpeg.org>;"Liu, 
> Kaixuan"<kaixuan@intel.com>;
> Subject: Re: [FFmpeg-devel] [PATCH V2] examples/vaapi_dec: Add a 
> VA-APIhwaccel decoding example
> 
> 
> From 0e4d230ae4c98949a962c6bbdad31d216b54bb6a Mon Sep 17 00:00:00 2001
> From: Jun Zhao <jun.z...@intel.com>
> Date: Tue, 21 Mar 2017 11:04:41 +0800
> Subject: [V2] examples/vaapi_dec: Add a VA-API hwaccel decoding example.
> 
> Add a VA-API hwaccel decoding example.
> 
> Signed-off-by: Liu, Kaixuan <kaixuan@intel.com>
> Signed-off-by: Jun Zhao <jun.z...@intel.com>
> ---
> doc/examples/vaapi_dec.c | 266 +++
> 1 file changed, 266 insertions(+)
> create mode 100644 doc/examples/vaapi_dec.c
> 
> diff --git a/doc/examples/vaapi_dec.c b/doc/examples/vaapi_dec.c
> new file mode 100644
> index 00..01320a3b71
> --- /dev/null
> +++ b/doc/examples/vaapi_dec.c
> @@ -0,0 +1,266 @@
> +/*
> + * Video Acceleration API (video decoding) decode sample
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * Intel VAAPI-accelerated decoding example.
> + *
> + * @example vaapi_dec.c
> + * This example shows how to do VAAPI-accelerated decoding with output
> + * frames from the VAAPI video surfaces.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static AVBufferRef *hw_device_ctx = NULL;
> +FILE *output_file = NULL;
> +
> +int decoder_init_vaapi(AVCodecContext *ctx)
> +{
> +int err = 0;
> +const char *dev_name = "/dev/dri/renderD128";
> +
> +if ((err = av_hwdevice_ctx_create(_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
> +  dev_name, NULL, 0)) < 0) {
> +fprintf(stderr, "Failed to create a VAAPI device.\n");
> +return err;
> +}
> +ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
> +
> +return err;
> +}
> +
> +static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
> +   const enum AVPixelFormat 
> *pix_fmts)
> +{
> +const enum AVPixelFormat *p;
> +
> +for (p = pix_fmts; *p != -1; p++) {
> +if (*p == AV_PIX_FMT_VAAPI)
> +return *p;
> +}
> +
> +return AV_PIX_FMT_NONE;
> +}
> +
> +int retrieve_data(AVFrame *input)
> +{
> +AVFrame *output = NULL;
> +int err;
> +av_assert0(input->format == AV_PIX_FMT_VAAPI);
> +
> +if (!(output = av_frame_alloc()))
> +return AVERROR(ENOMEM);
> +/* default output nv12 */
> +output->format = AV_PIX_FMT_NV12;
> +if ((err = av_hwframe_transfer_data(output, input, 0)) < 0) {
> +fprintf(stderr, "Failed to transfer data to output frame: %d.\n", 
> err);
> +goto fail;
> +}
> +
> +if ((err = av_frame_copy_props(output, input)) < 0) {
> +av_frame_unref(output);
> +goto fail;
> +}
> +
> +av_frame_unref(input);
> +av_frame_move_ref(input, output);
> +av_frame_free();
> +return 0;
> +
> +fail:
> +av_frame_free();
> +return err;
> +}
> +
> +int write_frame(AVFrame *frame)
> +{
> +int idx, size;
> +int width = frame->width;
> +int height = frame->height;
> +
> +av_assert0(frame && frame->data[0] &

Re: [FFmpeg-devel] [PATCH V2] examples/vaapi_dec: Add a VA-API hwaccel decoding example

2017-07-10 Thread
From 0e4d230ae4c98949a962c6bbdad31d216b54bb6a Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Tue, 21 Mar 2017 11:04:41 +0800
Subject: [V2] examples/vaapi_dec: Add a VA-API hwaccel decoding example.

Add a VA-API hwaccel decoding example.

Signed-off-by: Liu, Kaixuan 
Signed-off-by: Jun Zhao 
---
 doc/examples/vaapi_dec.c | 266 +++
 1 file changed, 266 insertions(+)
 create mode 100644 doc/examples/vaapi_dec.c

diff --git a/doc/examples/vaapi_dec.c b/doc/examples/vaapi_dec.c
new file mode 100644
index 00..01320a3b71
--- /dev/null
+++ b/doc/examples/vaapi_dec.c
@@ -0,0 +1,266 @@
+/*
+ * Video Acceleration API (video decoding) decode sample
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Intel VAAPI-accelerated decoding example.
+ *
+ * @example vaapi_dec.c
+ * This example shows how to do VAAPI-accelerated decoding with output
+ * frames from the VAAPI video surfaces.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static AVBufferRef *hw_device_ctx = NULL;
+FILE *output_file = NULL;
+
+int decoder_init_vaapi(AVCodecContext *ctx)
+{
+int err = 0;
+const char *dev_name = "/dev/dri/renderD128";
+
+if ((err = av_hwdevice_ctx_create(_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
+  dev_name, NULL, 0)) < 0) {
+fprintf(stderr, "Failed to create a VAAPI device.\n");
+return err;
+}
+ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
+
+return err;
+}
+
+static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
+   const enum AVPixelFormat *pix_fmts)
+{
+const enum AVPixelFormat *p;
+
+for (p = pix_fmts; *p != -1; p++) {
+if (*p == AV_PIX_FMT_VAAPI)
+return *p;
+}
+
+return AV_PIX_FMT_NONE;
+}
+
+int retrieve_data(AVFrame *input)
+{
+AVFrame *output = NULL;
+int err;
+av_assert0(input->format == AV_PIX_FMT_VAAPI);
+
+if (!(output = av_frame_alloc()))
+return AVERROR(ENOMEM);
+/* default output nv12 */
+output->format = AV_PIX_FMT_NV12;
+if ((err = av_hwframe_transfer_data(output, input, 0)) < 0) {
+fprintf(stderr, "Failed to transfer data to output frame: %d.\n", err);
+goto fail;
+}
+
+if ((err = av_frame_copy_props(output, input)) < 0) {
+av_frame_unref(output);
+goto fail;
+}
+
+av_frame_unref(input);
+av_frame_move_ref(input, output);
+av_frame_free();
+return 0;
+
+fail:
+av_frame_free();
+return err;
+}
+
+int write_frame(AVFrame *frame)
+{
+int idx, size;
+int width = frame->width;
+int height = frame->height;
+
+av_assert0(frame && frame->data[0] && output_file);
+
+for (idx = 0; idx < height; idx++) {
+if ((size = fwrite(frame->data[0] + idx*frame->linesize[0],
+   1, width, output_file)) < 0) {
+fprintf(stderr, "Dump Y to file error.\n");
+return -1;
+}
+}
+
+height >>= 1;
+for (idx = 0; idx < height; idx++) {
+if ((size = fwrite(frame->data[1] + idx*frame->linesize[1],
+   1, width, output_file)) < 0) {
+fprintf(stderr, "Dump UV to file error.\n");
+return -1;
+}
+}
+
+return 0;
+}
+
+int decode_write(AVCodecContext *avctx, AVPacket packet, int flush)
+{
+AVFrame *frame = NULL;
+int ret = 0;
+
+ret = avcodec_send_packet(avctx, );
+if (ret < 0 && ret != AVERROR_EOF)
+return 0;
+
+if (!(frame = av_frame_alloc()))
+return AVERROR(ENOMEM);
+
+ret = avcodec_receive_frame(avctx, frame);
+if (ret >= 0) {
+/* retrieve data from GPU to CPU */
+if ((ret = retrieve_data(frame)) < 0)
+goto fail;
+
+if ((ret = write_frame(frame)) < 0)
+goto fail;
+} else if (flush == 0) {
What about !flush? or small than 0?
+ret = 0;
+}
+
+fail:
+av_frame_free();
+return ret;
+}
+
+/* flush the decoder */
+int flush(AVCodecContext *avctx)
+{
+AVPacket packet;
+int ret = 0;
+
+

Re: [FFmpeg-devel] [PATCH] avformat/hls: Added subtitle support

2016-11-15 Thread


Thanks

刘歧|CDN|研发总监
吉林省高升科技有限公司北京分公司
地址:北京市海淀区西三环北路87号国际财经中心B座9层
手机:18611075131
邮箱: li...@gosun.com
电话:010-82602628

> 在 2016年11月15日,下午6:50,Franklin Phillips <franklinphillips...@inbox.lv> 写道:
> 
> Hi,
> 
> I am having trouble getting my patch to show up in 
> https://patchwork.ffmpeg.org/. This page 
> (https://www.ffmpeg.org/developer.html#Submitting-patches-1) suggests it 
> could be the mime type, however I used one of the recommended types, 
> text/plain, and it is still not appearing on the patchwork page.
> 
> Any advice?
use git send-email maybe better
> 
> Thanks
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/udp: deprecate local_port option

2016-10-09 Thread

> 在 2016年10月10日,上午10:30,Steven Liu  写道:
> 
> 2016-10-10 10:27 GMT+08:00 James Almer :
> 
>> On 10/9/2016 11:24 PM, Steven Liu wrote:
>>> 
>>> Signed-off-by: Steven Liu 
>>> ---
>>> doc/protocols.texi|3 +++
>>> libavformat/udp.c |   19 ++-
>>> libavformat/version.h |3 +++
>>> 3 files changed, 24 insertions(+), 1 deletions(-)
>>> 
>>> diff --git a/doc/protocols.texi b/doc/protocols.texi
>>> index 3abc5f3..85a3f56 100644
>>> --- a/doc/protocols.texi
>>> +++ b/doc/protocols.texi
>>> @@ -1304,6 +1304,9 @@ input has enough packets to sustain it.
>>> When using @var{bitrate} this specifies the maximum number of bits in
>>> packet bursts.
>>> 
>>> +@item local_port=@var{port}
>>> +This is a deprecated option, you can use localport instead it.
>>> +
>>> @item localport=@var{port}
>>> Override the local UDP port to bind with.
>>> 
>>> diff --git a/libavformat/udp.c b/libavformat/udp.c
>>> index 3835f98..af06b89 100644
>>> --- a/libavformat/udp.c
>>> +++ b/libavformat/udp.c
>>> @@ -86,6 +86,9 @@ typedef struct UDPContext {
>>> int pkt_size;
>>> int is_multicast;
>>> int is_broadcast;
>>> +#if FF_API_UDP_LOCAL_PORT
>>> +int local_port_deprecated;
>>> +#endif
>>> int local_port;
>>> int reuse_socket;
>>> int overrun_nonfatal;
>>> @@ -123,7 +126,9 @@ static const AVOption options[] = {
>>> { "bitrate","Bits to send per second",
>>   OFFSET(bitrate),AV_OPT_TYPE_INT64,  { .i64 = 0  }, 0,
>> INT64_MAX, .flags = E },
>>> { "burst_bits", "Max length of bursts in bits (when using
>> bitrate)", OFFSET(burst_bits),   AV_OPT_TYPE_INT64,  { .i64 = 0  }, 0,
>> INT64_MAX, .flags = E },
>>> { "localport",  "Local port",
>>OFFSET(local_port), AV_OPT_TYPE_INT,{ .i64 = -1 },-1,
>> INT_MAX, D|E },
>>> -{ "local_port", "Local port",
>>OFFSET(local_port), AV_OPT_TYPE_INT,{ .i64 = -1 },-1,
>> INT_MAX, .flags = D|E },
>>> +#if FF_API_UDP_LOCAL_PORT
>>> +{ "local_port", "Local port",
>>OFFSET(local_port_deprecated), AV_OPT_TYPE_INT,{ .i64 = -1 },
>>  -1, INT_MAX, .flags = D|E },
>>> +#endif
>>> { "localaddr",  "Local address",
>>   OFFSET(localaddr),  AV_OPT_TYPE_STRING, { .str = NULL },
>>   .flags = D|E },
>>> { "udplite_coverage", "choose UDPLite head size which should be
>> validated by checksum", OFFSET(udplite_coverage), AV_OPT_TYPE_INT, {.i64 =
>> 0}, 0, INT_MAX, D|E },
>>> { "pkt_size",   "Maximum UDP packet size",
>>   OFFSET(pkt_size),   AV_OPT_TYPE_INT,{ .i64 = 1472 },  -1,
>> INT_MAX, .flags = D|E },
>>> @@ -377,6 +382,12 @@ static int udp_socket_create(URLContext *h, struct
>> sockaddr_storage *addr,
>>> 
>>> if (((struct sockaddr *) >dest_addr)->sa_family)
>>> family = ((struct sockaddr *) >dest_addr)->sa_family;
>>> +#if FF_API_UDP_LOCAL_PORT
>>> +if (s->local_port_deprecated >= 0) {
>>> +av_log(s, AV_LOG_WARNING, "the local_port option will be
>> deprecated, please use localport option\n");
>>> +s->local_port = s->local_port_deprecated;
>>> +}
>>> +#endif
>>> res0 = udp_resolve_host(h, (localaddr && localaddr[0]) ? localaddr
>> : NULL,
>>> s->local_port,
>>> SOCK_DGRAM, family, AI_PASSIVE);
>>> @@ -481,6 +492,12 @@ int ff_udp_set_remote_url(URLContext *h, const
>> char *uri)
>>> int ff_udp_get_local_port(URLContext *h)
>>> {
>>> UDPContext *s = h->priv_data;
>>> +#if FF_API_UDP_LOCAL_PORT
>>> +if (s->local_port_deprecated >= 0) {
>>> +av_log(s, AV_LOG_WARNING, "the local_port option will be
>> deprecated, please use localport option\n");
>>> +s->local_port = s->local_port_deprecated;
>>> +}
>>> +#endif
>>> return s->local_port;
>>> }
>>> 
>>> diff --git a/libavformat/version.h b/libavformat/version.h
>>> index 92801b4..8606efe 100644
>>> --- a/libavformat/version.h
>>> +++ b/libavformat/version.h
>>> @@ -85,6 +85,9 @@
>>> #ifndef FF_API_HTTP_USER_AGENT
>>> #define FF_API_HTTP_USER_AGENT  (LIBAVFORMAT_VERSION_MAJOR < 58)
>>> #endif
>>> +#ifndef FF_API_UDP_LOCAL_PORT
>>> +#define FF_API_UDP_LOCAL_PORT   (LIBAVFORMAT_VERSION_MAJOR < 68)
>> 
>> 59 is enough. Major bumps usually take place once per year or so, and
>> 
> Ok, Change to 59
> Thanks
> 
>> deprecated features are normally removed after two years.
>> 
>>> +#endif
>>> 
>>> #ifndef FF_API_R_FRAME_RATE
>>> #define FF_API_R_FRAME_RATE1
>>> 
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
patch update


0001-avformat-udp-deprecate-local_port-option.patch
Description: Binary data