1
0
Эх сурвалжийг харах

Log total/skipped frames on output stop

This makes it easier to do two things:
  1.) Get the skipped frames count relative to each specific output
  2.) Make it so that getting the 'current' log will always contain
      information about skipped frames.  Before, you'd have to force the
      user to restart the program and get the last log, which was really
      annoying when you just wanted to see how the encoders were
      performing.
jp9000 11 жил өмнө
parent
commit
b4311a0de1

+ 3 - 0
libobs/obs-internal.h

@@ -410,6 +410,9 @@ struct obs_output {
 	os_event_t                      reconnect_stop_event;
 	volatile bool                   reconnect_thread_active;
 
+	uint32_t                        starting_frame_count;
+	uint32_t                        starting_skipped_frame_count;
+
 	int                             total_frames;
 
 	bool                            active;

+ 40 - 2
libobs/obs-output.c

@@ -15,6 +15,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
 
+#include <inttypes.h>
 #include "util/platform.h"
 #include "obs.h"
 #include "obs-internal.h"
@@ -153,8 +154,42 @@ const char *obs_output_get_name(obs_output_t output)
 
 bool obs_output_start(obs_output_t output)
 {
-	return (output != NULL) ?
-		output->info.start(output->context.data) : false;
+	bool success;
+
+	if (!output)
+		return false;
+
+	success = output->info.start(output->context.data);
+
+	if (success && output->video) {
+		output->starting_frame_count =
+			video_output_get_total_frames(output->video);
+		output->starting_skipped_frame_count =
+			video_output_get_skipped_frames(output->video);
+	}
+
+	return success;
+}
+
+static void log_frame_info(struct obs_output *output)
+{
+	uint32_t video_frames  = video_output_get_total_frames(output->video);
+	uint32_t video_skipped = video_output_get_skipped_frames(output->video);
+
+	uint32_t total   = video_frames  - output->starting_frame_count;
+	uint32_t skipped = video_skipped - output->starting_skipped_frame_count;
+
+	double percentage_skipped = (double)skipped / (double)total * 100.0;
+
+	blog(LOG_INFO, "Output '%s': stopping", output->context.name);
+	blog(LOG_INFO, "Output '%s': Total frames: %"PRIu32,
+			output->context.name, total);
+
+	if (total)
+		blog(LOG_INFO, "Output '%s': Number of skipped frames: "
+				"%"PRIu32" (%g%%)",
+				output->context.name,
+				skipped, percentage_skipped);
 }
 
 void obs_output_stop(obs_output_t output)
@@ -166,6 +201,9 @@ void obs_output_stop(obs_output_t output)
 
 		output->info.stop(output->context.data);
 		signal_stop(output, OBS_OUTPUT_SUCCESS);
+
+		if (output->video)
+			log_frame_info(output);
 	}
 }
 

+ 0 - 16
libobs/obs.c

@@ -314,24 +314,8 @@ static void obs_free_video(void)
 	struct obs_core_video *video = &obs->video;
 
 	if (video->video) {
-		uint32_t total_frames =
-			video_output_get_total_frames(video->video);
-		uint32_t skipped_frames =
-			video_output_get_skipped_frames(video->video);
-		double percentage_skipped =
-			(double)skipped_frames / (double)total_frames * 100.0;
-
 		obs_display_free(&video->main_display);
 
-		blog(LOG_INFO, "Video session ending");
-		blog(LOG_INFO, "Total frames: %"PRIu32, total_frames);
-		if (total_frames) {
-			blog(LOG_INFO, "Number of skipped frames: "
-					"%"PRIu32" (%g%%)",
-					skipped_frames, percentage_skipped);
-		}
-		blog(LOG_INFO, "-------------------------------------------");
-
 		video_output_close(video->video);
 		video->video = NULL;