The goal is to create a video stream from bitmap frames.
Current solution: I am streaming raw 24bpp bitmap data over tcp from my machine to a "remote" server, to distribute the frames to the clients. This works well when everything runs on my local machine.
Problem: The size of a frame is 1440000 (800*600*3) bytes, I only have a 2Mbps upstream and I need the video to be 25 frames per second with a resolution of 800x600.
Approach: So after a bit of research my approach would be to encode the bitmap frames into h264 and stream the resulting video.
Current situation: I compiled x264 and ffmpeg (for swscale, to convert RGB to YUV) and I am able to encode 24bpp bitmap Frames with x264. The last action in my test program is a call to x264_encoder_encode
. The bitmap data in the test program is randomly generated for every frame.
Now to my question(s):
Where do I go from here? TCP, UDP, RTMP? Which data would be transfered? Do i just transmit the resulting frame from x264_encoder_encode
?
Which still has a size of ~140000 bytes, according to the return value of the function. That would result in
(25*140000 = 3500000) 3,5 Mbps which is still greater than the 2Mpbs I have available.
While I dont really know how (yet!), I am confidend that this task is feasable. For example, here is a spreadsheet displaying needed bandwith for different resolutions for streaming platforms like twitch.tv (using RTMP).
My current x264_param
(from this post) looks like this (just fyi):
x264_param_default_preset(¶m, "veryfast", "zerolatency");
param.i_threads = 1;
param.i_width = width;
param.i_height = height;
param.i_fps_num = fps;
param.i_fps_den = 1;
// Intra refres:
param.i_keyint_max = fps;
param.b_intra_refresh = 1;
//Rate control:
param.rc.i_rc_method = X264_RC_CRF;
param.rc.f_rf_constant = 25;
param.rc.f_rf_constant_max = 35;
//For streaming:
param.b_repeat_headers = 1;
param.b_annexb = 1;
x264_param_apply_profile(¶m, "baseline");
thank you in advance.