Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th April 2015, 10:28   #1  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
How to use x264 coding 1280*1080 resolution color videos in real time?

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!
l35633 is offline   Reply With Quote
Old 29th April 2015, 13:39   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
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.

Last edited by raffriff42; 29th April 2015 at 13:49.
raffriff42 is offline   Reply With Quote
Old 29th April 2015, 16:26   #3  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Thank you so much! I just did it as your parameters. Still 50-60ms per frame, any other methods?
l35633 is offline   Reply With Quote
Old 29th April 2015, 16:53   #4  |  Link
Groucho2004
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Posts: 3,850
Quote:
Originally Posted by l35633 View Post
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?
Groucho2004 is offline   Reply With Quote
Old 2nd May 2015, 22:00   #5  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
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!
l35633 is offline   Reply With Quote
Old 2nd May 2015, 22:05   #6  |  Link
Groucho2004
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Posts: 3,850
Quote:
Originally Posted by l35633 View Post
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?
Groucho2004 is offline   Reply With Quote
Old 2nd May 2015, 22:06   #7  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 12,908
Quote:
Originally Posted by l35633 View Post
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 for this purpose.

Alternatives you could look into include the colorspace conversion routines of Avisynth, or maybe the fmtconv plug-in for VapourSynth.

Quote:
Originally Posted by l35633 View Post
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?
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 2nd May 2015 at 22:43.
LoRd_MuldeR is offline   Reply With Quote
Old 3rd May 2015, 10:14   #8  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by Groucho2004 View Post
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 is offline   Reply With Quote
Old 3rd May 2015, 10:23   #9  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by LoRd_MuldeR View Post
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 for this purpose.

Alternatives you could look into include the colorspace conversion routines of Avisynth, or maybe the fmtconv 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!
l35633 is offline   Reply With Quote
Old 3rd May 2015, 12:29   #10  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 12,908
Quote:
Originally Posted by l35633 View Post
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.

Code:
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...
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 3rd May 2015 at 14:43.
LoRd_MuldeR is offline   Reply With Quote
Old 3rd May 2015, 20:26   #11  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by LoRd_MuldeR View Post
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.

Code:
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.
l35633 is offline   Reply With Quote
Old 4th May 2015, 03:48   #12  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
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?
raffriff42 is offline   Reply With Quote
Old 4th May 2015, 14:55   #13  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by raffriff42 View Post
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!
l35633 is offline   Reply With Quote
Reply

Tags
high resolution, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.