Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-14 Thread Bodecs Bela



2018.08.06. 16:20 keltezéssel, Steven Liu írta:



On Aug 6, 2018, at 19:29, Ronak Patel  wrote:


On Aug 6, 2018, at 7:19 AM, Liu Steven  wrote:




在 2018年8月6日,下午7:12,Ronak Patel  写道:


On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:




在 2018年8月4日,上午2:17,Ronak  写道:


I have read this patch some problem for this patch.

1. maybe there will have a problem when duration is not same when every 
fragment, for example:
liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
-hls_list_size 0 output_test.m3u8
liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:8
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:3.87,
output_test0.ts
#EXTINF:7.30,
output_test1.ts
#EXTINF:8.33,
output_test2.ts

the output_test0.ts’s duration is short than output_test1.ts, the 
#EXT-X-TARGETDURATION need update to the longest duration.
this operation (check the longest duration) will happen at every fragment write 
complete.
it will not update when move the update option to the hls_write_header,


This is a problem in the code that splits the mpegts files. I've filed a 
separate issue for this here: https://trac.ffmpeg.org/ticket/7341. Mpegts 
segmentation should be following the hls_time parameter (or the default length).

This is whatever hls_time, is decide by keyframe position, this is happen when 
GOP size is not a permanent t position.


This is happening now with fMP4 assets, but not with mpegts.

Whatever fmp4 or mpegts, all of them need fix the problem of duration refresh.

for example:

liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
-hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:8
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-MAP:URI="init.mp4"
#EXTINF:3.87,
output_test0.m4s
#EXTINF:7.30,
output_test1.m4s
#EXTINF:8.33,
liuqideMacBook-Pro:xxx liuqi$

This is after your patch:
liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
-hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-MAP:URI="init.mp4"
#EXTINF:3.87,
output_test0.m4s
#EXTINF:7.30,
output_test1.m4s
#EXTINF:8.33,

The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:

4.3.3.1.  EXT-X-TARGETDURATION

The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
duration.  The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.  It applies to the entire Playlist file.  Its format
is:

#EXT-X-TARGETDURATION:

where s is a decimal-integer indicating the target duration in
seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
EXTINF:8.33



2. the version maybe will update when use hls_segment_type or append_list etc. 
when the operation is support from different version m3u8.

I don't follow what you mean here. The version number is known up front, based 
on the options that were passed in. It should be illegal to switch between 
versions when trying to update an existing manifest. When can this legitimately 
happen?

there maybe have some player cannot support high version of m3u8, for example 
old parser or player just support the VERSION 3,
this must think about all of the player or parser, because ffmpeg is not used 
only by myself.

Or what about get the #EXT-X-VERSION position, to update it? looks like 
flvenc.c or movenc.c date shift


3. need update segments vs->segments when hls_list_size option is set.


What do you mean by this and where should I do it?

for example, hls_list_size is 4, the m3u8 list should refresh every time when 
make a new fragment.

first time:
1.m4s
2.m4s
3.m4s
4.m4s

sencond time:
2.m4s
3.m4s
4.m4s
5.m4s

after your patch:

liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -v quiet -i 
~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
-hls_list_size 4 -hls_segment_type fmp4 -hls_time 3 -t 50 output_test.m3u8
liuqideMacBook-Pro:xxx liuqi$ cat output_test.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-MAP:URI="init.mp4"
#EXTINF:3.87,
output_test0.m4s
#EXTINF:7.30,
output_test1.m4s
#EXTINF:8.33,
output_test2.m4s
#EXTINF:3.97,
output_test3.m4s
#EXTINF:8.33,
output_test4.m4s
#EXTINF:4.03,
output_test5.m4s
#EXTINF:8.33,
output_test6.m4s
#EXTINF:4.63,
output_test7.m4s
liuqideMacBook-Pro:xxx liuqi$
liuqideMacBook-Pro:xxx liuqi$

the m3u8 list is incorrect, because users want control 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-13 Thread Steven Liu


> On Aug 14, 2018, at 05:06, Ronak  wrote:
> 
>> 
>> On Aug 13, 2018, at 10:49 AM, Steven Liu  wrote:
>>> 
 
 Hi Steven,
 
 Did you have a chance to review this patch? I haven't seen your feedback 
 yet. Did you have a chance to try it out?
 I would like to get this merged this week.
>>> 1. you MUST update the TARGET DURATION if the new fragment is long
>>> than old fragment, don't only test your audio files please, ffmpeg not
>>> only be used by you.
>> 
>> This patch already does that. I've confirmed with several video files. 
>> Please see the attached manifest that was generated by this patch as proof. 
>> This is a video file downloaded from here: 
>> https://www.sample-videos.com/index.php#sample-mp4-video.
> 
> Trying to send the attachment again, it got removed for some reason.
> 
> 
>> 
>>> 2. if the temp file have problem, you should seperate the patch into
>>> two patch, one fix temp file problem, the other implement your
>>> feature.
>> 
>> The two problems are interrelated. The creation/destruction of temp files 
>> repeatedly adds to the generation latency here. In my use-case, ffmpeg 
>> generates and destroys the temp file 155000 times when: 1. This is offline 
>> VOD. I am just generating from my laptop to my laptop. No Web Servers are 
>> involved. 2. I did not explicitly ask for this.
>> 
>>> 3. I need more time to think about how to improve the refresh problem
>>> when in VOD mode.Because this patch is not a good way, that is not a
>>> full care about the other function.
>> 
>> The alternative way is the one I was proposing first; which was to write the 
>> header once; and then the segments only in the hls_window method.
>> However, that has problems like you pointed out, due to the architecture 
>> that ffmpeg has. We can still pursue that path, but it will be a much more 
>> complicated fix. I would need much more of your help to fix this.
>> Dashenc.c also suffers from this same problem. This needs to be fixed in 
>> both places, not just hlsenc.c.
>> 

Could you please resend a new version patch, use "git send-email”,  make patch 
use “git format-patch -v” to make patch version. I cannot find the newest patch 
:(.
Then the patch can be picked up by patchwork.

Thanks

Steven



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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-13 Thread Ronak


> On Aug 13, 2018, at 4:48 PM, Ronak  wrote:
> 
> On Aug 13, 2018, at 10:49 AM, Steven Liu  wrote:
>> 
>>> 
>>> Hi Steven,
>>> 
>>> Did you have a chance to review this patch? I haven't seen your feedback 
>>> yet. Did you have a chance to try it out?
>>> I would like to get this merged this week.
>> 1. you MUST update the TARGET DURATION if the new fragment is long
>> than old fragment, don't only test your audio files please, ffmpeg not
>> only be used by you.
> 
> This patch already does that. I've confirmed with several video files. Please 
> see the attached manifest that was generated by this patch as proof. This is 
> a video file downloaded from here: 
> https://www.sample-videos.com/index.php#sample-mp4-video 
> .

Trying to send the attachment again, it got removed for some reason.



output_test_video.m3u8
Description: audio/mpegurl

> 
>> 2. if the temp file have problem, you should seperate the patch into
>> two patch, one fix temp file problem, the other implement your
>> feature.
> 
> The two problems are interrelated. The creation/destruction of temp files 
> repeatedly adds to the generation latency here. In my use-case, ffmpeg 
> generates and destroys the temp file 155000 times when: 1. This is offline 
> VOD. I am just generating from my laptop to my laptop. No Web Servers are 
> involved. 2. I did not explicitly ask for this.
> 
>> 3. I need more time to think about how to improve the refresh problem
>> when in VOD mode.Because this patch is not a good way, that is not a
>> full care about the other function.
> 
> The alternative way is the one I was proposing first; which was to write the 
> header once; and then the segments only in the hls_window method.
> However, that has problems like you pointed out, due to the architecture that 
> ffmpeg has. We can still pursue that path, but it will be a much more 
> complicated fix. I would need much more of your help to fix this.
> Dashenc.c also suffers from this same problem. This needs to be fixed in both 
> places, not just hlsenc.c.
> 
>> 
>> Thanks
>>> 
>>> Ronak
>>> 
>> ___
>> 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] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-13 Thread Ronak
On Aug 13, 2018, at 10:49 AM, Steven Liu  wrote:
> 
>> 
>> Hi Steven,
>> 
>> Did you have a chance to review this patch? I haven't seen your feedback 
>> yet. Did you have a chance to try it out?
>> I would like to get this merged this week.
> 1. you MUST update the TARGET DURATION if the new fragment is long
> than old fragment, don't only test your audio files please, ffmpeg not
> only be used by you.

This patch already does that. I've confirmed with several video files. Please 
see the attached manifest that was generated by this patch as proof. This is a 
video file downloaded from here: 
https://www.sample-videos.com/index.php#sample-mp4-video 
.



> 2. if the temp file have problem, you should seperate the patch into
> two patch, one fix temp file problem, the other implement your
> feature.

The two problems are interrelated. The creation/destruction of temp files 
repeatedly adds to the generation latency here. In my use-case, ffmpeg 
generates and destroys the temp file 155000 times when: 1. This is offline VOD. 
I am just generating from my laptop to my laptop. No Web Servers are involved. 
2. I did not explicitly ask for this.

> 3. I need more time to think about how to improve the refresh problem
> when in VOD mode.Because this patch is not a good way, that is not a
> full care about the other function.

The alternative way is the one I was proposing first; which was to write the 
header once; and then the segments only in the hls_window method.
However, that has problems like you pointed out, due to the architecture that 
ffmpeg has. We can still pursue that path, but it will be a much more 
complicated fix. I would need much more of your help to fix this.
Dashenc.c also suffers from this same problem. This needs to be fixed in both 
places, not just hlsenc.c.

> 
> Thanks
>> 
>> Ronak
>> 
> ___
> 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] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-13 Thread Steven Liu
>
> Hi Steven,
>
> Did you have a chance to review this patch? I haven't seen your feedback yet. 
> Did you have a chance to try it out?
> I would like to get this merged this week.
1. you MUST update the TARGET DURATION if the new fragment is long
than old fragment, don't only test your audio files please, ffmpeg not
only be used by you.
2. if the temp file have problem, you should seperate the patch into
two patch, one fix temp file problem, the other implement your
feature.
3. I need more time to think about how to improve the refresh problem
when in VOD mode.Because this patch is not a good way, that is not a
full care about the other function.

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-13 Thread Ronak


> On Aug 10, 2018, at 6:31 AM, Ronak Patel  
> wrote:
> 
>> 
>> On Aug 8, 2018, at 5:37 PM, Ronak  wrote:
>> 
>> 
>> 
>>> On Aug 8, 2018, at 3:52 PM, Ronak  wrote:
>>> 
>>> 
>>> 
 On Aug 6, 2018, at 10:20 AM, Steven Liu  wrote:
 
 
 
>> On Aug 6, 2018, at 19:29, Ronak Patel 
>>  wrote:
>> 
>> 
>> On Aug 6, 2018, at 7:19 AM, Liu Steven  wrote:
>> 
>> 
>> 
 在 2018年8月6日,下午7:12,Ronak Patel  写道:
 
 
 On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
 
 
 
> 在 2018年8月4日,上午2:17,Ronak  写道:
> 
>>> I have read this patch some problem for this patch.
>>> 
>>> 1. maybe there will have a problem when duration is not same 
>>> when every fragment, for example:
>>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f 
>>> hls -hls_list_size 0 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:3
>>> #EXT-X-TARGETDURATION:8
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXTINF:3.87,
>>> output_test0.ts
>>> #EXTINF:7.30,
>>> output_test1.ts
>>> #EXTINF:8.33,
>>> output_test2.ts
>>> 
>>> the output_test0.ts’s duration is short than output_test1.ts, 
>>> the #EXT-X-TARGETDURATION need update to the longest duration.
>>> this operation (check the longest duration) will happen at 
>>> every fragment write complete.
>>> it will not update when move the update option to the 
>>> hls_write_header,
>>> 
>> 
>> This is a problem in the code that splits the mpegts files. I've 
>> filed a separate issue for this here: 
>> https://trac.ffmpeg.org/ticket/7341. Mpegts segmentation should 
>> be following the hls_time parameter (or the default length).
> This is whatever hls_time, is decide by keyframe position, this 
> is happen when GOP size is not a permanent t position.
> 
>> 
>> This is happening now with fMP4 assets, but not with mpegts.
> Whatever fmp4 or mpegts, all of them need fix the problem of 
> duration refresh.
> 
> for example:
> 
> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 
> output_test.m3u8
> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
> #EXTM3U
> #EXT-X-VERSION:7
> #EXT-X-TARGETDURATION:8
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-MAP:URI="init.mp4"
> #EXTINF:3.87,
> output_test0.m4s
> #EXTINF:7.30,
> output_test1.m4s
> #EXTINF:8.33,
> liuqideMacBook-Pro:xxx liuqi$
 
 This is after your patch:
 liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 
 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:7
 #EXT-X-TARGETDURATION:3
 #EXT-X-MEDIA-SEQUENCE:0
 #EXT-X-MAP:URI="init.mp4"
 #EXTINF:3.87,
 output_test0.m4s
 #EXTINF:7.30,
 output_test1.m4s
 #EXTINF:8.33,
 
 The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
 
 4.3.3.1.  EXT-X-TARGETDURATION
 
 The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
 duration.  The EXTINF duration of each Media Segment in the 
 Playlist
 file, when rounded to the nearest integer, MUST be less than or 
 equal
 to the target duration; longer segments can trigger playback stalls
 or other errors.  It applies to the entire Playlist file.  Its 
 format
 is:
 
 #EXT-X-TARGETDURATION:
 
 where s is a decimal-integer indicating the target duration in
 seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
 
 your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
 EXTINF:8.33
>>> 
>>> 
>>> 2. the version maybe will update when 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-10 Thread Ronak Patel

On Aug 10, 2018, at 7:30 AM, Liu Steven  wrote:

 
>>> 
>>> Hi Steven,
>>> 
>>> Please see my new patch taking your feedback into account.
>>> 
>>> Ronak
>> 
>> Hi Steven,
>> 
>> Did you have a chance to review? I’m going to send you a new patch for 
>> dashenc.c shortly.
> Don’t worry, i will review it weekend, but i think your ways is not a better 
> way, maybe just change the hls_window maybe ok. the other code need not 
> modify.
>> 

The other code fixes the problem that HLS_TEMP option wasn’t working. 
Use_rename should only be on if it’s been specified on the command line.


>> For dashenc.c, ffmpeg again always assumes we are doing live streaming. It 
>> doesn’t even have another profile. I’m going to add a VOD profile to it and 
>> fix this problem there. I will have to add a new cli parameter so we can 
>> specify the profile now.
>> 
>> Ronak
> 

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-10 Thread Liu Steven
>>> 
>> 
>> Hi Steven,
>> 
>> Please see my new patch taking your feedback into account.
>> 
>> Ronak
> 
> Hi Steven,
> 
> Did you have a chance to review? I’m going to send you a new patch for 
> dashenc.c shortly.
Don’t worry, i will review it weekend, but i think your ways is not a better 
way, maybe just change the hls_window maybe ok. the other code need not modify.
> 
> For dashenc.c, ffmpeg again always assumes we are doing live streaming. It 
> doesn’t even have another profile. I’m going to add a VOD profile to it and 
> fix this problem there. I will have to add a new cli parameter so we can 
> specify the profile now.
> 
> Ronak



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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-10 Thread Ronak Patel

> On Aug 8, 2018, at 5:37 PM, Ronak  wrote:
> 
> 
> 
>> On Aug 8, 2018, at 3:52 PM, Ronak  wrote:
>> 
>> 
>> 
>>> On Aug 6, 2018, at 10:20 AM, Steven Liu  wrote:
>>> 
>>> 
>>> 
> On Aug 6, 2018, at 19:29, Ronak Patel  
> wrote:
> 
> 
> On Aug 6, 2018, at 7:19 AM, Liu Steven  wrote:
> 
> 
> 
>>> 在 2018年8月6日,下午7:12,Ronak Patel  写道:
>>> 
>>> 
>>> On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
>>> 
>>> 
>>> 
 在 2018年8月4日,上午2:17,Ronak  写道:
 
>> I have read this patch some problem for this patch.
>> 
>> 1. maybe there will have a problem when duration is not same 
>> when every fragment, for example:
>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f 
>> hls -hls_list_size 0 output_test.m3u8
>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>> #EXTM3U
>> #EXT-X-VERSION:3
>> #EXT-X-TARGETDURATION:8
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXTINF:3.87,
>> output_test0.ts
>> #EXTINF:7.30,
>> output_test1.ts
>> #EXTINF:8.33,
>> output_test2.ts
>> 
>> the output_test0.ts’s duration is short than output_test1.ts, 
>> the #EXT-X-TARGETDURATION need update to the longest duration.
>> this operation (check the longest duration) will happen at every 
>> fragment write complete.
>> it will not update when move the update option to the 
>> hls_write_header,
>> 
> 
> This is a problem in the code that splits the mpegts files. I've 
> filed a separate issue for this here: 
> https://trac.ffmpeg.org/ticket/7341. Mpegts segmentation should 
> be following the hls_time parameter (or the default length).
 This is whatever hls_time, is decide by keyframe position, this is 
 happen when GOP size is not a permanent t position.
 
> 
> This is happening now with fMP4 assets, but not with mpegts.
 Whatever fmp4 or mpegts, all of them need fix the problem of 
 duration refresh.
 
 for example:
 
 liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 
 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:7
 #EXT-X-TARGETDURATION:8
 #EXT-X-MEDIA-SEQUENCE:0
 #EXT-X-MAP:URI="init.mp4"
 #EXTINF:3.87,
 output_test0.m4s
 #EXTINF:7.30,
 output_test1.m4s
 #EXTINF:8.33,
 liuqideMacBook-Pro:xxx liuqi$
>>> 
>>> This is after your patch:
>>> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:7
>>> #EXT-X-TARGETDURATION:3
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXT-X-MAP:URI="init.mp4"
>>> #EXTINF:3.87,
>>> output_test0.m4s
>>> #EXTINF:7.30,
>>> output_test1.m4s
>>> #EXTINF:8.33,
>>> 
>>> The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
>>> 
>>> 4.3.3.1.  EXT-X-TARGETDURATION
>>> 
>>> The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>>> duration.  The EXTINF duration of each Media Segment in the Playlist
>>> file, when rounded to the nearest integer, MUST be less than or 
>>> equal
>>> to the target duration; longer segments can trigger playback stalls
>>> or other errors.  It applies to the entire Playlist file.  Its 
>>> format
>>> is:
>>> 
>>> #EXT-X-TARGETDURATION:
>>> 
>>> where s is a decimal-integer indicating the target duration in
>>> seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>>> 
>>> your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
>>> EXTINF:8.33
>> 
>> 
>> 2. the version maybe will update when use hls_segment_type or 
>> append_list etc. when the operation is support from different 
>> version m3u8.
> 
> I don't follow what you mean here. The version number is 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-08 Thread Ronak


> On Aug 8, 2018, at 3:52 PM, Ronak  wrote:
> 
> 
> 
>> On Aug 6, 2018, at 10:20 AM, Steven Liu  wrote:
>> 
>> 
>> 
>>> On Aug 6, 2018, at 19:29, Ronak Patel  
>>> wrote:
>>> 
 
 On Aug 6, 2018, at 7:19 AM, Liu Steven  wrote:
 
 
 
>> 在 2018年8月6日,下午7:12,Ronak Patel  写道:
>> 
>> 
>> On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
>> 
>> 
>> 
>>> 在 2018年8月4日,上午2:17,Ronak  写道:
>>> 
> I have read this patch some problem for this patch.
> 
> 1. maybe there will have a problem when duration is not same when 
> every fragment, for example:
> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
> -hls_list_size 0 output_test.m3u8
> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-TARGETDURATION:8
> #EXT-X-MEDIA-SEQUENCE:0
> #EXTINF:3.87,
> output_test0.ts
> #EXTINF:7.30,
> output_test1.ts
> #EXTINF:8.33,
> output_test2.ts
> 
> the output_test0.ts’s duration is short than output_test1.ts, the 
> #EXT-X-TARGETDURATION need update to the longest duration.
> this operation (check the longest duration) will happen at every 
> fragment write complete.
> it will not update when move the update option to the 
> hls_write_header,
> 
 
 This is a problem in the code that splits the mpegts files. I've 
 filed a separate issue for this here: 
 https://trac.ffmpeg.org/ticket/7341. Mpegts segmentation should be 
 following the hls_time parameter (or the default length).
>>> This is whatever hls_time, is decide by keyframe position, this is 
>>> happen when GOP size is not a permanent t position.
>>> 
 
 This is happening now with fMP4 assets, but not with mpegts.
>>> Whatever fmp4 or mpegts, all of them need fix the problem of 
>>> duration refresh.
>>> 
>>> for example:
>>> 
>>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:7
>>> #EXT-X-TARGETDURATION:8
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXT-X-MAP:URI="init.mp4"
>>> #EXTINF:3.87,
>>> output_test0.m4s
>>> #EXTINF:7.30,
>>> output_test1.m4s
>>> #EXTINF:8.33,
>>> liuqideMacBook-Pro:xxx liuqi$
>> 
>> This is after your patch:
>> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>> #EXTM3U
>> #EXT-X-VERSION:7
>> #EXT-X-TARGETDURATION:3
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXT-X-MAP:URI="init.mp4"
>> #EXTINF:3.87,
>> output_test0.m4s
>> #EXTINF:7.30,
>> output_test1.m4s
>> #EXTINF:8.33,
>> 
>> The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
>> 
>> 4.3.3.1.  EXT-X-TARGETDURATION
>> 
>> The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>> duration.  The EXTINF duration of each Media Segment in the Playlist
>> file, when rounded to the nearest integer, MUST be less than or equal
>> to the target duration; longer segments can trigger playback stalls
>> or other errors.  It applies to the entire Playlist file.  Its format
>> is:
>> 
>> #EXT-X-TARGETDURATION:
>> 
>> where s is a decimal-integer indicating the target duration in
>> seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>> 
>> your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
>> EXTINF:8.33
> 
> 
> 2. the version maybe will update when use hls_segment_type or 
> append_list etc. when the operation is support from different 
> version m3u8.
 
 I don't follow what you mean here. The version number is known up 
 front, based on the options that were passed in. It should be 
 illegal to switch between versions when trying to update an 
 existing manifest. When can this legitimately 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-08 Thread Ronak


> On Aug 6, 2018, at 10:20 AM, Steven Liu  wrote:
> 
> 
> 
>> On Aug 6, 2018, at 19:29, Ronak Patel  
>> wrote:
>> 
>>> 
>>> On Aug 6, 2018, at 7:19 AM, Liu Steven  wrote:
>>> 
>>> 
>>> 
> 在 2018年8月6日,下午7:12,Ronak Patel  写道:
> 
> 
> On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
> 
> 
> 
>> 在 2018年8月4日,上午2:17,Ronak  写道:
>> 
 I have read this patch some problem for this patch.
 
 1. maybe there will have a problem when duration is not same when 
 every fragment, for example:
 liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:3
 #EXT-X-TARGETDURATION:8
 #EXT-X-MEDIA-SEQUENCE:0
 #EXTINF:3.87,
 output_test0.ts
 #EXTINF:7.30,
 output_test1.ts
 #EXTINF:8.33,
 output_test2.ts
 
 the output_test0.ts’s duration is short than output_test1.ts, the 
 #EXT-X-TARGETDURATION need update to the longest duration.
 this operation (check the longest duration) will happen at every 
 fragment write complete.
 it will not update when move the update option to the 
 hls_write_header,
 
>>> 
>>> This is a problem in the code that splits the mpegts files. I've 
>>> filed a separate issue for this here: 
>>> https://trac.ffmpeg.org/ticket/7341. Mpegts segmentation should be 
>>> following the hls_time parameter (or the default length).
>> This is whatever hls_time, is decide by keyframe position, this is 
>> happen when GOP size is not a permanent t position.
>> 
>>> 
>>> This is happening now with fMP4 assets, but not with mpegts.
>> Whatever fmp4 or mpegts, all of them need fix the problem of 
>> duration refresh.
>> 
>> for example:
>> 
>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>> #EXTM3U
>> #EXT-X-VERSION:7
>> #EXT-X-TARGETDURATION:8
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXT-X-MAP:URI="init.mp4"
>> #EXTINF:3.87,
>> output_test0.m4s
>> #EXTINF:7.30,
>> output_test1.m4s
>> #EXTINF:8.33,
>> liuqideMacBook-Pro:xxx liuqi$
> 
> This is after your patch:
> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
> #EXTM3U
> #EXT-X-VERSION:7
> #EXT-X-TARGETDURATION:3
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-MAP:URI="init.mp4"
> #EXTINF:3.87,
> output_test0.m4s
> #EXTINF:7.30,
> output_test1.m4s
> #EXTINF:8.33,
> 
> The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
> 
> 4.3.3.1.  EXT-X-TARGETDURATION
> 
> The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
> duration.  The EXTINF duration of each Media Segment in the Playlist
> file, when rounded to the nearest integer, MUST be less than or equal
> to the target duration; longer segments can trigger playback stalls
> or other errors.  It applies to the entire Playlist file.  Its format
> is:
> 
> #EXT-X-TARGETDURATION:
> 
> where s is a decimal-integer indicating the target duration in
> seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
> 
> your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
> EXTINF:8.33
 
 
 2. the version maybe will update when use hls_segment_type or 
 append_list etc. when the operation is support from different 
 version m3u8.
>>> 
>>> I don't follow what you mean here. The version number is known up 
>>> front, based on the options that were passed in. It should be 
>>> illegal to switch between versions when trying to update an 
>>> existing manifest. When can this legitimately happen?
>> there maybe have some player cannot support high version of m3u8, 
>> for example old parser or player just support the VERSION 3,
>> this 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-06 Thread Steven Liu


> On Aug 6, 2018, at 19:29, Ronak Patel  
> wrote:
> 
>> 
>> On Aug 6, 2018, at 7:19 AM, Liu Steven  wrote:
>> 
>> 
>> 
 在 2018年8月6日,下午7:12,Ronak Patel  写道:
 
 
 On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
 
 
 
> 在 2018年8月4日,上午2:17,Ronak  写道:
> 
>>> I have read this patch some problem for this patch.
>>> 
>>> 1. maybe there will have a problem when duration is not same when 
>>> every fragment, for example:
>>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 0 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:3
>>> #EXT-X-TARGETDURATION:8
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXTINF:3.87,
>>> output_test0.ts
>>> #EXTINF:7.30,
>>> output_test1.ts
>>> #EXTINF:8.33,
>>> output_test2.ts
>>> 
>>> the output_test0.ts’s duration is short than output_test1.ts, the 
>>> #EXT-X-TARGETDURATION need update to the longest duration.
>>> this operation (check the longest duration) will happen at every 
>>> fragment write complete.
>>> it will not update when move the update option to the 
>>> hls_write_header,
>>> 
>> 
>> This is a problem in the code that splits the mpegts files. I've 
>> filed a separate issue for this here: 
>> https://trac.ffmpeg.org/ticket/7341. Mpegts segmentation should be 
>> following the hls_time parameter (or the default length).
> This is whatever hls_time, is decide by keyframe position, this is 
> happen when GOP size is not a permanent t position.
> 
>> 
>> This is happening now with fMP4 assets, but not with mpegts.
> Whatever fmp4 or mpegts, all of them need fix the problem of duration 
> refresh.
> 
> for example:
> 
> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
> #EXTM3U
> #EXT-X-VERSION:7
> #EXT-X-TARGETDURATION:8
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-MAP:URI="init.mp4"
> #EXTINF:3.87,
> output_test0.m4s
> #EXTINF:7.30,
> output_test1.m4s
> #EXTINF:8.33,
> liuqideMacBook-Pro:xxx liuqi$
 
 This is after your patch:
 liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:7
 #EXT-X-TARGETDURATION:3
 #EXT-X-MEDIA-SEQUENCE:0
 #EXT-X-MAP:URI="init.mp4"
 #EXTINF:3.87,
 output_test0.m4s
 #EXTINF:7.30,
 output_test1.m4s
 #EXTINF:8.33,
 
 The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
 
 4.3.3.1.  EXT-X-TARGETDURATION
 
 The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
 duration.  The EXTINF duration of each Media Segment in the Playlist
 file, when rounded to the nearest integer, MUST be less than or equal
 to the target duration; longer segments can trigger playback stalls
 or other errors.  It applies to the entire Playlist file.  Its format
 is:
 
 #EXT-X-TARGETDURATION:
 
 where s is a decimal-integer indicating the target duration in
 seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
 
 your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
 EXTINF:8.33
>>> 
>>> 
>>> 2. the version maybe will update when use hls_segment_type or 
>>> append_list etc. when the operation is support from different 
>>> version m3u8.
>> 
>> I don't follow what you mean here. The version number is known up 
>> front, based on the options that were passed in. It should be 
>> illegal to switch between versions when trying to update an existing 
>> manifest. When can this legitimately happen?
> there maybe have some player cannot support high version of m3u8, for 
> example old parser or player just support the VERSION 3,
> this must think about all of the player or parser, because ffmpeg is 
> not used only by myself.
> 
> Or what about get the #EXT-X-VERSION position, to update 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-06 Thread Ronak Patel

> On Aug 6, 2018, at 7:19 AM, Liu Steven  wrote:
> 
> 
> 
>>> 在 2018年8月6日,下午7:12,Ronak Patel  写道:
>>> 
>>> 
>>> On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
>>> 
>>> 
>>> 
 在 2018年8月4日,上午2:17,Ronak  写道:
 
>> I have read this patch some problem for this patch.
>> 
>> 1. maybe there will have a problem when duration is not same when 
>> every fragment, for example:
>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>> -hls_list_size 0 output_test.m3u8
>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>> #EXTM3U
>> #EXT-X-VERSION:3
>> #EXT-X-TARGETDURATION:8
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXTINF:3.87,
>> output_test0.ts
>> #EXTINF:7.30,
>> output_test1.ts
>> #EXTINF:8.33,
>> output_test2.ts
>> 
>> the output_test0.ts’s duration is short than output_test1.ts, the 
>> #EXT-X-TARGETDURATION need update to the longest duration.
>> this operation (check the longest duration) will happen at every 
>> fragment write complete.
>> it will not update when move the update option to the 
>> hls_write_header,
>> 
> 
> This is a problem in the code that splits the mpegts files. I've 
> filed a separate issue for this here: 
> https://trac.ffmpeg.org/ticket/7341. Mpegts segmentation should be 
> following the hls_time parameter (or the default length).
 This is whatever hls_time, is decide by keyframe position, this is 
 happen when GOP size is not a permanent t position.
 
> 
> This is happening now with fMP4 assets, but not with mpegts.
 Whatever fmp4 or mpegts, all of them need fix the problem of duration 
 refresh.
 
 for example:
 
 liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:7
 #EXT-X-TARGETDURATION:8
 #EXT-X-MEDIA-SEQUENCE:0
 #EXT-X-MAP:URI="init.mp4"
 #EXTINF:3.87,
 output_test0.m4s
 #EXTINF:7.30,
 output_test1.m4s
 #EXTINF:8.33,
 liuqideMacBook-Pro:xxx liuqi$
>>> 
>>> This is after your patch:
>>> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:7
>>> #EXT-X-TARGETDURATION:3
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXT-X-MAP:URI="init.mp4"
>>> #EXTINF:3.87,
>>> output_test0.m4s
>>> #EXTINF:7.30,
>>> output_test1.m4s
>>> #EXTINF:8.33,
>>> 
>>> The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
>>> 
>>> 4.3.3.1.  EXT-X-TARGETDURATION
>>> 
>>> The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>>> duration.  The EXTINF duration of each Media Segment in the Playlist
>>> file, when rounded to the nearest integer, MUST be less than or equal
>>> to the target duration; longer segments can trigger playback stalls
>>> or other errors.  It applies to the entire Playlist file.  Its format
>>> is:
>>> 
>>> #EXT-X-TARGETDURATION:
>>> 
>>> where s is a decimal-integer indicating the target duration in
>>> seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>>> 
>>> your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
>>> EXTINF:8.33
>> 
>> 
>> 2. the version maybe will update when use hls_segment_type or 
>> append_list etc. when the operation is support from different 
>> version m3u8.
> 
> I don't follow what you mean here. The version number is known up 
> front, based on the options that were passed in. It should be illegal 
> to switch between versions when trying to update an existing 
> manifest. When can this legitimately happen?
 there maybe have some player cannot support high version of m3u8, for 
 example old parser or player just support the VERSION 3,
 this must think about all of the player or parser, because ffmpeg is 
 not used only by myself.
 
 Or what about get the #EXT-X-VERSION position, to update it? looks 
 like flvenc.c or movenc.c date shift
 
> 
>> 3. need update segments vs->segments when hls_list_size option is 
>> set.

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-06 Thread Liu Steven


> 在 2018年8月6日,下午7:12,Ronak Patel  写道:
> 
>> 
>> On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
>> 
>> 
>> 
>>> 在 2018年8月4日,上午2:17,Ronak  写道:
>>> 
> I have read this patch some problem for this patch.
> 
> 1. maybe there will have a problem when duration is not same when 
> every fragment, for example:
> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
> -hls_list_size 0 output_test.m3u8
> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-TARGETDURATION:8
> #EXT-X-MEDIA-SEQUENCE:0
> #EXTINF:3.87,
> output_test0.ts
> #EXTINF:7.30,
> output_test1.ts
> #EXTINF:8.33,
> output_test2.ts
> 
> the output_test0.ts’s duration is short than output_test1.ts, the 
> #EXT-X-TARGETDURATION need update to the longest duration.
> this operation (check the longest duration) will happen at every 
> fragment write complete.
> it will not update when move the update option to the 
> hls_write_header,
> 
 
 This is a problem in the code that splits the mpegts files. I've filed 
 a separate issue for this here: https://trac.ffmpeg.org/ticket/7341. 
 Mpegts segmentation should be following the hls_time parameter (or the 
 default length).
>>> This is whatever hls_time, is decide by keyframe position, this is 
>>> happen when GOP size is not a permanent t position.
>>> 
 
 This is happening now with fMP4 assets, but not with mpegts.
>>> Whatever fmp4 or mpegts, all of them need fix the problem of duration 
>>> refresh.
>>> 
>>> for example:
>>> 
>>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:7
>>> #EXT-X-TARGETDURATION:8
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXT-X-MAP:URI="init.mp4"
>>> #EXTINF:3.87,
>>> output_test0.m4s
>>> #EXTINF:7.30,
>>> output_test1.m4s
>>> #EXTINF:8.33,
>>> liuqideMacBook-Pro:xxx liuqi$
>> 
>> This is after your patch:
>> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>> #EXTM3U
>> #EXT-X-VERSION:7
>> #EXT-X-TARGETDURATION:3
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXT-X-MAP:URI="init.mp4"
>> #EXTINF:3.87,
>> output_test0.m4s
>> #EXTINF:7.30,
>> output_test1.m4s
>> #EXTINF:8.33,
>> 
>> The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
>> 
>> 4.3.3.1.  EXT-X-TARGETDURATION
>> 
>> The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>> duration.  The EXTINF duration of each Media Segment in the Playlist
>> file, when rounded to the nearest integer, MUST be less than or equal
>> to the target duration; longer segments can trigger playback stalls
>> or other errors.  It applies to the entire Playlist file.  Its format
>> is:
>> 
>> #EXT-X-TARGETDURATION:
>> 
>> where s is a decimal-integer indicating the target duration in
>> seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>> 
>> your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
>> EXTINF:8.33
> 
> 
> 2. the version maybe will update when use hls_segment_type or 
> append_list etc. when the operation is support from different version 
> m3u8.
 
 I don't follow what you mean here. The version number is known up 
 front, based on the options that were passed in. It should be illegal 
 to switch between versions when trying to update an existing manifest. 
 When can this legitimately happen?
>>> there maybe have some player cannot support high version of m3u8, for 
>>> example old parser or player just support the VERSION 3,
>>> this must think about all of the player or parser, because ffmpeg is 
>>> not used only by myself.
>>> 
>>> Or what about get the #EXT-X-VERSION position, to update it? looks like 
>>> flvenc.c or movenc.c date shift
>>> 
 
> 3. need update segments vs->segments when hls_list_size option is set.
> 
 
 What do you mean by this and where should I do it?
>>> for example, hls_list_size is 4, the m3u8 list should refresh every 
>>> time when make a new fragment.

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-06 Thread Ronak Patel

> On Aug 5, 2018, at 10:54 PM, Liu Steven  wrote:
> 
> 
> 
>> 在 2018年8月4日,上午2:17,Ronak  写道:
>> 
 I have read this patch some problem for this patch.
 
 1. maybe there will have a problem when duration is not same when 
 every fragment, for example:
 liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:3
 #EXT-X-TARGETDURATION:8
 #EXT-X-MEDIA-SEQUENCE:0
 #EXTINF:3.87,
 output_test0.ts
 #EXTINF:7.30,
 output_test1.ts
 #EXTINF:8.33,
 output_test2.ts
 
 the output_test0.ts’s duration is short than output_test1.ts, the 
 #EXT-X-TARGETDURATION need update to the longest duration.
 this operation (check the longest duration) will happen at every 
 fragment write complete.
 it will not update when move the update option to the hls_write_header,
 
>>> 
>>> This is a problem in the code that splits the mpegts files. I've filed 
>>> a separate issue for this here: https://trac.ffmpeg.org/ticket/7341. 
>>> Mpegts segmentation should be following the hls_time parameter (or the 
>>> default length).
>> This is whatever hls_time, is decide by keyframe position, this is 
>> happen when GOP size is not a permanent t position.
>> 
>>> 
>>> This is happening now with fMP4 assets, but not with mpegts.
>> Whatever fmp4 or mpegts, all of them need fix the problem of duration 
>> refresh.
>> 
>> for example:
>> 
>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>> #EXTM3U
>> #EXT-X-VERSION:7
>> #EXT-X-TARGETDURATION:8
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXT-X-MAP:URI="init.mp4"
>> #EXTINF:3.87,
>> output_test0.m4s
>> #EXTINF:7.30,
>> output_test1.m4s
>> #EXTINF:8.33,
>> liuqideMacBook-Pro:xxx liuqi$
> 
> This is after your patch:
> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
> #EXTM3U
> #EXT-X-VERSION:7
> #EXT-X-TARGETDURATION:3
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-MAP:URI="init.mp4"
> #EXTINF:3.87,
> output_test0.m4s
> #EXTINF:7.30,
> output_test1.m4s
> #EXTINF:8.33,
> 
> The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
> 
> 4.3.3.1.  EXT-X-TARGETDURATION
> 
> The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
> duration.  The EXTINF duration of each Media Segment in the Playlist
> file, when rounded to the nearest integer, MUST be less than or equal
> to the target duration; longer segments can trigger playback stalls
> or other errors.  It applies to the entire Playlist file.  Its format
> is:
> 
> #EXT-X-TARGETDURATION:
> 
> where s is a decimal-integer indicating the target duration in
> seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
> 
> your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
> EXTINF:8.33
 
 
 2. the version maybe will update when use hls_segment_type or 
 append_list etc. when the operation is support from different version 
 m3u8.
>>> 
>>> I don't follow what you mean here. The version number is known up 
>>> front, based on the options that were passed in. It should be illegal 
>>> to switch between versions when trying to update an existing manifest. 
>>> When can this legitimately happen?
>> there maybe have some player cannot support high version of m3u8, for 
>> example old parser or player just support the VERSION 3,
>> this must think about all of the player or parser, because ffmpeg is not 
>> used only by myself.
>> 
>> Or what about get the #EXT-X-VERSION position, to update it? looks like 
>> flvenc.c or movenc.c date shift
>> 
>>> 
 3. need update segments vs->segments when hls_list_size option is set.
 
>>> 
>>> What do you mean by this and where should I do it?
>> for example, hls_list_size is 4, the m3u8 list should refresh every time 
>> when make a new fragment.
>> 
>> first time:
>> 1.m4s
>> 2.m4s
>> 3.m4s
>> 4.m4s
>> 
>> sencond time:
>> 2.m4s
>> 3.m4s
>> 4.m4s
>> 5.m4s
> 
> after 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-05 Thread Liu Steven


> 在 2018年8月4日,上午2:17,Ronak  写道:
> 
>>> I have read this patch some problem for this patch.
>>> 
>>> 1. maybe there will have a problem when duration is not same when every 
>>> fragment, for example:
>>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 0 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:3
>>> #EXT-X-TARGETDURATION:8
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXTINF:3.87,
>>> output_test0.ts
>>> #EXTINF:7.30,
>>> output_test1.ts
>>> #EXTINF:8.33,
>>> output_test2.ts
>>> 
>>> the output_test0.ts’s duration is short than output_test1.ts, the 
>>> #EXT-X-TARGETDURATION need update to the longest duration.
>>> this operation (check the longest duration) will happen at every 
>>> fragment write complete.
>>> it will not update when move the update option to the hls_write_header,
>>> 
>> 
>> This is a problem in the code that splits the mpegts files. I've filed a 
>> separate issue for this here: https://trac.ffmpeg.org/ticket/7341. 
>> Mpegts segmentation should be following the hls_time parameter (or the 
>> default length).
> This is whatever hls_time, is decide by keyframe position, this is happen 
> when GOP size is not a permanent t position.
> 
>> 
>> This is happening now with fMP4 assets, but not with mpegts.
> Whatever fmp4 or mpegts, all of them need fix the problem of duration 
> refresh.
> 
> for example:
> 
> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
> #EXTM3U
> #EXT-X-VERSION:7
> #EXT-X-TARGETDURATION:8
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-MAP:URI="init.mp4"
> #EXTINF:3.87,
> output_test0.m4s
> #EXTINF:7.30,
> output_test1.m4s
> #EXTINF:8.33,
> liuqideMacBook-Pro:xxx liuqi$
 
 This is after your patch:
 liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:7
 #EXT-X-TARGETDURATION:3
 #EXT-X-MEDIA-SEQUENCE:0
 #EXT-X-MAP:URI="init.mp4"
 #EXTINF:3.87,
 output_test0.m4s
 #EXTINF:7.30,
 output_test1.m4s
 #EXTINF:8.33,
 
 The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
 
 4.3.3.1.  EXT-X-TARGETDURATION
 
 The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
 duration.  The EXTINF duration of each Media Segment in the Playlist
 file, when rounded to the nearest integer, MUST be less than or equal
 to the target duration; longer segments can trigger playback stalls
 or other errors.  It applies to the entire Playlist file.  Its format
 is:
 
 #EXT-X-TARGETDURATION:
 
 where s is a decimal-integer indicating the target duration in
 seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
 
 your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
 EXTINF:8.33
>>> 
>>> 
>>> 2. the version maybe will update when use hls_segment_type or 
>>> append_list etc. when the operation is support from different version 
>>> m3u8.
>> 
>> I don't follow what you mean here. The version number is known up front, 
>> based on the options that were passed in. It should be illegal to switch 
>> between versions when trying to update an existing manifest. When can 
>> this legitimately happen?
> there maybe have some player cannot support high version of m3u8, for 
> example old parser or player just support the VERSION 3,
> this must think about all of the player or parser, because ffmpeg is not 
> used only by myself.
> 
> Or what about get the #EXT-X-VERSION position, to update it? looks like 
> flvenc.c or movenc.c date shift
> 
>> 
>>> 3. need update segments vs->segments when hls_list_size option is set.
>>> 
>> 
>> What do you mean by this and where should I do it?
> for example, hls_list_size is 4, the m3u8 list should refresh every time 
> when make a new fragment.
> 
> first time:
> 1.m4s
> 2.m4s
> 3.m4s
> 4.m4s
> 
> sencond time:
> 2.m4s
> 3.m4s
> 4.m4s
> 5.m4s
 
 after your patch:
 
 liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 4 -hls_segment_type 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-05 Thread Ronak Patel

> I'm attaching a new patch that resolves all of these issues, while still 
> resolving this bug for VOD playlists.
> 
> Can you please review?
> 
> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>

Hi Steven,

Can you please have a look at the updated patch and tell me what you think?

I also fixed the temp_file implementation.

If you like this approach, I’ll do this for dash as well.

I’ve noticed that ffmpeg always assumes the dash stream is live until the very 
end and doesn’t support profiles (onDemand, live, etc) like mp4box does. I’m 
going to have to add that to dashenc.

Ronak

> 
> Thanks,
> 
> Ronak
> 
> 
> ___
> 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] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-03 Thread Ronak
>> I have read this patch some problem for this patch.
>> 
>> 1. maybe there will have a problem when duration is not same when every 
>> fragment, for example:
>> liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -v quiet -i 
>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>> -hls_list_size 0 output_test.m3u8
>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>> #EXTM3U
>> #EXT-X-VERSION:3
>> #EXT-X-TARGETDURATION:8
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXTINF:3.87,
>> output_test0.ts
>> #EXTINF:7.30,
>> output_test1.ts
>> #EXTINF:8.33,
>> output_test2.ts
>> 
>> the output_test0.ts’s duration is short than output_test1.ts, the 
>> #EXT-X-TARGETDURATION need update to the longest duration.
>> this operation (check the longest duration) will happen at every 
>> fragment write complete.
>> it will not update when move the update option to the hls_write_header,
>> 
> 
> This is a problem in the code that splits the mpegts files. I've filed a 
> separate issue for this here: https://trac.ffmpeg.org/ticket/7341. Mpegts 
> segmentation should be following the hls_time parameter (or the default 
> length).
 This is whatever hls_time, is decide by keyframe position, this is happen 
 when GOP size is not a permanent t position.
 
> 
> This is happening now with fMP4 assets, but not with mpegts.
 Whatever fmp4 or mpegts, all of them need fix the problem of duration 
 refresh.
 
 for example:
 
 liuqideMacBook-Pro:xxx liuqi$ ./ffmpeg -ss -v quiet -i 
 ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
 -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
 liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
 #EXTM3U
 #EXT-X-VERSION:7
 #EXT-X-TARGETDURATION:8
 #EXT-X-MEDIA-SEQUENCE:0
 #EXT-X-MAP:URI="init.mp4"
 #EXTINF:3.87,
 output_test0.m4s
 #EXTINF:7.30,
 output_test1.m4s
 #EXTINF:8.33,
 liuqideMacBook-Pro:xxx liuqi$
>>> 
>>> This is after your patch:
>>> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -ss 17 -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 0 -hls_segment_type fmp4 -hls_time 3 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ head -n 10  output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:7
>>> #EXT-X-TARGETDURATION:3
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXT-X-MAP:URI="init.mp4"
>>> #EXTINF:3.87,
>>> output_test0.m4s
>>> #EXTINF:7.30,
>>> output_test1.m4s
>>> #EXTINF:8.33,
>>> 
>>> The RFC https://www.rfc-editor.org/rfc/rfc8216.txt describe:
>>> 
>>> 4.3.3.1.  EXT-X-TARGETDURATION
>>> 
>>> The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>>> duration.  The EXTINF duration of each Media Segment in the Playlist
>>> file, when rounded to the nearest integer, MUST be less than or equal
>>> to the target duration; longer segments can trigger playback stalls
>>> or other errors.  It applies to the entire Playlist file.  Its format
>>> is:
>>> 
>>> #EXT-X-TARGETDURATION:
>>> 
>>> where s is a decimal-integer indicating the target duration in
>>> seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>>> 
>>> your patch make the EXT-X-TARGETDURATION less than EXTINF:7.30 
>>> EXTINF:8.33
>> 
>> 
>> 2. the version maybe will update when use hls_segment_type or 
>> append_list etc. when the operation is support from different version 
>> m3u8.
> 
> I don't follow what you mean here. The version number is known up front, 
> based on the options that were passed in. It should be illegal to switch 
> between versions when trying to update an existing manifest. When can 
> this legitimately happen?
 there maybe have some player cannot support high version of m3u8, for 
 example old parser or player just support the VERSION 3,
 this must think about all of the player or parser, because ffmpeg is not 
 used only by myself.
 
 Or what about get the #EXT-X-VERSION position, to update it? looks like 
 flvenc.c or movenc.c date shift
 
> 
>> 3. need update segments vs->segments when hls_list_size option is set.
>> 
> 
> What do you mean by this and where should I do it?
 for example, hls_list_size is 4, the m3u8 list should refresh every time 
 when make a new fragment.
 
 first time:
 1.m4s
 2.m4s
 3.m4s
 4.m4s
 
 sencond time:
 2.m4s
 3.m4s
 4.m4s
 5.m4s
>>> 
>>> after your patch:
>>> 
>>> liuqideMacBook-Pro:xxx liuqi$  ./ffmpeg -v quiet -i 
>>> ~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c copy -f hls 
>>> -hls_list_size 4 -hls_segment_type fmp4 -hls_time 3 -t 50 output_test.m3u8
>>> liuqideMacBook-Pro:xxx liuqi$ cat output_test.m3u8
>>> #EXTM3U
>>> #EXT-X-VERSION:7
>>> #EXT-X-TARGETDURATION:3
>>> 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak Patel


> On Aug 1, 2018, at 9:30 PM, Ronak Patel  
> wrote:
> 
> 
>> On Aug 1, 2018, at 7:30 PM, Steven Liu  wrote:
>> 
>> 
>> 
>>> On Aug 2, 2018, at 07:22, Steven Liu  wrote:
>>> 
>>> 
>>> 
> On Aug 2, 2018, at 06:20, Ronak  wrote:
> 
> 
> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 03:50, Ronak  
>> wrote:
>> 
>> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
> From: "Ronak Patel (Audible)" 
> Date: Tue, 31 Jul 2018 19:05:18 -0400
> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an 
> N^2
> algorithm to N.
> 
> This fixes the creation of the hls manifest in hlsenc.c by writing the 
> header once in hls_write_header, and the segments individually in the 
> hls_window method.
> Files that would previously take over a week to fragment now take 1 
> minute on the same hardware. This was a 153 hour audio file (2.2GB of 
> audio).
> 
> Signed-off-by: Ronak Patel 
> ---
> libavformat/hlsenc.c | 143 
> +++
> 1 file changed, 76 insertions(+), 67 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index b5644f0..b15645d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext 
> *s, HLSContext *hls,
>  }
>  p = (char *)av_basename(dirname);
>  *p = '\0';
> -
>  }
> 
>  while (segment) {
> @@ -1365,63 +1364,37 @@ fail:
>  return ret;
> }
> 
> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
> VariantStream *vs)
> {
>  HLSContext *hls = s->priv_data;
>  HLSSegment *en;
> -int target_duration = 0;
>  int ret = 0;
> -char temp_filename[1024];
> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
> vs->nb_entries);
> -const char *proto = avio_find_protocol_name(s->url);
> -int use_rename = proto && !strcmp(proto, "file");
> -static unsigned warned_non_file;
> +int byterange_mode;
>  char *key_uri = NULL;
>  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;
> -if (byterange_mode) {
> -hls->version = 4;
> -sequence = 0;
> -}
> -
> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
> -hls->version = 6;
> -}
> 
> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> -hls->version = 7;
> -}
> +if (last) {
> 
> -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");
> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
> +ff_hls_write_end_list(hls->m3u8_out);
> +}
> 
> -set_http_options(s, , hls);
> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" 
> : "%s", vs->m3u8_name);
> -if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, 
> )) < 0)
> -goto fail;
> +if (vs->vtt_m3u8_name) {
> +ff_hls_write_end_list(hls->sub_m3u8_out);
> +}
> +} else {
> 
> -for (en = vs->segments; en; en = en->next) {
> -if (target_duration <= en->duration)
> -target_duration = lrint(en->duration);
> -}
> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
> (hls->max_seg_size > 0);
> 
> -vs->discontinuity_set = 0;
> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
> hls->allowcache,
> - target_duration, sequence, 
> hls->pl_type);
> +en = vs->last_segment;
> +if (en == NULL) {
> +ret = 1;
> +goto fail;
> +}
> 
> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence 
> && vs->discontinuity_set==0 ){
> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
> -vs->discontinuity_set = 1;
> -}
> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
> -avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
> -}
> -for (en = vs->segments; en; en = en->next) {
> 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak Patel

> On Aug 1, 2018, at 7:30 PM, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 07:22, Steven Liu  wrote:
>> 
>> 
>> 
 On Aug 2, 2018, at 06:20, Ronak  wrote:
 
 
 On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
 
 
 
> On Aug 2, 2018, at 03:50, Ronak  wrote:
> 
> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
 From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
 From: "Ronak Patel (Audible)" 
 Date: Tue, 31 Jul 2018 19:05:18 -0400
 Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an 
 N^2
 algorithm to N.
 
 This fixes the creation of the hls manifest in hlsenc.c by writing the 
 header once in hls_write_header, and the segments individually in the 
 hls_window method.
 Files that would previously take over a week to fragment now take 1 minute 
 on the same hardware. This was a 153 hour audio file (2.2GB of audio).
 
 Signed-off-by: Ronak Patel 
 ---
 libavformat/hlsenc.c | 143 
 +++
 1 file changed, 76 insertions(+), 67 deletions(-)
 
 diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
 index b5644f0..b15645d 100644
 --- a/libavformat/hlsenc.c
 +++ b/libavformat/hlsenc.c
 @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
 HLSContext *hls,
   }
   p = (char *)av_basename(dirname);
   *p = '\0';
 -
   }
 
   while (segment) {
 @@ -1365,63 +1364,37 @@ fail:
   return ret;
 }
 
 -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
 +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
 VariantStream *vs)
 {
   HLSContext *hls = s->priv_data;
   HLSSegment *en;
 -int target_duration = 0;
   int ret = 0;
 -char temp_filename[1024];
 -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
 vs->nb_entries);
 -const char *proto = avio_find_protocol_name(s->url);
 -int use_rename = proto && !strcmp(proto, "file");
 -static unsigned warned_non_file;
 +int byterange_mode;
   char *key_uri = NULL;
   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;
 -if (byterange_mode) {
 -hls->version = 4;
 -sequence = 0;
 -}
 -
 -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
 -hls->version = 6;
 -}
 
 -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 -hls->version = 7;
 -}
 +if (last) {
 
 -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");
 +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
 +ff_hls_write_end_list(hls->m3u8_out);
 +}
 
 -set_http_options(s, , hls);
 -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" 
 : "%s", vs->m3u8_name);
 -if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, 
 )) < 0)
 -goto fail;
 +if (vs->vtt_m3u8_name) {
 +ff_hls_write_end_list(hls->sub_m3u8_out);
 +}
 +} else {
 
 -for (en = vs->segments; en; en = en->next) {
 -if (target_duration <= en->duration)
 -target_duration = lrint(en->duration);
 -}
 +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
 (hls->max_seg_size > 0);
 
 -vs->discontinuity_set = 0;
 -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
 hls->allowcache,
 - target_duration, sequence, hls->pl_type);
 +en = vs->last_segment;
 +if (en == NULL) {
 +ret = 1;
 +goto fail;
 +}
 
 -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence 
 && vs->discontinuity_set==0 ){
 -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
 -vs->discontinuity_set = 1;
 -}
 -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
 -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))) {
   

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Steven Liu


> On Aug 2, 2018, at 07:22, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 06:20, Ronak  wrote:
>> 
>>> 
>>> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
>>> 
>>> 
>>> 
 On Aug 2, 2018, at 03:50, Ronak  wrote:
 
 <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
>>> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
>>> From: "Ronak Patel (Audible)" 
>>> Date: Tue, 31 Jul 2018 19:05:18 -0400
>>> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
>>> algorithm to N.
>>> 
>>> This fixes the creation of the hls manifest in hlsenc.c by writing the 
>>> header once in hls_write_header, and the segments individually in the 
>>> hls_window method.
>>> Files that would previously take over a week to fragment now take 1 minute 
>>> on the same hardware. This was a 153 hour audio file (2.2GB of audio).
>>> 
>>> Signed-off-by: Ronak Patel 
>>> ---
>>> libavformat/hlsenc.c | 143 
>>> +++
>>> 1 file changed, 76 insertions(+), 67 deletions(-)
>>> 
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index b5644f0..b15645d 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>>> HLSContext *hls,
>>>}
>>>p = (char *)av_basename(dirname);
>>>*p = '\0';
>>> -
>>>}
>>> 
>>>while (segment) {
>>> @@ -1365,63 +1364,37 @@ fail:
>>>return ret;
>>> }
>>> 
>>> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
>>> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
>>> VariantStream *vs)
>>> {
>>>HLSContext *hls = s->priv_data;
>>>HLSSegment *en;
>>> -int target_duration = 0;
>>>int ret = 0;
>>> -char temp_filename[1024];
>>> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
>>> vs->nb_entries);
>>> -const char *proto = avio_find_protocol_name(s->url);
>>> -int use_rename = proto && !strcmp(proto, "file");
>>> -static unsigned warned_non_file;
>>> +int byterange_mode;
>>>char *key_uri = NULL;
>>>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;
>>> -if (byterange_mode) {
>>> -hls->version = 4;
>>> -sequence = 0;
>>> -}
>>> -
>>> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
>>> -hls->version = 6;
>>> -}
>>> 
>>> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>>> -hls->version = 7;
>>> -}
>>> +if (last) {
>>> 
>>> -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");
>>> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
>>> +ff_hls_write_end_list(hls->m3u8_out);
>>> +}
>>> 
>>> -set_http_options(s, , hls);
>>> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
>>> "%s", vs->m3u8_name);
>>> -if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, )) 
>>> < 0)
>>> -goto fail;
>>> +if (vs->vtt_m3u8_name) {
>>> +ff_hls_write_end_list(hls->sub_m3u8_out);
>>> +}
>>> +} else {
>>> 
>>> -for (en = vs->segments; en; en = en->next) {
>>> -if (target_duration <= en->duration)
>>> -target_duration = lrint(en->duration);
>>> -}
>>> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
>>> (hls->max_seg_size > 0);
>>> 
>>> -vs->discontinuity_set = 0;
>>> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
>>> hls->allowcache,
>>> - target_duration, sequence, hls->pl_type);
>>> +en = vs->last_segment;
>>> +if (en == NULL) {
>>> +ret = 1;
>>> +goto fail;
>>> +}
>>> 
>>> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence 
>>> && vs->discontinuity_set==0 ){
>>> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
>>> -vs->discontinuity_set = 1;
>>> -}
>>> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
>>> -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(hls->m3u8_out, 
>>> "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
>>> @@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int last, 
>>> VariantStream 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Steven Liu


> On Aug 2, 2018, at 06:20, Ronak  wrote:
> 
>> 
>> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
>> 
>> 
>> 
>>> On Aug 2, 2018, at 03:50, Ronak  wrote:
>>> 
>>> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
>> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
>> From: "Ronak Patel (Audible)" 
>> Date: Tue, 31 Jul 2018 19:05:18 -0400
>> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
>> algorithm to N.
>> 
>> This fixes the creation of the hls manifest in hlsenc.c by writing the 
>> header once in hls_write_header, and the segments individually in the 
>> hls_window method.
>> Files that would previously take over a week to fragment now take 1 minute 
>> on the same hardware. This was a 153 hour audio file (2.2GB of audio).
>> 
>> Signed-off-by: Ronak Patel 
>> ---
>> libavformat/hlsenc.c | 143 
>> +++
>> 1 file changed, 76 insertions(+), 67 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index b5644f0..b15645d 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>> HLSContext *hls,
>> }
>> p = (char *)av_basename(dirname);
>> *p = '\0';
>> -
>> }
>> 
>> while (segment) {
>> @@ -1365,63 +1364,37 @@ fail:
>> return ret;
>> }
>> 
>> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
>> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
>> VariantStream *vs)
>> {
>> HLSContext *hls = s->priv_data;
>> HLSSegment *en;
>> -int target_duration = 0;
>> int ret = 0;
>> -char temp_filename[1024];
>> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
>> vs->nb_entries);
>> -const char *proto = avio_find_protocol_name(s->url);
>> -int use_rename = proto && !strcmp(proto, "file");
>> -static unsigned warned_non_file;
>> +int byterange_mode;
>> char *key_uri = NULL;
>> 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;
>> -if (byterange_mode) {
>> -hls->version = 4;
>> -sequence = 0;
>> -}
>> -
>> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
>> -hls->version = 6;
>> -}
>> 
>> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>> -hls->version = 7;
>> -}
>> +if (last) {
>> 
>> -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");
>> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
>> +ff_hls_write_end_list(hls->m3u8_out);
>> +}
>> 
>> -set_http_options(s, , hls);
>> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
>> "%s", vs->m3u8_name);
>> -if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, )) 
>> < 0)
>> -goto fail;
>> +if (vs->vtt_m3u8_name) {
>> +ff_hls_write_end_list(hls->sub_m3u8_out);
>> +}
>> +} else {
>> 
>> -for (en = vs->segments; en; en = en->next) {
>> -if (target_duration <= en->duration)
>> -target_duration = lrint(en->duration);
>> -}
>> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
>> (hls->max_seg_size > 0);
>> 
>> -vs->discontinuity_set = 0;
>> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
>> hls->allowcache,
>> - target_duration, sequence, hls->pl_type);
>> +en = vs->last_segment;
>> +if (en == NULL) {
>> +ret = 1;
>> +goto fail;
>> +}
>> 
>> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
>> vs->discontinuity_set==0 ){
>> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
>> -vs->discontinuity_set = 1;
>> -}
>> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
>> -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(hls->m3u8_out, 
>> "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
>> @@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int last, 
>> VariantStream *vs)
>> if (ret < 0) {
>> av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
>> }
>> -}
>> -
>> -if (last && (hls->flags & 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak

> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 03:50, Ronak  wrote:
>> 
>> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
> From: "Ronak Patel (Audible)" 
> Date: Tue, 31 Jul 2018 19:05:18 -0400
> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
> algorithm to N.
> 
> This fixes the creation of the hls manifest in hlsenc.c by writing the header 
> once in hls_write_header, and the segments individually in the hls_window 
> method.
> Files that would previously take over a week to fragment now take 1 minute on 
> the same hardware. This was a 153 hour audio file (2.2GB of audio).
> 
> Signed-off-by: Ronak Patel 
> ---
> libavformat/hlsenc.c | 143 +++
> 1 file changed, 76 insertions(+), 67 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index b5644f0..b15645d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
> HLSContext *hls,
> }
> p = (char *)av_basename(dirname);
> *p = '\0';
> -
> }
> 
> while (segment) {
> @@ -1365,63 +1364,37 @@ fail:
> return ret;
> }
> 
> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
> VariantStream *vs)
> {
> HLSContext *hls = s->priv_data;
> HLSSegment *en;
> -int target_duration = 0;
> int ret = 0;
> -char temp_filename[1024];
> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
> vs->nb_entries);
> -const char *proto = avio_find_protocol_name(s->url);
> -int use_rename = proto && !strcmp(proto, "file");
> -static unsigned warned_non_file;
> +int byterange_mode;
> char *key_uri = NULL;
> 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;
> -if (byterange_mode) {
> -hls->version = 4;
> -sequence = 0;
> -}
> -
> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
> -hls->version = 6;
> -}
> 
> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> -hls->version = 7;
> -}
> +if (last) {
> 
> -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");
> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
> +ff_hls_write_end_list(hls->m3u8_out);
> +}
> 
> -set_http_options(s, , hls);
> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
> "%s", vs->m3u8_name);
> -if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, )) < 
> 0)
> -goto fail;
> +if (vs->vtt_m3u8_name) {
> +ff_hls_write_end_list(hls->sub_m3u8_out);
> +}
> +} else {
> 
> -for (en = vs->segments; en; en = en->next) {
> -if (target_duration <= en->duration)
> -target_duration = lrint(en->duration);
> -}
> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
> (hls->max_seg_size > 0);
> 
> -vs->discontinuity_set = 0;
> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
> hls->allowcache,
> - target_duration, sequence, hls->pl_type);
> +en = vs->last_segment;
> +if (en == NULL) {
> +ret = 1;
> +goto fail;
> +}
> 
> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
> vs->discontinuity_set==0 ){
> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
> -vs->discontinuity_set = 1;
> -}
> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
> -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(hls->m3u8_out, 
> "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
> @@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> if (ret < 0) {
> av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
> }
> -}
> -
> -if (last && (hls->flags & HLS_OMIT_ENDLIST)==0)
> -ff_hls_write_end_list(hls->m3u8_out);
> 
> -if( vs->vtt_m3u8_name ) {
> -if ((ret = hlsenc_io_open(s, >sub_m3u8_out, vs->vtt_m3u8_name, 
> )) < 0)
> 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Steven Liu


> On Aug 2, 2018, at 03:50, Ronak  wrote:
> 
> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
From: "Ronak Patel (Audible)" 
Date: Tue, 31 Jul 2018 19:05:18 -0400
Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
 algorithm to N.

This fixes the creation of the hls manifest in hlsenc.c by writing the header 
once in hls_write_header, and the segments individually in the hls_window 
method.
Files that would previously take over a week to fragment now take 1 minute on 
the same hardware. This was a 153 hour audio file (2.2GB of audio).

Signed-off-by: Ronak Patel 
---
 libavformat/hlsenc.c | 143 +++
 1 file changed, 76 insertions(+), 67 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index b5644f0..b15645d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 }
 p = (char *)av_basename(dirname);
 *p = '\0';
-
 }
 
 while (segment) {
@@ -1365,63 +1364,37 @@ fail:
 return ret;
 }
 
-static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
+static int hls_write_manifest_segment(AVFormatContext *s, int last, 
VariantStream *vs)
 {
 HLSContext *hls = s->priv_data;
 HLSSegment *en;
-int target_duration = 0;
 int ret = 0;
-char temp_filename[1024];
-int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
vs->nb_entries);
-const char *proto = avio_find_protocol_name(s->url);
-int use_rename = proto && !strcmp(proto, "file");
-static unsigned warned_non_file;
+int byterange_mode;
 char *key_uri = NULL;
 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;
-if (byterange_mode) {
-hls->version = 4;
-sequence = 0;
-}
-
-if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
-hls->version = 6;
-}
 
-if (hls->segment_type == SEGMENT_TYPE_FMP4) {
-hls->version = 7;
-}
+if (last) {
 
-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");
+if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
+ff_hls_write_end_list(hls->m3u8_out);
+}
 
-set_http_options(s, , hls);
-snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
"%s", vs->m3u8_name);
-if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, )) < 0)
-goto fail;
+if (vs->vtt_m3u8_name) {
+ff_hls_write_end_list(hls->sub_m3u8_out);
+}
+} else {
 
-for (en = vs->segments; en; en = en->next) {
-if (target_duration <= en->duration)
-target_duration = lrint(en->duration);
-}
+byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size 
> 0);
 
-vs->discontinuity_set = 0;
-ff_hls_write_playlist_header(hls->m3u8_out, hls->version, hls->allowcache,
- target_duration, sequence, hls->pl_type);
+en = vs->last_segment;
+if (en == NULL) {
+ret = 1;
+goto fail;
+}
 
-if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
vs->discontinuity_set==0 ){
-avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
-vs->discontinuity_set = 1;
-}
-if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
-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(hls->m3u8_out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", 
en->key_uri);
@@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 if (ret < 0) {
 av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
 }
-}
-
-if (last && (hls->flags & HLS_OMIT_ENDLIST)==0)
-ff_hls_write_end_list(hls->m3u8_out);
 
-if( vs->vtt_m3u8_name ) {
-if ((ret = hlsenc_io_open(s, >sub_m3u8_out, vs->vtt_m3u8_name, 
)) < 0)
-goto fail;
-ff_hls_write_playlist_header(hls->sub_m3u8_out, hls->version, 
hls->allowcache,
- target_duration, sequence, 
PLAYLIST_TYPE_NONE);
-for (en = vs->segments; en; en = en->next) {
+if( vs->vtt_m3u8_name ) {
 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak
> On Aug 1, 2018, at 2:14 PM, Carl Eugen Hoyos  wrote:
> 
> 2018-08-01 20:02 GMT+02:00, Ronak :
>> I'm re-sending the attachment.
> 
> Your patch contains tabs that cannot be committed to FFmpeg's repository -
> please remove them.
> 

Sounds good. Tabs are now removed.



0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch
Description: Binary data



> 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] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Carl Eugen Hoyos
2018-08-01 20:02 GMT+02:00, Ronak :
> I'm re-sending the attachment.

Your patch contains tabs that cannot be committed to FFmpeg's repository -
please remove them.

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak
I'm re-sending the attachment. Not sure why it's not showing up.



0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch
Description: Binary data


> On Aug 1, 2018, at 1:56 PM, Carl Eugen Hoyos  wrote:
> 
> 2018-08-01 18:39 GMT+02:00, Ronak :
> 
>> Here's my first proposed patch for fixing
>> https://trac.ffmpeg.org/ticket/7281
> 
> No patch visible here:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2018-August/232785.html
> 
> 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] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Carl Eugen Hoyos
2018-08-01 18:39 GMT+02:00, Ronak :

> Here's my first proposed patch for fixing
> https://trac.ffmpeg.org/ticket/7281

No patch visible here:
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-August/232785.html

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