From 720edd050e43e029ee01afc50beee897a0dbc87b Mon Sep 17 00:00:00 2001 From: "Sue N. Cooper" Date: Sun, 3 Sep 2023 00:05:17 +0300 Subject: [PATCH 1/3] link agains libandroid, fixes #809 --- scripts/function-android.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/function-android.sh b/scripts/function-android.sh index 36415b4..5e87b04 100755 --- a/scripts/function-android.sh +++ b/scripts/function-android.sh @@ -404,9 +404,9 @@ get_common_linked_libraries() { # SUPPORTED ON API LEVEL 24 AND LATER if [[ ${API} -ge 24 ]]; then - echo "-lc -lm -ldl -llog -lcamera2ndk -lmediandk ${COMMON_LIBRARY_PATHS}" + echo "-lc -lm -ldl -llog -landroid -lcamera2ndk -lmediandk ${COMMON_LIBRARY_PATHS}" else - echo "-lc -lm -ldl -llog ${COMMON_LIBRARY_PATHS}" + echo "-lc -lm -ldl -llog -landroid ${COMMON_LIBRARY_PATHS}" echo -e "INFO: Building ffmpeg without native camera API which is not supported on Android API Level ${API}\n" 1>>"${BASEDIR}"/build.log 2>&1 fi ;; From f9d8ddca4c8db22b725b5d146989116323b6ffcd Mon Sep 17 00:00:00 2001 From: "Sue N. Cooper" Date: Sun, 3 Sep 2023 00:08:46 +0300 Subject: [PATCH 2/3] fix time statistics, fixes #804 --- .../src/main/cpp/fftools_ffmpeg.c | 22 +++++++++++++------ apple/src/fftools_ffmpeg.c | 22 +++++++++++++------ linux/src/fftools_ffmpeg.c | 22 +++++++++++++------ 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffmpeg.c b/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffmpeg.c index 19024cb..28aa83a 100644 --- a/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffmpeg.c +++ b/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffmpeg.c @@ -32,6 +32,10 @@ * * ffmpeg-kit changes by ARTHENICA LTD * + * 09.2023 + * -------------------------------------------------------- + * - forward_report method signature accepts pts to calculate the time + * * 07.2023 * -------------------------------------------------------- * - FFmpeg 6.0 changes migrated @@ -1725,11 +1729,19 @@ static void print_final_stats(int64_t total_size) } } -static void forward_report(uint64_t frame_number, float fps, float quality, int64_t total_size, int seconds, int microseconds, double bitrate, double speed) +static void forward_report(uint64_t frame_number, float fps, float quality, int64_t total_size, int64_t pts, double bitrate, double speed) { // FORWARD DATA if (report_callback != NULL) { - report_callback(frame_number, fps, quality, total_size, ((double)seconds*1000) + ((double)microseconds)/1000, bitrate, speed); + double milliseconds = 0; + if (pts != AV_NOPTS_VALUE) { + milliseconds = ((double)FFABS64U(pts)) / 1000; + } + if (pts < 0) { + report_callback(frame_number, fps, quality, total_size, 0 - milliseconds, bitrate, speed); + } else { + report_callback(frame_number, fps, quality, total_size, milliseconds, bitrate, speed); + } } } @@ -1864,11 +1876,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1; // FFmpegKit forward report - if (pts == AV_NOPTS_VALUE) { - forward_report(frame_number, fps, q, total_size, 0, 0, bitrate, speed); - } else { - forward_report(frame_number, fps, q, total_size, secs, us, bitrate, speed); - } + forward_report(frame_number, fps, q, total_size, pts, bitrate, speed); if (local_print_stats) { if (total_size < 0) av_bprintf(&buf, "size=N/A time="); diff --git a/apple/src/fftools_ffmpeg.c b/apple/src/fftools_ffmpeg.c index 19024cb..28aa83a 100644 --- a/apple/src/fftools_ffmpeg.c +++ b/apple/src/fftools_ffmpeg.c @@ -32,6 +32,10 @@ * * ffmpeg-kit changes by ARTHENICA LTD * + * 09.2023 + * -------------------------------------------------------- + * - forward_report method signature accepts pts to calculate the time + * * 07.2023 * -------------------------------------------------------- * - FFmpeg 6.0 changes migrated @@ -1725,11 +1729,19 @@ static void print_final_stats(int64_t total_size) } } -static void forward_report(uint64_t frame_number, float fps, float quality, int64_t total_size, int seconds, int microseconds, double bitrate, double speed) +static void forward_report(uint64_t frame_number, float fps, float quality, int64_t total_size, int64_t pts, double bitrate, double speed) { // FORWARD DATA if (report_callback != NULL) { - report_callback(frame_number, fps, quality, total_size, ((double)seconds*1000) + ((double)microseconds)/1000, bitrate, speed); + double milliseconds = 0; + if (pts != AV_NOPTS_VALUE) { + milliseconds = ((double)FFABS64U(pts)) / 1000; + } + if (pts < 0) { + report_callback(frame_number, fps, quality, total_size, 0 - milliseconds, bitrate, speed); + } else { + report_callback(frame_number, fps, quality, total_size, milliseconds, bitrate, speed); + } } } @@ -1864,11 +1876,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1; // FFmpegKit forward report - if (pts == AV_NOPTS_VALUE) { - forward_report(frame_number, fps, q, total_size, 0, 0, bitrate, speed); - } else { - forward_report(frame_number, fps, q, total_size, secs, us, bitrate, speed); - } + forward_report(frame_number, fps, q, total_size, pts, bitrate, speed); if (local_print_stats) { if (total_size < 0) av_bprintf(&buf, "size=N/A time="); diff --git a/linux/src/fftools_ffmpeg.c b/linux/src/fftools_ffmpeg.c index 19024cb..28aa83a 100644 --- a/linux/src/fftools_ffmpeg.c +++ b/linux/src/fftools_ffmpeg.c @@ -32,6 +32,10 @@ * * ffmpeg-kit changes by ARTHENICA LTD * + * 09.2023 + * -------------------------------------------------------- + * - forward_report method signature accepts pts to calculate the time + * * 07.2023 * -------------------------------------------------------- * - FFmpeg 6.0 changes migrated @@ -1725,11 +1729,19 @@ static void print_final_stats(int64_t total_size) } } -static void forward_report(uint64_t frame_number, float fps, float quality, int64_t total_size, int seconds, int microseconds, double bitrate, double speed) +static void forward_report(uint64_t frame_number, float fps, float quality, int64_t total_size, int64_t pts, double bitrate, double speed) { // FORWARD DATA if (report_callback != NULL) { - report_callback(frame_number, fps, quality, total_size, ((double)seconds*1000) + ((double)microseconds)/1000, bitrate, speed); + double milliseconds = 0; + if (pts != AV_NOPTS_VALUE) { + milliseconds = ((double)FFABS64U(pts)) / 1000; + } + if (pts < 0) { + report_callback(frame_number, fps, quality, total_size, 0 - milliseconds, bitrate, speed); + } else { + report_callback(frame_number, fps, quality, total_size, milliseconds, bitrate, speed); + } } } @@ -1864,11 +1876,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1; // FFmpegKit forward report - if (pts == AV_NOPTS_VALUE) { - forward_report(frame_number, fps, q, total_size, 0, 0, bitrate, speed); - } else { - forward_report(frame_number, fps, q, total_size, secs, us, bitrate, speed); - } + forward_report(frame_number, fps, q, total_size, pts, bitrate, speed); if (local_print_stats) { if (total_size < 0) av_bprintf(&buf, "size=N/A time="); From c937b29b7ac2d2396d5bddc17fd35317cef6be9c Mon Sep 17 00:00:00 2001 From: "Sue N. Cooper" Date: Sun, 3 Sep 2023 17:59:21 +0300 Subject: [PATCH 3/3] use new version in the readme --- android/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/README.md b/android/README.md index 95186c9..f678926 100644 --- a/android/README.md +++ b/android/README.md @@ -77,7 +77,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director } dependencies { - implementation 'com.arthenica:ffmpeg-kit-full:6.0' + implementation 'com.arthenica:ffmpeg-kit-full:6.0-1' } ```