[Libva] linux vaapi h.264 encoding haswell hd graphics 4600
Nik Orlov
nikitos1550 at yandex.ru
Fri Mar 28 02:51:45 PDT 2014
Here I have downloaded yuv420 1920x1080 raw video
http://trace.eas.asu.edu/yuv/
Big Buck Bunny - 14315 Frames - 24 fps
And do some tests
user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./avcenc 1920 1080 /media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv ./test.avcenc
libva info: VA-API version 0.35.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver() returns 0
14316/14315 ...
done!
encode 14315 frames in 115.916801 secondes, FPS is 123.5
user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./avcenc 1920 1080 /media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv ./test2.avcenc fb=1000000 mode=0
libva info: VA-API version 0.35.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver() returns 0
52/14315 ...Unrepairable overflow!
14316/14315 ...
done!
encode 14315 frames in 345.111206 secondes, FPS is 41.5
user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./avcenc 1920 1080 /media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv ./test2.avcenc fb=1000000 mode=1
libva info: VA-API version 0.35.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver() returns 0
39/14315 ...Unrepairable overflow!
14316/14315 ...
done!
encode 14315 frames in 271.048706 secondes, FPS is 52.8
user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./avcenc 1920 1080 /media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv ./test2.avcenc fb=1000000 mode=2
libva info: VA-API version 0.35.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver() returns 0
20/14315 ...Unrepairable overflow!
14318/14315 ...
done!
encode 14315 frames in 272.932495 secondes, FPS is 52.4
Than I encoded it via h264encoder
user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ h264encode -w 1920 -h 1080 --srcyuv /media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv -framecount 14315 -f 24 -o ./test.h264
Source YUV file /media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv with 14315 frames
Source frame is 1920x1080 and will code clip to 1920x1088 with crop
INPUT:Try to encode H264...
INPUT: RateControl : VBR
INPUT: Resolution : 1920x1080, 14315 frames
INPUT: FrameRate : 24
INPUT: Bitrate : 11943936
INPUT: Slieces : 1
INPUT: IntraPeriod : 30
INPUT: IDRPeriod : 60
INPUT: IpPeriod : 1
INPUT: Initial QP : 26
INPUT: Min QP : 0
INPUT: Source YUV : FILE:/media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv (fourcc NV12)
INPUT: Coded Clip : ./test.h264
INPUT: Rec Clip : Not save reconstructed frame
libva info: VA-API version 0.35.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver() returns 0
Use profile VAProfileH264High
Support rate control mode (0x12):CBR CQP
Support VAConfigAttribEncPackedHeaders
Support packed sequence headers
Support packed picture headers
Support packed misc headers
Support 1 RefPicList0 and 1 RefPicList1
-00014314(147603 bytes coded)
PERFORMANCE: Frame Rate : 62.07 fps (14315 frames, 230630 ms (16.11 ms per frame))
PERFORMANCE: Compression ratio : 59:1
PERFORMANCE: UploadPicture : 224767 ms (15.70, 97.46% percent)
PERFORMANCE: vaBeginPicture : 21 ms (0.00, 0.01% percent)
PERFORMANCE: vaRenderHeader : 67 ms (0.00, 0.03% percent)
PERFORMANCE: vaEndPicture : 2263 ms (0.16, 0.98% percent)
PERFORMANCE: vaSyncSurface : 4141 ms (0.29, 1.80% percent)
PERFORMANCE: SavePicture : 1692 ms (0.12, 0.73% percent)
PERFORMANCE: Others : -2321 ms (300032.48, 1862275.06% percent)
(Multithread enabled, the timing is only for reference)
Try to see it with VLC. Some bugs, but not that I have getted with auto generated yuv, maybe I did something wrong?
See bug screenshot http://yadi.sk/d/EDTI2RVgLMomM
user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ffmpeg -f rawvideo -vcodec rawvideo -s 1920x1080 -r 24 -pix_fmt yuv420p -i /media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv ./test.mp4
ffmpeg version N-61874-g57e939d Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 27 2014 11:38:32 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --enable-libx264 --enable-gpl
libavutil 52. 69.100 / 52. 69.100
libavcodec 55. 55.100 / 55. 55.100
libavformat 55. 35.101 / 55. 35.101
libavdevice 55. 11.100 / 55. 11.100
libavfilter 4. 3.100 / 4. 3.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
[rawvideo @ 0x37afa80] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from '/media/user/d482a1e4-9a55-47ca-b307-72316011289a/home/user/BigBuckBunny_1920_1080_24fps.yuv':
Duration: 00:09:56.46, start: 0.000000, bitrate: 597196 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 597196 kb/s, 24 tbr, 24 tbn, 24 tbc
[libx264 @ 0x37b9ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x37b9ec0] profile High, level 4.0
[libx264 @ 0x37b9ec0] 264 - core 142 r2409 d6b4e63 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to './test.mp4':
Metadata:
encoder : Lavf55.35.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080, q=-1--1, 12288 tbn, 24 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
frame=14315 fps= 47 q=-1.0 Lsize= 218487kB time=00:09:56.37 bitrate=3001.2kbits/s
video:218324kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.074732%
[libx264 @ 0x37b9ec0] frame I:153 Avg QP:18.20 size:201621
[libx264 @ 0x37b9ec0] frame P:5301 Avg QP:22.13 size: 27779
[libx264 @ 0x37b9ec0] frame B:8861 Avg QP:25.43 size: 5130
[libx264 @ 0x37b9ec0] consecutive B-frames: 10.6% 15.6% 15.1% 58.7%
[libx264 @ 0x37b9ec0] mb I I16..4: 19.1% 63.3% 17.7%
[libx264 @ 0x37b9ec0] mb P I16..4: 1.9% 6.7% 0.7% P16..4: 27.6% 7.8% 5.3% 0.0% 0.0% skip:50.0%
[libx264 @ 0x37b9ec0] mb B I16..4: 0.2% 0.6% 0.1% B16..8: 22.6% 1.5% 0.3% direct: 0.8% skip:73.9% L0:40.7% L1:55.2% BI: 4.1%
[libx264 @ 0x37b9ec0] 8x8 transform intra:70.2% inter:74.1%
[libx264 @ 0x37b9ec0] coded y,uvDC,uvAC intra: 54.0% 59.5% 27.5% inter: 8.2% 8.6% 1.2%
[libx264 @ 0x37b9ec0] i16 v,h,dc,p: 25% 19% 4% 52%
[libx264 @ 0x37b9ec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 13% 20% 5% 8% 12% 7% 7% 6%
[libx264 @ 0x37b9ec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 14% 12% 6% 11% 12% 8% 7% 6%
[libx264 @ 0x37b9ec0] i8c dc,h,v,p: 53% 19% 17% 11%
[libx264 @ 0x37b9ec0] Weighted P-Frames: Y:4.9% UV:3.5%
[libx264 @ 0x37b9ec0] ref P L0: 60.9% 17.8% 14.8% 6.3% 0.1%
[libx264 @ 0x37b9ec0] ref B L0: 84.8% 13.4% 1.8%
[libx264 @ 0x37b9ec0] ref B L1: 94.7% 5.3%
[libx264 @ 0x37b9ec0] kb/s:2998.54
Try to see it via VLC - everything is good
See good screenshot http://yadi.sk/d/1lSpqiFVLMoof
28.03.2014, 11:26, "Xiang, Haihao" <haihao.xiang at intel.com>:
> Can you reproduce this issue with --srcyuv and --fourcc ?
>
> Thanks
> Haihao
>
>> user at video-ubuntu:~/Downloads$ vainfo
>> libva info: VA-API version 0.35.0
>> libva info: va_getDriverName() returns 0
>> libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
>> libva info: Found init function __vaDriverInit_0_35
>> libva info: va_openDriver() returns 0
>> vainfo: VA-API version: 0.35 (libva 1.3.0)
>> vainfo: Driver version: Intel i965 driver - 1.3.0
>> vainfo: Supported profile and entrypoints
>> VAProfileMPEG2Simple : VAEntrypointVLD
>> VAProfileMPEG2Simple : VAEntrypointEncSlice
>> VAProfileMPEG2Main : VAEntrypointVLD
>> VAProfileMPEG2Main : VAEntrypointEncSlice
>> VAProfileH264ConstrainedBaseline: VAEntrypointVLD
>> VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
>> VAProfileH264Main : VAEntrypointVLD
>> VAProfileH264Main : VAEntrypointEncSlice
>> VAProfileH264High : VAEntrypointVLD
>> VAProfileH264High : VAEntrypointEncSlice
>> VAProfileVC1Simple : VAEntrypointVLD
>> VAProfileVC1Main : VAEntrypointVLD
>> VAProfileVC1Advanced : VAEntrypointVLD
>> VAProfileNone : VAEntrypointVideoProc
>> VAProfileJPEGBaseline : VAEntrypointVLD
>>
>> libva-1.3.0 and intel-libva-driver-1.3.0
>>
>> 28.03.2014, 11:01, "Zhao Yakui" <yakui.zhao at intel.com>:
>>> On Fri, 2014-03-28 at 10:44 +0400, Nik Orlov wrote:
>>>> Hello!
>>>>
>>>> I have tested h264encoder with sync mode and without. Time is ok.
>>>> But I have strange bug.
>>>> I`m generating h264 bitstream output like this
>>>> ./h264encode -w 3840 -h 1080 -framecount 2500 -f 25 -o ./test.h264
>>>> I have generated different resolutions, from resolution 1024x768 I
>>>> have such ugly picture.
>>>> At the moment I don`t understand what is it about?
>>> Which version of driver is used in your test?
>>>
>>> It seems that it is not encoded as expected.
>>>
>>> Will you please try to file a bug on https://bugs.freedesktop.org/ and
>>> select the libva as component?
>>>
>>> Thanks.
>>> Yakui
>>>> Screenshots:
>>>> bug1920x1080.jpg http://yadi.sk/d/ixGQfaKLLM7aU
>>>> bug3840x1080 http://yadi.sk/d/fnZ1TXJSLM7ac
>>>> bug3840x1080_2 http://yadi.sk/d/7NqWLkgLLM7ai
>>>>
>>>> Any ideas?
>>>>
>>>> 27.03.2014, 21:32, "Yuan, Shengquan" <shengquan.yuan at intel.com>:
>>>>> “Frame Rate: 0.06 fps (1 frames, 16500 ms (16500.00 ms per frame))”
>>>>> in your test is calculated by “(total time of app execution)/(total
>>>>> frame)”. “(total time of app execution)” includes app setup, source
>>>>> YUV uploading, frame encoding, coded bitstream saving, app stop,
>>>>> etc. If you only encode 1 frame, the majority time will be “source
>>>>> YUV uploading”.
>>>>>
>>>>> There is detailed break-down of the time in the output, but since
>>>>> the application runs with two threads (one is source YUV uploading,
>>>>> another thread is frame encoding), you are not able to get the
>>>>> absolute time of a frame encoding.
>>>>>
>>>>> Tips:
>>>>> * If you want to know the accurate time of one frame encoding,
>>>>> use option “-syncmode”, and check the time of
>>>>> “vaBegin/vaRender/vaEnd/vaSyncSurface”
>>>>> * If you want to get the end-to-end encoding fps number, try
>>>>> to encoding thousand of frames with auto-generated YUV
>>>>> source (without –srcyuv), e.g. “h264encode –n 7000”
>>>>>
>>>>> Thanks
>>>>> -Austin
>>>>>
>>>>> From: Libva [mailto:libva-bounces at lists.freedesktop.org] On Behalf
>>>>> Of Matt Pekar
>>>>> Sent: Thursday, March 27, 2014 9:11 AM
>>>>> To: Nik Orlov
>>>>> Cc: libva at lists.freedesktop.org
>>>>> Subject: Re: [Libva] linux vaapi h.264 encoding haswell hd graphics
>>>>> 4600
>>>>>
>>>>> For that size of frame, 20ms is a pretty darn good time IMO. We see
>>>>> 10ms (ish) on things in the 1280x720 range.
>>>>>
>>>>> 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.
>>>>>
>>>>> 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.
>>>>>
>>>>> On Thu, Mar 27, 2014 at 5:57 AM, Nik Orlov <nikitos1550 at yandex.ru>
>>>>> wrote:
>>>>> Hello!
>>>>>
>>>>> I have ubuntu-desktop 13.10 amd64 on core i7 4770 (Haswell, HD
>>>>> graphics 4600).
>>>>> I have installed vaapi (libva from sources 1.3.0).
>>>>>
>>>>> There is h264encode test. I have started it:
>>>>>
>>>>> user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./h264encode -w
>>>>> 3840 -h 1080 -framecount 1 -f 25
>>>>> Source frame is 3840x1080 and will code clip to 3840x1088 with crop
>>>>>
>>>>> INPUT:Try to encode H264...
>>>>> INPUT: RateControl : VBR
>>>>> INPUT: Resolution : 3840x1080, 1 frames
>>>>> INPUT: FrameRate : 25
>>>>> INPUT: Bitrate : 24883200
>>>>> INPUT: Slieces : 1
>>>>> INPUT: IntraPeriod : 30
>>>>> INPUT: IDRPeriod : 60
>>>>> INPUT: IpPeriod : 1
>>>>> INPUT: Initial QP : 26
>>>>> INPUT: Min QP : 0
>>>>> INPUT: Source YUV : AUTO generated
>>>>> INPUT: Coded Clip : /tmp/test.264
>>>>> INPUT: Rec Clip : Not save reconstructed frame
>>>>>
>>>>> libva info: VA-API version 0.35.0
>>>>> libva info: va_getDriverName() returns 0
>>>>> libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
>>>>> libva info: Found init function __vaDriverInit_0_35
>>>>> libva info: va_openDriver() returns 0
>>>>> Use profile VAProfileH264High
>>>>> Support rate control mode (0x12):CBR CQP
>>>>> Support VAConfigAttribEncPackedHeaders
>>>>> Support packed sequence headers
>>>>> Support packed picture headers
>>>>> Support packed misc headers
>>>>> Support 1 RefPicList0 and 1 RefPicList1
>>>>> Loading data into surface 15.....Complete surface loading
>>>>> |00000000(485835 bytes coded)
>>>>>
>>>>> PERFORMANCE: Frame Rate : 0.06 fps (1 frames, 16500 ms
>>>>> (16500.00 ms per frame))
>>>>> PERFORMANCE: Compression ratio : 12:1
>>>>> PERFORMANCE: UploadPicture : 16444 ms (16444.00, 99.66%
>>>>> percent)
>>>>> PERFORMANCE: vaBeginPicture : 0 ms (0.00, 0.00% percent)
>>>>> PERFORMANCE: vaRenderHeader : 0 ms (0.00, 0.00% percent)
>>>>> PERFORMANCE: vaEndPicture : 3 ms (3.00, 0.02% percent)
>>>>> PERFORMANCE: vaSyncSurface : 32 ms (32.00, 0.19% percent)
>>>>> PERFORMANCE: SavePicture : 0 ms (0.00, 0.00% percent)
>>>>> PERFORMANCE: Others : 21 ms (21.00, 0.13% percent)
>>>>> (Multithread enabled, the timing is only for reference)
>>>>>
>>>>> And other way
>>>>>
>>>>> user at video-ubuntu:~/VAAPI/libva-1.3.0/test/encode$ ./h264encode -w
>>>>> 3840 -h 1080 -framecount 2500 -f 25
>>>>> Source frame is 3840x1080 and will code clip to 3840x1088 with crop
>>>>>
>>>>> INPUT:Try to encode H264...
>>>>> INPUT: RateControl : VBR
>>>>> INPUT: Resolution : 3840x1080, 2500 frames
>>>>> INPUT: FrameRate : 25
>>>>> INPUT: Bitrate : 24883200
>>>>> INPUT: Slieces : 1
>>>>> INPUT: IntraPeriod : 30
>>>>> INPUT: IDRPeriod : 60
>>>>> INPUT: IpPeriod : 1
>>>>> INPUT: Initial QP : 26
>>>>> INPUT: Min QP : 0
>>>>> INPUT: Source YUV : AUTO generated
>>>>> INPUT: Coded Clip : /tmp/test.264
>>>>> INPUT: Rec Clip : Not save reconstructed frame
>>>>>
>>>>> libva info: VA-API version 0.35.0
>>>>> libva info: va_getDriverName() returns 0
>>>>> libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
>>>>> libva info: Found init function __vaDriverInit_0_35
>>>>> libva info: va_openDriver() returns 0
>>>>> Use profile VAProfileH264High
>>>>> Support rate control mode (0x12):CBR CQP
>>>>> Support VAConfigAttribEncPackedHeaders
>>>>> Support packed sequence headers
>>>>> Support packed picture headers
>>>>> Support packed misc headers
>>>>> Support 1 RefPicList0 and 1 RefPicList1
>>>>> Loading data into surface 15.....Complete surface loading
>>>>> \00002499(719089 bytes coded)
>>>>>
>>>>> PERFORMANCE: Frame Rate : 53.70 fps (2500 frames, 46555
>>>>> ms (18.62 ms per frame))
>>>>> PERFORMANCE: Compression ratio : 11:1
>>>>> PERFORMANCE: UploadPicture : 16364 ms (6.55, 35.15%
>>>>> percent)
>>>>> PERFORMANCE: vaBeginPicture : 2 ms (0.00, 0.00% percent)
>>>>> PERFORMANCE: vaRenderHeader : 18 ms (0.01, 0.04% percent)
>>>>> PERFORMANCE: vaEndPicture : 1098 ms (0.44, 2.36% percent)
>>>>> PERFORMANCE: vaSyncSurface : 21385 ms (8.55, 45.93%
>>>>> percent)
>>>>> PERFORMANCE: SavePicture : 8759 ms (3.50, 18.81% percent)
>>>>> PERFORMANCE: Others : -1071 ms (1717986.49,
>>>>> 9225574.54% percent)
>>>>> (Multithread enabled, the timing is only for reference)
>>>>>
>>>>> So, when test encodes more frames time for encoding 1 frame is about
>>>>> 20ms.
>>>>> Why it is so?
>>>>>
>>>>> 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?
>>>>> As I understand programm sends some data to GPU, GPU encodes video
>>>>> and then send me encoded data back.
>>>>> How much time takes sending data to GPU and back?
>>>>>
>>>>> 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.
>>>>>
>>>>> --
>>>>> Ник Орлов mailto:nikitos1550 at yandex.ru
>>>>> _______________________________________________
>>>>> Libva mailing list
>>>>> Libva at lists.freedesktop.org
>>>>> http://lists.freedesktop.org/mailman/listinfo/libva
>>>> --
>>>> Ник Орлов
>>>> mailto:nikitos1550 at yandex.ru
>>>>
>>>> _______________________________________________
>>>> Libva mailing list
>>>> Libva at lists.freedesktop.org
>>>> http://lists.freedesktop.org/mailman/listinfo/libva
--
Ник Орлов mailto:nikitos1550 at yandex.ru
More information about the Libva
mailing list