* [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix negative timestamps at the beginning of the encoding
@ 2023-07-03 22:13 Marton Balint
2023-07-09 8:48 ` Marton Balint
0 siblings, 1 reply; 2+ messages in thread
From: Marton Balint @ 2023-07-03 22:13 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Also fix a couple of possible overflows while at it.
Fixes the negative initial timestamps in ticket #10358.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
fftools/ffmpeg.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 435e12a37b..71d4067a6c 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -497,11 +497,12 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
int vid;
double bitrate;
double speed;
- int64_t pts = INT64_MIN + 1;
+ int64_t pts = AV_NOPTS_VALUE;
static int64_t last_time = -1;
static int first_report = 1;
uint64_t nb_frames_dup = 0, nb_frames_drop = 0;
- int hours, mins, secs, us;
+ int mins, secs, us;
+ int64_t hours;
const char *hours_sign;
int ret;
float t;
@@ -553,7 +554,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
}
/* compute min output value */
if (ost->last_mux_dts != AV_NOPTS_VALUE) {
- pts = FFMAX(pts, ost->last_mux_dts);
+ if (pts == AV_NOPTS_VALUE || ost->last_mux_dts > pts)
+ pts = ost->last_mux_dts;
if (copy_ts) {
if (copy_ts_first_pts == AV_NOPTS_VALUE && pts > 1)
copy_ts_first_pts = pts;
@@ -566,23 +568,21 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
nb_frames_drop += ost->last_dropped;
}
- secs = FFABS(pts) / AV_TIME_BASE;
- us = FFABS(pts) % AV_TIME_BASE;
- mins = secs / 60;
- secs %= 60;
- hours = mins / 60;
- mins %= 60;
+ us = FFABS64U(pts) % AV_TIME_BASE;
+ secs = FFABS64U(pts) / AV_TIME_BASE % 60;
+ mins = FFABS64U(pts) / AV_TIME_BASE / 60 % 60;
+ hours = FFABS64U(pts) / AV_TIME_BASE / 3600;
hours_sign = (pts < 0) ? "-" : "";
- bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
- speed = t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
+ bitrate = pts != AV_NOPTS_VALUE && pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
+ speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
if (total_size < 0) av_bprintf(&buf, "size=N/A time=");
else av_bprintf(&buf, "size=%8.0fkB time=", total_size / 1024.0);
if (pts == AV_NOPTS_VALUE) {
av_bprintf(&buf, "N/A ");
} else {
- av_bprintf(&buf, "%s%02d:%02d:%02d.%02d ",
+ av_bprintf(&buf, "%s%02"PRId64":%02d:%02d.%02d ",
hours_sign, hours, mins, secs, (100 * us) / AV_TIME_BASE);
}
@@ -603,7 +603,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
} else {
av_bprintf(&buf_script, "out_time_us=%"PRId64"\n", pts);
av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts);
- av_bprintf(&buf_script, "out_time=%s%02d:%02d:%02d.%06d\n",
+ av_bprintf(&buf_script, "out_time=%s%02"PRId64":%02d:%02d.%06d\n",
hours_sign, hours, mins, secs, us);
}
--
2.35.3
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix negative timestamps at the beginning of the encoding
2023-07-03 22:13 [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix negative timestamps at the beginning of the encoding Marton Balint
@ 2023-07-09 8:48 ` Marton Balint
0 siblings, 0 replies; 2+ messages in thread
From: Marton Balint @ 2023-07-09 8:48 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Tue, 4 Jul 2023, Marton Balint wrote:
> Also fix a couple of possible overflows while at it.
>
> Fixes the negative initial timestamps in ticket #10358.
Will apply.
Regards,
Marton
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> fftools/ffmpeg.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 435e12a37b..71d4067a6c 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -497,11 +497,12 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
> int vid;
> double bitrate;
> double speed;
> - int64_t pts = INT64_MIN + 1;
> + int64_t pts = AV_NOPTS_VALUE;
> static int64_t last_time = -1;
> static int first_report = 1;
> uint64_t nb_frames_dup = 0, nb_frames_drop = 0;
> - int hours, mins, secs, us;
> + int mins, secs, us;
> + int64_t hours;
> const char *hours_sign;
> int ret;
> float t;
> @@ -553,7 +554,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
> }
> /* compute min output value */
> if (ost->last_mux_dts != AV_NOPTS_VALUE) {
> - pts = FFMAX(pts, ost->last_mux_dts);
> + if (pts == AV_NOPTS_VALUE || ost->last_mux_dts > pts)
> + pts = ost->last_mux_dts;
> if (copy_ts) {
> if (copy_ts_first_pts == AV_NOPTS_VALUE && pts > 1)
> copy_ts_first_pts = pts;
> @@ -566,23 +568,21 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
> nb_frames_drop += ost->last_dropped;
> }
>
> - secs = FFABS(pts) / AV_TIME_BASE;
> - us = FFABS(pts) % AV_TIME_BASE;
> - mins = secs / 60;
> - secs %= 60;
> - hours = mins / 60;
> - mins %= 60;
> + us = FFABS64U(pts) % AV_TIME_BASE;
> + secs = FFABS64U(pts) / AV_TIME_BASE % 60;
> + mins = FFABS64U(pts) / AV_TIME_BASE / 60 % 60;
> + hours = FFABS64U(pts) / AV_TIME_BASE / 3600;
> hours_sign = (pts < 0) ? "-" : "";
>
> - bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
> - speed = t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
> + bitrate = pts != AV_NOPTS_VALUE && pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
> + speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
>
> if (total_size < 0) av_bprintf(&buf, "size=N/A time=");
> else av_bprintf(&buf, "size=%8.0fkB time=", total_size / 1024.0);
> if (pts == AV_NOPTS_VALUE) {
> av_bprintf(&buf, "N/A ");
> } else {
> - av_bprintf(&buf, "%s%02d:%02d:%02d.%02d ",
> + av_bprintf(&buf, "%s%02"PRId64":%02d:%02d.%02d ",
> hours_sign, hours, mins, secs, (100 * us) / AV_TIME_BASE);
> }
>
> @@ -603,7 +603,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
> } else {
> av_bprintf(&buf_script, "out_time_us=%"PRId64"\n", pts);
> av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts);
> - av_bprintf(&buf_script, "out_time=%s%02d:%02d:%02d.%06d\n",
> + av_bprintf(&buf_script, "out_time=%s%02"PRId64":%02d:%02d.%06d\n",
> hours_sign, hours, mins, secs, us);
> }
>
> --
> 2.35.3
>
> _______________________________________________
> 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".
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-09 8:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 22:13 [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix negative timestamps at the beginning of the encoding Marton Balint
2023-07-09 8:48 ` Marton Balint
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git