diff mbox

[FFmpeg-devel] accurrate time output in program_date_time

Message ID 20190709084337.314-1-pilarpav@centrum.cz
State New
Headers show

Commit Message

Pavel Pilar July 9, 2019, 8:43 a.m. UTC
---
 libavformat/hlsenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

mypopy@gmail.com July 9, 2019, 9 a.m. UTC | #1
On Tue, Jul 9, 2019 at 4:43 PM Pavel Pilar <pilarpav@centrum.cz> wrote:
>
> ---
>  libavformat/hlsenc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 057134f410..00c725af18 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -23,6 +23,7 @@
>  #include "config.h"
>  #include <float.h>
>  #include <stdint.h> i
> +#include <time.h>
>  #if HAVE_UNISTD_H
>  #include <unistd.h>
>  #endif
> @@ -2741,9 +2742,15 @@ static int hls_init(AVFormatContext *s)
>          }
>
>          if (hls->flags & HLS_PROGRAM_DATE_TIME) {
> +#ifdef _POSIX_TIMERS
> +            struct timespec now0;
> +            clock_gettime(CLOCK_MONOTONIC, &now0);
> +            vs->initial_prog_date_time = now0.tv_sec + now0.tv_nsec / 1e9;
> +#else
I think you can use av_gettime() in this case
>              time_t now0;
>              time(&now0);
>              vs->initial_prog_date_time = now0;
> +#endif
>          }
>          if (hls->format_options_str) {
>              ret = av_dict_parse_string(&hls->format_options, hls->format_options_str, "=", ":", 0);
> --
> 2.17.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 057134f410..00c725af18 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -23,6 +23,7 @@ 
 #include "config.h"
 #include <float.h>
 #include <stdint.h>
+#include <time.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -2741,9 +2742,15 @@  static int hls_init(AVFormatContext *s)
         }
 
         if (hls->flags & HLS_PROGRAM_DATE_TIME) {
+#ifdef _POSIX_TIMERS           
+            struct timespec now0;
+            clock_gettime(CLOCK_MONOTONIC, &now0);
+            vs->initial_prog_date_time = now0.tv_sec + now0.tv_nsec / 1e9;
+#else
             time_t now0;
             time(&now0);
             vs->initial_prog_date_time = now0;
+#endif
         }
         if (hls->format_options_str) {
             ret = av_dict_parse_string(&hls->format_options, hls->format_options_str, "=", ":", 0);