View Full Version : How to use x264 coding 1280*1080 resolution color videos in real time?
l35633
29th April 2015, 10:28
Dear Friends:
Now I am encoding 1280*1080 resolution color videos with x264 library, the average encoding time of each frame is about 50-60ms, but the time is too slow for me. I want to shorten the encoding time by adjusting x264 parameters, and I don't care too much about compression ratio if encoding speed is fast.
I NEED YOUR WARM HELP AND ADVICE.
THANK YOU VERY MUCH!
raffriff42
29th April 2015, 13:39
x264 --crf 22 --preset ultrafast -o <output-path> <input-path>
If that is not fast enough, seek help from Intel or AMD :)
EDIT add --tune zerolatency if you are streaming live video.
l35633
29th April 2015, 16:26
Thank you so much! I just did it as your parameters. Still 50-60ms per frame, any other methods?
Groucho2004
29th April 2015, 16:53
Still 50-60ms per frame, any other methods?
That seems very slow considering the encoder parameters and the resolution.
What CPU does this run on? Can you describe your workflow in more detail? Do you use Avisynth to feed the frames?
l35633
2nd May 2015, 22:00
Thank you very much! I really find that RGB2YUV function consumes much times, because I have to transfer the RGB color image to yuv format,
it is the real reason why the encoding is so slow. Do you have any idea to accelerate RGB2YUV functions for x264 ?
By the way , what does that mean of " Do you use Avisynth to feed the frames?"
Thank you very much!
Groucho2004
2nd May 2015, 22:05
Thank you very much! I really find that RGB2YUV function consumes much times, because I have to transfer the RGB color image to yuv format,
it is the real reason why the encoding is so slow. Do you have any idea to accelerate RGB2YUV functions for x264 ?
By the way , what does that mean of " Do you use Avisynth to feed the frames?"
Thank you very much!
Please elaborate on your workflow. What format are your source videos?
LoRd_MuldeR
2nd May 2015, 22:06
Thank you very much! I really find that RGB2YUV function consumes much times, because I have to transfer the RGB color image to yuv format,
it is the real reason why the encoding is so slow. Do you have any idea to accelerate RGB2YUV functions for x264 ?
Please clarify: Do you do the RGB to YUV conversion in your own code or do you let the x264 encoder do the colorspace conversion for you?
In the former case, I suggest you replace your own code with a highly optimized library (instead of reinventing the wheel), unless your own code is very optimized already, of course. I think x264 uses libswscale (https://www.ffmpeg.org/libswscale.html) for this purpose.
Alternatives you could look into include the colorspace conversion routines of Avisynth (http://sourceforge.net/projects/avisynth2/), or maybe the fmtconv (http://forum.doom9.org/showthread.php?t=166504) plug-in for VapourSynth.
By the way , what does that mean of " Do you use Avisynth to feed the frames?"
Well, do you call the x264 library directly (from your own code) or do you use the x264 command-line encoder? In the latter case, do you feed x264 with an Avisynth script or with something else?
l35633
3rd May 2015, 10:14
Please elaborate on your workflow. What format are your source videos?
OK. Thank you!
1280*1080 resolution RGB format images are real-time captured from Kinect V2, I use x264-142 library to encode.
That is what I am doing now.
Thank you very much!
l35633
3rd May 2015, 10:23
Please clarify: Do you do the RGB to YUV conversion in your own code or do you let the x264 encoder do the colorspace conversion for you?
In the former case, I suggest you replace your own code with a highly optimized library (instead of reinventing the wheel), unless your own code is very optimized already, of course. I think x264 uses libswscale (https://www.ffmpeg.org/libswscale.html) for this purpose.
Alternatives you could look into include the colorspace conversion routines of Avisynth (http://sourceforge.net/projects/avisynth2/), or maybe the fmtconv (http://forum.doom9.org/showthread.php?t=166504) plug-in for VapourSynth.
Well, do you call the x264 library directly (from your own code) or do you use the x264 command-line encoder? In the latter case, do you feed x264 with an Avisynth script or with something else?
1. Now I do the RGB to YUV conversion in your own code
2. You mean that I use libswscale to RGB2YUV color space conversion or directly let x264 to encode RGB directly, which will use libswscale for a conversion inside?
3. OK, I will see your montioned avisynth2 and fmtconv methods
4. I use x264 library directly to encode, any good ideas for me still?
Thank you very much!:thanks:
LoRd_MuldeR
3rd May 2015, 12:29
You mean that I use libswscale to RGB2YUV color space conversion or directly let x264 to encode RGB directly, which will use libswscale for a conversion inside?
If you used the x264 command-line encoder (x264.exe) you could feed it with any supported color format and it would do the required colorspace conversion internally - using libswscale.
This happens inside the command-line front-end, not inside the "core" library.
x264_8bit_x86.exe --crf 16 -o test.mp4 foreman_cif.rgb.avi
lavf [info]: 352x288p 0:1 @ 25/1 fps (vfr)
resize [warning]: converting from bgr24 to yuv420p
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
x264 [info]: profile High, level 1.3
But, as you are calling the x264 library (libx264.dll) directly, I think you will have to provide YUV data. And that means that you will need to take care of the RGB to YUV conversion yourself.
Still, it doesn't mean that you have to implement it all by yourself. You could try using something like libswscale or "borrowing" code from Avisynth or fmtconv...
l35633
3rd May 2015, 20:26
If you used the x264 command-line encoder (x264.exe) you could feed it with any supported color format and it would do the required colorspace conversion internally - using libswscale.
This happens inside the command-line front-end, not inside the "core" library.
x264_8bit_x86.exe --crf 16 -o test.mp4 foreman_cif.rgb.avi
lavf [info]: 352x288p 0:1 @ 25/1 fps (vfr)
resize [warning]: converting from bgr24 to yuv420p
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
x264 [info]: profile High, level 1.3
But, as you are calling the x264 library (libx264.dll) directly, I think you will have to provide YUV data. And that means that you will need to take care of the RGB to YUV conversion yourself.
Still, it doesn't mean that you have to implement it all by yourself. You could try using something like libswscale or "borrowing" code from Avisynth or fmtconv...
Thank you very much! I will try and test the results.
:thanks:
raffriff42
4th May 2015, 03:48
Try to determine the bottleneck. Open Task Manager - is the CPU fully utilized? Is memory usage hitting maximum? What kind of disk transfer rates are you seeing?
l35633
4th May 2015, 14:55
Try to determine the bottleneck. Open Task Manager - is the CPU fully utilized? Is memory usage hitting maximum? What kind of disk transfer rates are you seeing?
Thank you, friend!:thanks:
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.