Black image when I change the FPS the gain and exposure time

Dear Aravis community Hello,
I am using a USB 3.1 camera for 127 acquisitions, the maximum rate for the camera.
I am using the qarv tool to set up the parameters to be sure that the image I got are not saturated.
So in the qarv tool, I could set the 127 FPS with the gain and exposure time in ms in order to get a clear image.
I do the same thing using the library in C language but, I get a nearly black image.
to explain a little bit about how I do this, the acquisition camera is done and after that, I store the buffer in binary to a file. I use a python script to convert the binary to png files. My camera is 1920x1200 px.

Here is my code:

/* SPDX-License-Identifier:Unlicense */

/* Aravis header */

#include <arv.h>

/* Standard headers */

#include <stdlib.h>
#include <stdio.h>

	#define MAX_IMAGES 160
	#define EXPOSURE_TIME 1000
	#define CAMERA_GAIN 16
	#define MAX_IMAGES 127
	#define EXPOSURE_TIME 2000
	#define CAMERA_GAIN 10

typedef struct
	GMainLoop *main_loop;
	guint32 counter;
} AppData;

void new_buffer_cb(ArvStream *USB_stream, void *user_data)
	ArvBuffer *USB_buffer;
	AppData *app_data = user_data;
	FILE *USB_BinaryOutFile;
	const char *USB_filePath = "Images/USB_160BinaryImage8bit.bin";
	const char *USB_filePath = "Images/USB_160BinaryImage12bit.bin";

	const void *DataFromBuffer;
	size_t BufferSize = 0;

	if (app_data->counter > MAX_IMAGES-1)
		/* This code is called from the USB_stream receiving thread, which means all the time spent there is less time
		 * available for the reception of incoming packets */

		USB_BinaryOutFile = fopen(USB_filePath, "ab");

		USB_buffer = arv_stream_pop_buffer(USB_stream);

		/* Get the data and size from the Aravis USB_buffer */
		DataFromBuffer = arv_buffer_get_data(USB_buffer,

		/* Write to the  binary file */
		fwrite(DataFromBuffer, BufferSize, 1, USB_BinaryOutFile);

		/* Display some informations about the retrieved USB_buffer */
	//	printf("Acquired %d × %d USB_buffer number %d \n",
	//										arv_buffer_get_image_width(USB_buffer),
	//										arv_buffer_get_image_height(USB_buffer),  app_data->counter);

		/* Don't destroy the USB_buffer, but put it back into the USB_buffer pool */
		arv_stream_push_buffer(USB_stream, USB_buffer);

		printf("The number or call back function is %d\n",app_data->counter);

		/* Close the binary file */


 * Connect to the first available USB_camera, then acquire 10 buffers.

int main(int argc, char **argv)
	ArvCamera *USB_camera;
	AppData app_data;
	GError *USB_error = NULL;

	app_data.main_loop = g_main_loop_new(NULL, FALSE);
	app_data.counter = 0;
	double min, max = 0;

	/* Connect to the first available USB_camera */
	USB_camera = arv_camera_new("IDS Imaging Development Systems GmbH-4104427946", &USB_error);

	if (ARV_IS_CAMERA(USB_camera))
		ArvStream *USB_stream;

		printf("Found USB_camera '%s'\n",
				arv_camera_get_model_name(USB_camera, NULL));

		arv_camera_get_frame_rate_bounds(USB_camera, &max, &min , &USB_error);
		printf("the maximum bound is %f and the minimum bound is %f\n", min, max);

		arv_camera_set_string (USB_camera, "PixelFormat", "Mono8", NULL);
		arv_camera_set_string (USB_camera, "PixelFormat", "Mono12", NULL);
		printf("The name of the camera is :%s\n",arv_camera_get_model_name(USB_camera, &USB_error));

		/* Set gain */
		arv_camera_set_gain(USB_camera, CAMERA_GAIN, NULL);
		printf("The camera gain is %f\n",arv_camera_get_gain(USB_camera, NULL));

		/*Set time exposure */
		arv_camera_set_exposure_time(USB_camera, EXPOSURE_TIME, NULL);
		printf("The camera time exposure is %f\n", arv_camera_get_exposure_time(USB_camera, NULL));

		/* Set frame rate to MAX_IMAGES Hz */
		arv_camera_set_frame_rate(USB_camera, MAX_IMAGES, NULL);
		printf("The camera rate is : %f\n",arv_camera_get_frame_rate(USB_camera, &USB_error));

		/* Create the USB_stream object without callback */
		USB_stream = arv_camera_create_stream(USB_camera, NULL, NULL, &USB_error);

		if (ARV_IS_STREAM(USB_stream))
			int i;
			size_t USB_payload;

			/* Retrieve the USB_payload size for USB_buffer creation */
			USB_payload = arv_camera_get_payload(USB_camera, &USB_error);

			if (USB_error == NULL)
				/* Insert some buffers in the USB_stream USB_buffer pool */
				for (i = 0; i < MAX_IMAGES; i++)
					/*Pushes a ArvBuffer to the USB_stream thread. The USB_stream takes ownership of USB_buffer ,
					 and will free all the buffers still in its queues when destroyed.*/
							arv_buffer_new(USB_payload, NULL));

			/*Connects a GCallback function to a signal for a particular object*/
			g_signal_connect(USB_stream, "new-buffer", G_CALLBACK (new_buffer_cb),

			arv_stream_set_emit_signals(USB_stream, TRUE);

			if (USB_error == NULL)
				/* Start the acquisition */
				arv_camera_start_acquisition(USB_camera, &USB_error);

			if (USB_error == NULL)
				/*The GMainLoop struct is an opaque data type representing the main event loop of a GLib or GTK+ application*/
			printf("out of gmain");
			if (USB_error == NULL)
				/* Stop the acquisition */
				arv_camera_stop_acquisition(USB_camera, &USB_error);

			arv_stream_set_emit_signals(USB_stream, FALSE);

			/* Destroy the USB_stream object */

		/* Destroy the USB_camera instance */


	if (USB_error != NULL)
		/* En USB_error happened, display the corresponding message */
		printf("USB_error: %s\n", USB_error->message);
		return EXIT_FAILURE;


I have this issue only when I set the rating image to 127 FPS with the 12 bits camera configuration. The 8-bit worked well and when I extract the binary data using a script to save the result to a 160 png file the expected images are good like I have seen in the qarv tool.
Thank you in advance,