[FFmpeg-user] HLS Streaming - FFMPEG: Program date time of older segment also changing in playlist.m3u8 when re-streaming after discontinuity.

2020-11-11 Thread Suriya Velusamy
HI,

Following is the ffmpeg command used to stream the data.

ffmpeg -re -f avfoundation

-framerate 30 -i 0

-codec:v h264_videotoolbox -x264-params keyint=120:scenecut=0

-codec:a copy -f hls

-hls_list_size 60

-hls_time 10

-hls_flags delete_segments

-hls_flags +append_list

-hls_flags +discont_start

-hls_flags +program_date_time

-strftime 1

-strftime_mkdir 1

-hls_segment_filename

'%Y%m%dT%H%M%S%z.ts' playlist.m3u8



Following is the playlist.m3u8 content which generated for a few seconds.



#EXTM3U

#EXT-X-VERSION:3

#EXT-X-TARGETDURATION:10

#EXT-X-MEDIA-SEQUENCE:0

#EXT-X-DISCONTINUITY

#EXT-X-DISCONTINUITY

#EXTINF:10.00,

#EXT-X-PROGRAM-DATE-TIME:2020-11-09T22:07:53.000+0530

20201109T220753+0530.ts

#EXTINF:10.00,

#EXT-X-PROGRAM-DATE-TIME:2020-11-09T22:08:03.000+0530

20201109T220803+0530.ts

#EXT-X-ENDLIST



When the re-stream happens(in case of restarting the streaming service),
the program date time of older segments(before #EXT-X-DISCONTINUITY) also
get changed like below which is unexpected.



#EXTM3U

#EXT-X-VERSION:3

#EXT-X-TARGETDURATION:10

#EXT-X-MEDIA-SEQUENCE:0

#EXT-X-DISCONTINUITY

#EXT-X-DISCONTINUITY

#EXTINF:10.00,

#EXT-X-PROGRAM-DATE-TIME:2020-11-09T22:12:50.633+0530

20201109T220753+0530.ts

#EXTINF:10.00,

#EXT-X-PROGRAM-DATE-TIME:2020-11-09T22:13:00.633+0530

20201109T220803+0530.ts

#EXT-X-DISCONTINUITY

#EXTINF:10.00,

#EXT-X-PROGRAM-DATE-TIME:2020-11-09T22:13:12.000+0530

20201109T221312+0530.ts

#EXTINF:5.40,

#EXT-X-PROGRAM-DATE-TIME:2020-11-09T22:13:22.000+0530

20201109T221322+0530.ts

#EXT-X-ENDLIST



Why does the program date time of older segments change? Should we add any
arguments explicitly in ffmpeg command to handle this?



Regards,

Suriya V.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] HLS Streaming - FFMPEG: Program date time of older segment also changing in playlist.m3u8 when re-streaming after discontinuity.

2020-11-11 Thread andrei ka
you mean the names of segments are the same, not "program time"... would
make sense to me if the idea was related to kicking the last couple of ts
out from caches (you may need to read src code for understanding why it's
happening)... what if you delete all m3u8 before restart... ?

&rei
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] HLS Streaming - FFMPEG: Program date time of older segment also changing in playlist.m3u8 when re-streaming after discontinuity.

2020-11-12 Thread Vignesh Ravichandran
andrei ka wrote
> you mean the names of segments are the same, not "program time"... would
> make sense to me if the idea was related to kicking the last couple of ts
> out from caches (you may need to read src code for understanding why it's
> happening)... what if you delete all m3u8 before restart... ?
> 
> &rei
> ___
> ffmpeg-user mailing list

> ffmpeg-user@

> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> 
> To unsubscribe, visit link above, or email

> ffmpeg-user-request@

>  with subject "unsubscribe".


*Did some digging into the code base and found the below behavior:*

1. The initial_prog_date_time gets set to the current local time
2. The existing playlist (.m3u8) file gets parsed and the segments present
are added to the variant stream
3. The new segment is created and added to the variant stream
4. The existing segments and the new segment are written to the playlist
file.
   The initial_prog_date_time from point 1 is used for calculating
"#EXT-X-PROGRAM-DATE-TIME" for the segments,
   which results in incorrect "#EXT-X-PROGRAM-DATE-TIME" values for existing
segments

*Contents of playlist file (.m3u8) used for debugging:*
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-DISCONTINUITY
#EXTINF:4.00,
#EXT-X-PROGRAM-DATE-TIME:2020-11-12T19:31:50.104+0530
20201112T193150+0530.ts
#EXTINF:4.00,
#EXT-X-PROGRAM-DATE-TIME:2020-11-12T19:31:54.104+0530
20201112T193154+0530.ts
#EXTINF:0.90,
#EXT-X-PROGRAM-DATE-TIME:2020-11-12T19:31:58.104+0530
20201112T193158+0530.ts
#EXT-X-ENDLIST

*Logs (Added more logs to hlsenc.c and hlsplaylist.c to produce the below):*

Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_videotoolbox))
Press [q] to stop, [?] for help
[hls muxer @ 0x7fd19e80b200] parse_playlist(): Parsing
20201112T193150+0530.ts
[hls muxer @ 0x7fd19e80b200] parse_playlist(): Parsing
20201112T193154+0530.ts
[hls muxer @ 0x7fd19e80b200] parse_playlist(): Parsing
20201112T193158+0530.ts
[hls muxer @ 0x7fd19e80b200] parse_playlist(): Initial program date time:
1605247848.848017 *// This Epoch second is equal to
2020-11-13T11:40:48.848+0530*
[hls muxer @ 0x7fd19e80b200] parse_playlist(): Parsing complete. 3 segments
added to vs->segments
Output #0, hls, to 'playlist.m3u8':
  Metadata:
encoder : Lavf58.64.100
Stream #0:0: Video: h264 (h264_videotoolbox), yuv420p(tv, progressive),
1280x720, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc
Metadata:
  encoder : Lavc58.112.102 h264_videotoolbox
[hls @ 0x7fd19e81c000] Opening '20201113T114057+0530.ts' for writing=72
drop=0 speed=0.974x
[hls @ 0x7fd19e81c000] Opening 'playlist.m3u8.tmp' for writing
ff_hls_write_file_entry(): Writing 20201112T193150+0530.ts with
program_datetime 2020-11-13T11:40:48.848+0530
ff_hls_write_file_entry(): Writing 20201112T193154+0530.ts with
program_datetime 2020-11-13T11:40:52.848+0530
ff_hls_write_file_entry(): Writing 20201112T193158+0530.ts with
program_datetime 2020-11-13T11:40:56.848+0530
ff_hls_write_file_entry(): Writing 20201113T114057+0530.ts with
program_datetime 2020-11-13T11:40:57.748+0530
[hls @ 0x7fd19e81c000] Opening '20201113T114101+0530.ts' for writing=146
drop=0 speed=0.984x
[hls @ 0x7fd19e81c000] Opening 'playlist.m3u8.tmp' for writing
ff_hls_write_file_entry(): Writing 20201112T193150+0530.ts with
program_datetime 2020-11-13T11:40:48.848+0530
ff_hls_write_file_entry(): Writing 20201112T193154+0530.ts with
program_datetime 2020-11-13T11:40:52.848+0530
ff_hls_write_file_entry(): Writing 20201112T193158+0530.ts with
program_datetime 2020-11-13T11:40:56.848+0530
ff_hls_write_file_entry(): Writing 20201113T114057+0530.ts with
program_datetime 2020-11-13T11:40:57.748+0530
ff_hls_write_file_entry(): Writing 20201113T114101+0530.ts with
program_datetime 2020-11-13T11:41:01.748+0530
[hls @ 0x7fd19e81c000] Opening '20201113T114105+0530.ts' for writing=155
drop=0 speed=0.984x
[hls @ 0x7fd19e81c000] Opening 'playlist.m3u8.tmp' for writing
ff_hls_write_file_entry(): Writing 20201112T193150+0530.ts with
program_datetime 2020-11-13T11:40:48.848+0530
ff_hls_write_file_entry(): Writing 20201112T193154+0530.ts with
program_datetime 2020-11-13T11:40:52.848+0530
ff_hls_write_file_entry(): Writing 20201112T193158+0530.ts with
program_datetime 2020-11-13T11:40:56.848+0530
ff_hls_write_file_entry(): Writing 20201113T114057+0530.ts with
program_datetime 2020-11-13T11:40:57.748+0530
ff_hls_write_file_entry(): Writing 20201113T114101+0530.ts with
program_datetime 2020-11-13T11:41:01.748+0530
ff_hls_write_file_entry(): Writing 20201113T114105+0530.ts with
program_datetime 2020-11-13T11:41:05.748+0530
frame=  264 fps= 30 q=-0.0 Lsize=N/A time=00:00:08.80 bitrate=N/A dup=159
drop=0 speed=1.01x
video:222kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown


Hope this helps



-
Vignesh
--
Sent from: http://www.ffmpeg-archive.org/