<div dir="ltr">Why are you concerned with the time for encding a single frame? It's probably just the API initializing various data structures on the chip. If you're encoding single frames just use jpeg.<div><br>
</div><div>We use libva for real-time encoding at 60fps at 1280x720, with about a 10ms delay on the libva part. It does a good job.</div><div><br></div><div>The simplest piece of sample code I've seen is the h264encode.c file included in the library. There's also the gstreamer-vaapi code, but it's much more spread out over many files:</div>
<div><br></div><div><a href="http://www.freedesktop.org/software/vaapi/releases/gstreamer-vaapi/">http://www.freedesktop.org/software/vaapi/releases/gstreamer-vaapi/</a><br></div><div><br></div>What are you planning to output your encoded video to? You may want to look into using gstreamer. Fair warning: moost of this stuff is not at the "plug and play" stage.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 27, 2014 at 11:43 AM, Nik Orlov <span dir="ltr"><<a href="mailto:nikitos1550@yandex.ru" target="_blank">nikitos1550@yandex.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello! Thanks for you answer!<br>
<br>
Do you mean 3840x1080 (yuv420p) size of frame? Real time for me, is all that takes less than 1/25s for encoding one frame (with sending data to gpu and sending it back).<br>
In my test I have started two 3840x1080 encodings at on time:<br>
<div class="">/h264encode -w 3840 -h 1080 -framecount 2500 -f 25<br>
/h264encode -w 3840 -h 1080 -framecount 2500 -f 25<br>
<br>
</div>Ubuntu 13.04 has desktop env, and graphics during encoding was slow, but cpu was less 10%.<br>
And I still have about 10ms for 1 frame for each encoding.<br>
<br>
But, as you see when I encodes 1 frame (or 60 frames, less than 1000 or more) time for 1 frame is very big. Why is it so?<br>
And I think it will be a problem with real time encoding :-(<br>
<br>
Another problem is that it is much diffulty to use encoding via libva (at the moment I have expirience only with liavcodec (ffmpeg lib).<br>
Could you advice me some tutorials or c/c++ program examples about h.264 libva encoding?<br>
<br>
<br>
27.03.2014, 20:11, "Matt Pekar" <<a href="mailto:mpekar@raineyelectronics.com">mpekar@raineyelectronics.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> For that size of frame, 20ms is a pretty darn good time IMO. We see 10ms (ish) on things in the 1280x720 range.<br>
><br>
> Since your input stream is only 25fps, the encoder will be able to provide near real-time output, with just a 20ms delay before writing each frame.<br>
><br>
> If you were trying to do 60fps then you wouldn't be able to do "real time" at all since you'd be falling behind 5ms every frame.<br>
><br>
> On Thu, Mar 27, 2014 at 5:57 AM, Nik Orlov <<a href="mailto:nikitos1550@yandex.ru">nikitos1550@yandex.ru</a>> wrote:<br>
>> Hello!<br>
>><br>
>> I have ubuntu-desktop 13.10 amd64 on core i7 4770 (Haswell, HD graphics 4600).<br>
>> I have installed vaapi (libva from sources 1.3.0).<br>
>><br>
>> There is h264encode test. I have started it:<br>
>><br>
>> user@video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./h264encode -w 3840 -h 1080 -framecount 1 -f 25<br>
>> Source frame is 3840x1080 and will code clip to 3840x1088 with crop<br>
>><br>
>> INPUT:Try to encode H264...<br>
>> INPUT: RateControl : VBR<br>
>> INPUT: Resolution : 3840x1080, 1 frames<br>
>> INPUT: FrameRate : 25<br>
>> INPUT: Bitrate : 24883200<br>
>> INPUT: Slieces : 1<br>
>> INPUT: IntraPeriod : 30<br>
>> INPUT: IDRPeriod : 60<br>
>> INPUT: IpPeriod : 1<br>
>> INPUT: Initial QP : 26<br>
>> INPUT: Min QP : 0<br>
>> INPUT: Source YUV : AUTO generated<br>
>> INPUT: Coded Clip : /tmp/test.264<br>
>> INPUT: Rec Clip : Not save reconstructed frame<br>
>><br>
>> libva info: VA-API version 0.35.0<br>
>> libva info: va_getDriverName() returns 0<br>
>> libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so<br>
>> libva info: Found init function __vaDriverInit_0_35<br>
>> libva info: va_openDriver() returns 0<br>
>> Use profile VAProfileH264High<br>
>> Support rate control mode (0x12):CBR CQP<br>
>> Support VAConfigAttribEncPackedHeaders<br>
>> Support packed sequence headers<br>
>> Support packed picture headers<br>
>> Support packed misc headers<br>
>> Support 1 RefPicList0 and 1 RefPicList1<br>
>> Loading data into surface 15.....Complete surface loading<br>
>> |00000000(485835 bytes coded)<br>
>><br>
>> PERFORMANCE: Frame Rate : 0.06 fps (1 frames, 16500 ms (16500.00 ms per frame))<br>
>> PERFORMANCE: Compression ratio : 12:1<br>
>> PERFORMANCE: UploadPicture : 16444 ms (16444.00, 99.66% percent)<br>
>> PERFORMANCE: vaBeginPicture : 0 ms (0.00, 0.00% percent)<br>
>> PERFORMANCE: vaRenderHeader : 0 ms (0.00, 0.00% percent)<br>
>> PERFORMANCE: vaEndPicture : 3 ms (3.00, 0.02% percent)<br>
>> PERFORMANCE: vaSyncSurface : 32 ms (32.00, 0.19% percent)<br>
>> PERFORMANCE: SavePicture : 0 ms (0.00, 0.00% percent)<br>
>> PERFORMANCE: Others : 21 ms (21.00, 0.13% percent)<br>
>> (Multithread enabled, the timing is only for reference)<br>
>><br>
>> And other way<br>
>><br>
>> user@video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./h264encode -w 3840 -h 1080 -framecount 2500 -f 25<br>
>> Source frame is 3840x1080 and will code clip to 3840x1088 with crop<br>
>><br>
>> INPUT:Try to encode H264...<br>
>> INPUT: RateControl : VBR<br>
>> INPUT: Resolution : 3840x1080, 2500 frames<br>
>> INPUT: FrameRate : 25<br>
>> INPUT: Bitrate : 24883200<br>
>> INPUT: Slieces : 1<br>
>> INPUT: IntraPeriod : 30<br>
>> INPUT: IDRPeriod : 60<br>
>> INPUT: IpPeriod : 1<br>
>> INPUT: Initial QP : 26<br>
>> INPUT: Min QP : 0<br>
>> INPUT: Source YUV : AUTO generated<br>
>> INPUT: Coded Clip : /tmp/test.264<br>
>> INPUT: Rec Clip : Not save reconstructed frame<br>
>><br>
>> libva info: VA-API version 0.35.0<br>
>> libva info: va_getDriverName() returns 0<br>
>> libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so<br>
>> libva info: Found init function __vaDriverInit_0_35<br>
>> libva info: va_openDriver() returns 0<br>
>> Use profile VAProfileH264High<br>
>> Support rate control mode (0x12):CBR CQP<br>
>> Support VAConfigAttribEncPackedHeaders<br>
>> Support packed sequence headers<br>
>> Support packed picture headers<br>
>> Support packed misc headers<br>
>> Support 1 RefPicList0 and 1 RefPicList1<br>
>> Loading data into surface 15.....Complete surface loading<br>
>> \00002499(719089 bytes coded)<br>
>><br>
>> PERFORMANCE: Frame Rate : 53.70 fps (2500 frames, 46555 ms (18.62 ms per frame))<br>
>> PERFORMANCE: Compression ratio : 11:1<br>
>> PERFORMANCE: UploadPicture : 16364 ms (6.55, 35.15% percent)<br>
>> PERFORMANCE: vaBeginPicture : 2 ms (0.00, 0.00% percent)<br>
>> PERFORMANCE: vaRenderHeader : 18 ms (0.01, 0.04% percent)<br>
>> PERFORMANCE: vaEndPicture : 1098 ms (0.44, 2.36% percent)<br>
>> PERFORMANCE: vaSyncSurface : 21385 ms (8.55, 45.93% percent)<br>
>> PERFORMANCE: SavePicture : 8759 ms (3.50, 18.81% percent)<br>
>> PERFORMANCE: Others : -1071 ms (1717986.49, 9225574.54% percent)<br>
>> (Multithread enabled, the timing is only for reference)<br>
>><br>
>> So, when test encodes more frames time for encoding 1 frame is about 20ms.<br>
>> Why it is so?<br>
>><br>
>> My primary question, if I want to encode video in real time (It means camera sends me frame each 40ms), what time for encoding 1 frame I will get?<br>
>> As I understand programm sends some data to GPU, GPU encodes video and then send me encoded data back.<br>
>> How much time takes sending data to GPU and back?<br>
>><br>
>> Maybe it will possible to encode each frame in real time, or maybe it isn`t possible, but It is possible to keep some buffer (for example for 25 frames - 1 sec of video) and than encode ot very fast.<br>
>><br>
>> --<br>
>> ๎ษห ๏าฬฯื mailto:<a href="mailto:nikitos1550@yandex.ru">nikitos1550@yandex.ru</a><br>
>> _______________________________________________<br>
>> Libva mailing list<br>
>> <a href="mailto:Libva@lists.freedesktop.org">Libva@lists.freedesktop.org</a><br>
>> <a href="http://lists.freedesktop.org/mailman/listinfo/libva" target="_blank">http://lists.freedesktop.org/mailman/listinfo/libva</a><br>
<br>
--<br>
๎ษห ๏าฬฯื mailto:<a href="mailto:nikitos1550@yandex.ru">nikitos1550@yandex.ru</a><br>
</div></div></blockquote></div><br></div>