[FFmpeg-devel] [PATCH] avformat/hlsenc: actual segment file size and duration in segment filenames

Bodecs Bela bodecsb at vivanet.hu
Tue Jan 3 10:11:42 EET 2017



2017.01.03. 2:34 keltezéssel, Steven Liu írta:
> 2017-01-03 8:22 GMT+08:00 Steven Liu <lingjiujianke at gmail.com>:
>
>>
>> 2017-01-03 2:58 GMT+08:00 Bodecs Bela <bodecsb at vivanet.hu>:
>>
>>> Dear All,
>>>
>>> this patch makes it possible to put actual segment file size (measured
>>> in bytes) and/or duration (calculated in microseconds) into segment
>>> filenames. This feature is useful when post-processing live streaming
>>> access log files. New behaviour works only when -use_localtime option
>>> is set and second_level_segment_size or/and
>>> second_level_segment_duration new hls_flags are specified. %%s is the
>>> placeholder for size and %%t for duration in hls_segment_filename
>>> option. Fix sized trailing zeropadding also works eg. %%09s or %%023t.
>>>
>>> A command to test new features:
>>> ./ffmpeg -loglevel info -y -f lavfi -i color=c=red:size=640x480:r=25 -f
>>> lavfi -i sine=f=440:b=4:r=44100 -c:v mpeg2video -g 25 -acodec aac
>>> -cutoff 20000 -ac 2 -ar 44100 -ab 192k -f hls -hls_time 3 -hls_list_size
>>> 5 -hls_flags
>>> second_level_segment_index+second_level_segment_size+second_
>>> level_segment_duration
>>> -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename
>>> "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8
>>>
>>> this will produce segments like this:
>>> segment_20170102194334_0003_00122200_0000003000000.ts
>>> segment_20170102194334_0004_00120072_0000003000000.ts
>>> etc.
>>>
>>>
>>> thank you in advance,
>>>
>>> Bela Bodecs
>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>>
>> you should add document for the new option.
>>
> in +static int replace_int_data_in_filename(char *buf, int buf_size, const
> char *filename, char placeholder, int64_t number)
>
> +        c = *p;  //
> will add comment?
>
> in @@ -388,6 +443,38 @@ static int hls_append_segment(struct
> AVFormatContext *s, HLSContext *hls, double
>
> +    if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE |
> HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
> strlen(hls->current_segment_final_filename_fmt)) {
> This is one line and the line is too long, maybe split to or three line be
> better, The other too long line should be split.
I have shortened and splitted the lines and removed empty comment sign.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avformat-hlsenc-size-and-duration-in-segment-filenam.patch
Type: text/x-patch
Size: 13261 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170103/f3d11196/attachment.bin>


More information about the ffmpeg-devel mailing list