Fix black video when resizing to smaller window size
This commit is contained in:
parent
c622d2d799
commit
c94ce44dbe
@ -38,5 +38,4 @@ FFMPEG only uses the GPU with CUDA when doing transcoding from an input video to
|
|||||||
libraries at compile-time.
|
libraries at compile-time.
|
||||||
* Clean up the code!
|
* Clean up the code!
|
||||||
* Fix segfault in debug mode (happens because audio codec becomes NULL?)
|
* Fix segfault in debug mode (happens because audio codec becomes NULL?)
|
||||||
* Fix blackscreen at start that appears until the second keyframe, which can be several seconds on a non-moving screen. Why does this happen? ffmpeg says the first frame should always be a keyframe!
|
|
||||||
* Dynamically change bitrate to match desired fps. This would be helpful when streaming for example, where the encode output speed also depends on upload speed to the stream service.
|
* Dynamically change bitrate to match desired fps. This would be helpful when streaming for example, where the encode output speed also depends on upload speed to the stream service.
|
||||||
|
18
src/main.cpp
18
src/main.cpp
@ -897,6 +897,9 @@ int main(int argc, char **argv) {
|
|||||||
int window_width = xwa.width;
|
int window_width = xwa.width;
|
||||||
int window_height = xwa.height;
|
int window_height = xwa.height;
|
||||||
|
|
||||||
|
int original_window_width = window_width;
|
||||||
|
int original_window_height = window_height;
|
||||||
|
|
||||||
std::mutex write_output_mutex;
|
std::mutex write_output_mutex;
|
||||||
std::thread audio_thread;
|
std::thread audio_thread;
|
||||||
|
|
||||||
@ -1026,6 +1029,7 @@ int main(int argc, char **argv) {
|
|||||||
"Error: cuGraphicsGLRegisterImage failed, error %s, texture "
|
"Error: cuGraphicsGLRegisterImage failed, error %s, texture "
|
||||||
"id: %u\n",
|
"id: %u\n",
|
||||||
err_str, window_pixmap.target_texture_id);
|
err_str, window_pixmap.target_texture_id);
|
||||||
|
running = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,8 +1041,21 @@ int main(int argc, char **argv) {
|
|||||||
av_frame_unref(frame);
|
av_frame_unref(frame);
|
||||||
if (av_hwframe_get_buffer(video_stream->codec->hw_frames_ctx, frame, 0) < 0) {
|
if (av_hwframe_get_buffer(video_stream->codec->hw_frames_ctx, frame, 0) < 0) {
|
||||||
fprintf(stderr, "Error: av_hwframe_get_buffer failed\n");
|
fprintf(stderr, "Error: av_hwframe_get_buffer failed\n");
|
||||||
|
running = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame->pts = frame_count;
|
||||||
|
|
||||||
|
if(window_width < original_window_width)
|
||||||
|
frame->width = window_pixmap.texture_width & ~1;
|
||||||
|
else
|
||||||
|
frame->width = original_window_width;
|
||||||
|
|
||||||
|
if(window_height < original_window_height)
|
||||||
|
frame->height = window_pixmap.texture_height & ~1;
|
||||||
|
else
|
||||||
|
frame->height = original_window_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
++fps_counter;
|
++fps_counter;
|
||||||
@ -1085,7 +1102,6 @@ int main(int argc, char **argv) {
|
|||||||
cuMemcpy2D(&memcpy_struct);
|
cuMemcpy2D(&memcpy_struct);
|
||||||
// res = cuCtxPopCurrent(&old_ctx);
|
// res = cuCtxPopCurrent(&old_ctx);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->pts = frame_count;
|
frame->pts = frame_count;
|
||||||
|
Loading…
Reference in New Issue
Block a user