NVIDIA
I run the GLIFR_SimpleH264 sample,the h264 stream looks bad.Who knows the reasons?Thanks!
This is a video capture,triangle edge looks fuzzy.After the H264 encoding, the picture is very serious losses.
This is a video capture,triangle edge looks fuzzy.After the H264 encoding, the picture is very serious losses.
Attachments

stream.png

#1
Posted 08/15/2015 08:36 AM   
This is my code: static void display() { char textBuffer[32]; float elapsedTime; uintptr_t dataSize; const void *data; if (startTime == 0) startTime = getTimeInuS(); // Draw a colored cube to the FBO glBindFramebuffer(GL_FRAMEBUFFER, fboID); glViewport(0, 0, fboWidth, fboHeight); glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); glColor3f(0, 0, 1); glBegin(GL_LINE_LOOP); glVertex2f(1, 0); glVertex2f(1, 1); glVertex2f(0, 1); glVertex2f(0, 0); glEnd(); glBegin(GL_TRIANGLES); glVertex2f(0.3f, 0); glVertex2f(0.7f, 0); glVertex2f(0.5f, 0.4f); glEnd(); glBindFramebuffer(GL_FRAMEBUFFER, 0); // transfer the FBO if (nvIFR.nvIFROGLTransferFramebufferToH264Enc(transferObjectHandle, NULL, fboID, GL_COLOR_ATTACHMENT0, GL_NONE) != NV_IFROGL_SUCCESS) { fprintf(stderr, "Failed to transfer data from the framebuffer.\n"); exit(-1); } // lock the transferred data if (nvIFR.nvIFROGLLockTransferData(transferObjectHandle, &dataSize, &data) != NV_IFROGL_SUCCESS) { fprintf(stderr, "Failed to lock the transferred data.\n"); exit(-1); } // write to the file if (isOutFile) fwrite(data, 1, dataSize, outFile); // release the data buffer if (nvIFR.nvIFROGLReleaseTransferData(transferObjectHandle) != NV_IFROGL_SUCCESS) { fprintf(stderr, "Failed to release the transferred data.\n"); exit(-1); } frameCounter++; elapsedTime = (float)(getTimeInuS() - startTime) / 1000000; // print the frame rate every second if (elapsedTime - lastUpdateTime > 1.f) { float frameRate; frameRate = (float)(frameCounter - lastUpdateFrame) / (elapsedTime - lastUpdateTime); lastUpdateFrame = frameCounter; lastUpdateTime = elapsedTime; // draw the frame rate to the window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, winWidth, winHeight); snprintf(textBuffer, sizeof(textBuffer), "Encoding %dx%d at %4.0f fps\n", fboWidth, fboHeight, frameRate); printText(0, winHeight - 12, textBuffer); glutSwapBuffers(); } time(&end); if ((duration > 0) && ((end - start) > duration)) { if (isOutFile) fclose(outFile); deinit(); exit(0); } else if ((numFrames > 0) && (frameCounter >= (unsigned int)numFrames)) { if (isOutFile) fclose(outFile); deinit(); exit(0); } }
This is my code:

static void display()
{
char textBuffer[32];
float elapsedTime;
uintptr_t dataSize;
const void *data;

if (startTime == 0)
startTime = getTimeInuS();

// Draw a colored cube to the FBO
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
glViewport(0, 0, fboWidth, fboHeight);

glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
glColor3f(0, 0, 1);

glBegin(GL_LINE_LOOP);
glVertex2f(1, 0);
glVertex2f(1, 1);
glVertex2f(0, 1);
glVertex2f(0, 0);
glEnd();

glBegin(GL_TRIANGLES);
glVertex2f(0.3f, 0);
glVertex2f(0.7f, 0);
glVertex2f(0.5f, 0.4f);
glEnd();

glBindFramebuffer(GL_FRAMEBUFFER, 0);

// transfer the FBO
if (nvIFR.nvIFROGLTransferFramebufferToH264Enc(transferObjectHandle, NULL,
fboID, GL_COLOR_ATTACHMENT0, GL_NONE) != NV_IFROGL_SUCCESS)
{
fprintf(stderr, "Failed to transfer data from the framebuffer.\n");
exit(-1);
}

// lock the transferred data
if (nvIFR.nvIFROGLLockTransferData(transferObjectHandle, &dataSize, &data) != NV_IFROGL_SUCCESS)
{
fprintf(stderr, "Failed to lock the transferred data.\n");
exit(-1);
}

// write to the file
if (isOutFile)
fwrite(data, 1, dataSize, outFile);

// release the data buffer
if (nvIFR.nvIFROGLReleaseTransferData(transferObjectHandle) != NV_IFROGL_SUCCESS)
{
fprintf(stderr, "Failed to release the transferred data.\n");
exit(-1);
}

frameCounter++;
elapsedTime = (float)(getTimeInuS() - startTime) / 1000000;

// print the frame rate every second
if (elapsedTime - lastUpdateTime > 1.f)
{
float frameRate;

frameRate = (float)(frameCounter - lastUpdateFrame) / (elapsedTime - lastUpdateTime);
lastUpdateFrame = frameCounter;
lastUpdateTime = elapsedTime;

// draw the frame rate to the window
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, winWidth, winHeight);

snprintf(textBuffer, sizeof(textBuffer), "Encoding %dx%d at %4.0f fps\n", fboWidth, fboHeight, frameRate);
printText(0, winHeight - 12, textBuffer);

glutSwapBuffers();
}
time(&end);
if ((duration > 0) && ((end - start) > duration))
{
if (isOutFile)
fclose(outFile);
deinit();
exit(0);
}
else if ((numFrames > 0) && (frameCounter >= (unsigned int)numFrames))
{
if (isOutFile)
fclose(outFile);
deinit();
exit(0);
}
}

#2
Posted 08/15/2015 08:50 AM   
Scroll To Top

Add Reply