-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add V4L2 request support #278
Comments
Patch attached that at least gets V4l2 request decode working:-
So needs a lot of work. |
FWIW - copy back/decode only appears to work but performance is terrible and it looks like there is a conversion to YUV420P happening somewhere (it should be returning NV12) |
Mark, I'm wonder why using mythffmpeg at commandline with -loglevel debug i see references to v4l2_decode
gives
but using mythtv with log playback,libav and loglevel debug there is ffmpeg output like from sw.decode without any reference to v4l2_request:
above is from video playback profile "v4l2 decode only". |
@warpme don't use decode only - as noted earlier - something isn't correct there. |
ehh silly me!. it is great work! |
Mark, |
@warpme I'm swamped with issues and a little help would be nice. There were some changes last night - can you modify/update/regenerate the patch for the small changes required? |
sure. l'll do and attach updated patch here :-) |
Mark,
I think we should apply above code to MythTV FFmpeg - ideally as GIT submodule with patch-by-patch downstream commits applied over mainline 4.3.1 FFmpeg. Such approach IMHO will allow:
If you decide to go this route - I can decompose patch 151-.... into series of single commits over upstream FFmpeg. Ideally will be do the same for our v4l2_m2m downstream changes (and maybe mux/dvbsubs as well)... |
@warpme I need to cleanup and commit a stash of code I have locally and will then revisit v4l2 support. I'm wary of adding v4l2 request code to master until we have fixed the regression in the existing (non-request) code. |
Mark, Is there any chance to look on seeking issue with v4l2_request? |
- *MythTV* code only - no FFmpeg or configure support yet so this is non- functional and I've added an ifdef to protect usage of the as-yet undeclared V4L2RequestDescriptor type Refs #278
@warpme It looks like v4l2 request is now available for pi4 HEVC. I'll check it out. re seeking - I can't find the reference to it (it was on the raspberrypi.org forums somewhere) - but it is apparently a known issue with the FFmpeg code. |
Mark,
Updated configure patch: https://github.com/warpme/minimyth2/blob/7e01083817b01411e2134e1855fd9d5b11f05fda/script/myth-master/mythtv/files/0152-configure-add-v4l2request-support.patch All works perfectly (except known seek issue). Some thoughts from my side: As You mention seek issue is ffmpeg issue. So I asked KODI friends with following Q: when i'm switching in player from ffmpeg sw.decode to v4l2_request: are there any extra needs/changes in player calling to ffmpeg api regarding seek? (i'm asking about purely seek area). Context: we have perfectly working seek in sw. decode - but seek on v4l2_request gives us looped playback. Answer: nope So: as we (mythtv) have perfectly working seek on sw. decode (and on vaapi/vdpau/nvdec as well) - for non working seek on v4l2_req on mythtv i see following possible logical answers:
Accordingly to KODI devs a\ is false to it looks like b\ is a case. FYI: Here is relevant KODI code: https://github.com/xbmc/xbmc/blob/master/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp btw: When You will be playing with RPI - pls note: KODI has separate patch for RPI (https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/multimedia/ffmpeg/patches/rpi/ffmpeg-001-rpi.patch) I was told v4l2_request code for rpi and rest of state-less decoders (allwinner/rockchip) is the same. Main addition is sand fb format, 10bits, etc. Also - pls note: many discussions about seek issues are about statefull decoders (v4l2_m2m) - not about stateless (v4l2_request). IIRC key issue in stateful decoders cooperating with ffmpeg is assuring all the time (start/stop/seek) a state coherency between ffmpeg state machine and decoder firmware state machine. stateless decoders are much nicer here as all logic is usually in sw. (ffmpeg). |
@warpme I think that kodi/ffmpeg patch for pi is out of date. I was referring to the new h265 kernel driver: https://github.com/raspberrypi/linux/tree/rpi-5.4.y/drivers/staging/media/rpivid I tried testing yesterday. Add the appropriate overlay and a new /dev/video19 device appears as expected. The usual crap when trying to do anything on the pi however; patched ffmpeg doesn't detect v4l2-request support (not exactly sure why, but one reason is probably that the pi v4l2 header (videodev2.h) is still too old, despite updating the kernel). Compiled myth anyway as it should still tell me whether it has detected any v4l2 request devices; but is linking to both broadcom and mesa opengl drivers and won't start; so threw it out of the window and am heading back to the tx6 to test. |
Mark,
ps: Yeah - rpi is nightmare (especially with their attitude to upstream kernel & ffmpeg). This is very sad as rpi success is not in small part based on FOSS but their return to FOSS by contributing their rpi-speciffic work by upstreaming is total frustration for FOSS. I would say: it was at best "do-minimal-to-stop-foss-ranting" but with rpi4 becomes more "subtle-block-for-keeping-advantage-over-copmetition". |
Hardware decoding on tx6 failing. Motivation gone. Sense of humour gone. Another box thrown out of the window. I'll come back to this when I can bear to flash another sd card... |
Mark, Regarding rpi:
I think worth strategy is small steep at once and starting with something well supported by good foss devs. ps: i uploaded current master build for tx6 (https://github.com/warpme/minimyth2/releases/tag/v11.12.0-v32-Pre-1976-gc9ec3de372) so you can see how well Your work already works. |
ref 9ab8e19 |
Updated ffmpeg patch with small changes for raspberry pi 4 HEVC decoding (only changes are in v4l2_request.c). Decoding appears to work but presentation fails at the DMA BUF stage (i.e. DRM to EGL image). Not sure whether I've missed something from the Pi4 patches or whether the ubuntu pi kernel is too old (5.8) or there is just something else that needs to be done. |
Ah - this is what i was suspecting (i mean armbian thing). I feel a bit shame about this 5.9 vs. 5.10 thing - but this is because we are on bleeding edge.... re 60fps@4k on tx6: i suspect it is issue of mem.bw limitation in gl driver when gpu is doing reading video buffer and writing it out in a larger form. 30fps working for you - is this on 4G tx6 variant? btw: my friends developed support for HW deinterlaceds in h6 and rk SoCs. re Pi4 patches: rpi ppl told me definitely we must go with rpi-5.10.y as it has huge changes / fixes in hevc and drm.... |
Mark, Inside you have bootloader + instruction how to burn sd card For 5.10 kernel You need to use mythtv ffmpeg patches for 5.10 kernel: https://github.com/warpme/minimyth2/blob/339359bbee000d40e06721d4f2aad9c85797693e/script/myth-master/mythtv/files/0151-ffmpeg-add-V4l2_request-support-5.10kernel.patch This ffmpeg patches + current mythtv on 5.10 kernel should well work on h6. If You will have any issues - it is possible provided Armbian 5.10 kernel needs some patching. Give me sign in such case i can provide you minimal set patches for 5.10kernel to get up and running. ps: all this patching is save in respect upstream: my policy is to use minimal required patches from kernel ML validated by kernel maintainers.... |
Mark,
for me it looks like decoded frames from rpi video decoder are with format not recognised by egl. as result no picture. update: I tested https://github.com/MythTV/mythtv/files/5770000/ffmpeg_request_pi4.gz for any regressions. happy to report all 10 platforms playing ok :-) |
Those are the same errors I'm seeing. I've taken code from popcornmix's github branch (forget which one - but latest update was only hours old at the time). I'm not going to worry about it just yet - see below.
Great - thanks. I've made a bit of a breakthrough on DRM rendering (I didn't realise Qt allowed us to access something critical) - so now focused on DRM rendering - which should be the last piece of the puzzle. |
hmmmm..... i'm starting to feel soon we will be most advanced player in embedded world. Already kernel drm guys citing/suggesting us as most prospective playback pipeline! |
Mark, I compiled current master, enabled env. variables and give try. Unfortunately on all platforms at playback start I’m: getting „Please wait” black screen, 1sec of sound in background and then player hang. Looking on fe logs I always see: Pls see attached log from H6 (file has also some extra logs about kernel dmesg, drmmodes, etc) As I have the same error on 4 different hardwares - it think issue might be: I started to look into my qt build.
Looking on Internet I found a bit similar issue: ardera/flutter-pi#86 fix seems to be like this: ardera/flutter-pi@1a49227 Looking into fix I see:
Maybe issue is: DRM properties provided for atomic flip are unsupported on my case(hw + Kernel/DRM)? update:
(see attached file) and is there is interesting line at 3439.154434
So maybe this something related to video mode change at just starting videoplayback? update2: |
@warpme - I've confirmed video mode switching isn't working on tx6. The no video problem appears to be a file system permissions issue. I think you are only getting a partial Qt setup as the following check is failing:- https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythui/platforms/mythdrmdevice.cpp#L229 Does that make sense? To be clear, this is what I get at the start of my logs - which is identical to your logs apart from the json config file - and without the format set the GUI plane completely obscures the video:- `2021-01-19 22:50:13.458837 I [2953/2953] thread_unknown platforms/mythdrmdevice.cpp:147:SetupDRM Exporting 'QT_QPA_EGLFS_KMS_ATOMIC=1' 2021-01-19 22:50:13.574941 I [2953/2953] thread_unknown platforms/mythdrmdevice.cpp:236:SetupDRM Exporting 'QT_QPA_EGLFS_KMS_CONFIG=eglfs_kms_config.json' |
Mark, I must say: this is IMPRESSIVE!. tested: rk3328/rk3399/h6/rpi3b/rpi4 DRM_PRIME with DRM planes shines here: I done test on lowest tvbox i have which was practically unusable at all due v.slow memory (rk3328). Now i have really smooth HD playback on it. This makes huge amount of SoCs with poor GPU (like i.e. mali450) and slow memory nicely working frontends. Another nice surprise: on H6 I have smooth playback of HD/4k@30 - but now also 4k@60 works smooth. With EGL DRM_PRIME - 4k30 was ok - but 4k60 was jumpy. On rpi3 all works nicely even on mainline kernel. Interesting is that on rpi i have quite well working seek on H264 - but rest of platforms have non-working seek. Once again: oh man - this is fantastic work! |
Mark, Just update about v4l2 decode testing on various boxes: mythv code as of ccec025 gives me following status: Summarizing:
So far a bit showstopers (just FYI):
great work! |
@warpme Unfortunately I'm not seeing the same success. For example no HEVC decoding on tanix tx6 - so I can't really get a feel for how well it handles 4k. I'm still using the armbian image you supplied me - which I think was only 5.10rc4 - do you have any idea when HEVC was finalised? (the FFmpeg error complains about failing to set HEVC controls). My gut feeling is that we need some sort of header/kernel/version check if the request stuff is to go into master - otherwise I just see too many issues. |
Mark, re Your Q about hvec finalisation: at current mainline kernel it is in flux as v4l2_request controls are not finalised so:
With above, to move our work forward, I managed to get ffmpeg & kernel code with common v4l2_request hvec controls for aml/aw/rk (rpi4 crap is beyond my patience atm). Im quite sure balbes150 (creator of Armbian image i provided to You) not included some of kernel v4l2_request hvec controls changes - so this explains why hvec not works for you on armbian. Im not debian guy, so armbian kernel rebuild needs some learning curve for me - but if required i can play with this. (so pls advice i You need me here). re "My gut feeling is that we need some sort of header/kernel/version check if the request stuff is to go into master - otherwise I just see too many issues." By this I think we may consider 2 steep strategy here:
As far as i know this exact strategy is of all incarnations of OS'es used for KODI (OpenELEC, CoreELEC, LibereELEC, etc) let me know what you think about above! |
Please remove me from this list….I have no idea why I am on it
… On 3 Feb 2021, at 21:20, Piotr Oniszczuk ***@***.***> wrote:
Mark,
Sorry for late replay!
I was adding wayland support (btw works well; but hell can't figure how to auto-start weston on system without systemd...).
re Your Q about hvec finalisation: at current mainline kernel it is in flux as v4l2_request controls are not finalised so:
not yet exposed as kernel uAPI;
there is discrepancy between various kernel's hvec decoder drivers.
plan to finalize is next months (at leat this date was expressed in Dec2020)
With above, to move our work forward, I managed to get ffmpeg & kernel code with common v4l2_request hvec controls for aml/aw/rk (rpi4 crap is beyond my patience atm).
ffmpeg patches we are using currently already offers working hvec decode on h6/rk3328/rk3399/s905/s912/sm1 (all hw i have to test).
But to get it working you must sync v4l2_request hvec controls also on kernel side (in cedrus/rkvdec/vdec kernel video decoders).
Im quite sure balbes150 (creator of Armbian image i provided to You) not included some of kernel v4l2_request hvec controls changes - so this explains why hvec not works for you on armbian.
This means, to move forward, we need to patch+rebuild kernel in Armbian you are using.
I have all required patches for 5.10 mainline - so effectively task is just to rebuild armbian kernel you are using.
Im not debian guy, so armbian kernel rebuild needs some learning curve for me - but if required i can play with this. (so pls advice i You need me here).
Alternatively - If you will find energy/time to play with armbian kernel recompile - I have all required patches handy and tested...
re "My gut feeling is that we need some sort of header/kernel/version check if the request stuff is to go into master - otherwise I just see too many issues."
My experience/observation from past: finalisation of h264 took 1.5y.
For hevc i'm suspecting it will be faster so probably with 3q2021 or 4q2021 we may expect kernel offers uAPI with stabilised controls, so ffmpeg guys will start consume it. This will take next let say 6mo. Effectively out-of-box hvec will be probably 1..1.5y from now.
By this I think we may consider 2 steep strategy here:
intermediate steep (next 12..18mo): 5.10 lts kernel + patches + ffmpeg + patches
target: mainline kenrel + mainline ffmpeg (12..18mo from today)
As far as i know this exact strategy is of all incarnations of OS'es used for KODI (OpenELEC, CoreELEC, LibereELEC, etc)
let me know what you think about above!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#278 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AC7YMRCIASTYVJ5D5PNHXUTS5G4ZXANCNFSM4THHCA7Q>.
|
Use the unsubscribe link at the bottom of the email, and if you don't want more of these, edit your notification settings on github |
Mark, By excercise I build 5.10.12 armbian kernel + all patches required for working hevc on aw/aml/rk: http://warped.inet2.org/armbian-kernel-5.10.12.tar.xz For upgrade:
I done simple test with upgrading and Armbian (http://warped.inet2.org/armbian-2020.11.zip) seems to boot ok and reports 5.10.12 kernel. ps: this is my first debian .pkg - so i hope nothing is broken. pls let me know how it goes for you :-) edit 10.02.2021: |
Mark, update: works
failed
difference i see is: |
I implemented change in ffmpeg code giving me nicely working seek on v4l2_request on h264 content: warpme/minimyth2@d32dd07 With this i can say: We can close this ticket with status: |
@warpme The necessary Linux kernel headers are public now. Has there been any movement from FFmpeg to add this officially? |
@ulmus-scott FYI: here is my exchange with @Kwiboo about ffmpeg update in mythtv: @Kwiboo: I have now squashed work-in-progress changes and pushed it to my v2 branch FFmpeg/FFmpeg@master...Kwiboo:FFmpeg:v4l2request-2024-v2 , have done minor name and line length refactoring of mpeg2, h264 and hevc to keep them more consistent, will go over vp8 and vp9 and main core code before I send it out later this weekend also started adding support for av1, should be pretty easy as ffmpeg uses the cbs av1 parser and we have almost full access to the parsed raw headers @warpme: is v2 code also with decoding decoupled from drm context or rather "old" way (decoding associated to drm context)? Asking as adapting mythtv to new model (decoding decoupled from drm) might be challenging. For me ideally will be divide up-streaming into 2 steeps: mainline v4l2_request with decoding associated to drm context. then steep2: decouple decoding from drm context. For sure it is non-optimal - but this is only way for e.g. mythtv where video decoding specialist left project.... @Kwiboo: yes, the v2 branch expect use of a new hwdevice type, after a quick peek at the mythtv code I can see that https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/decoders/mythv4l2m2mcontext.cpp#L511 possible need to change to use the new AV_HWDEVICE_TYPE_V4L2REQUEST or https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/decoders/mythdrmprimecontext.cpp#L220-L222 could possible be adopted to also support AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and just call the av_hwdevice_ctx_create with config->device_type That is what the Kodi PR xbmc/xbmc#25467 does, it will just call av_hwdevice_ctx_create with the device_type provided Also not really sure why mythtv include the v4l2_request.h file, that should not really be needed in client applications Then there is no need to include header or use the V4L2RequestDescriptor type, it is expected that the avframe->data[0] points to a AVDRMFrameDescriptor, it just include additional information beyond such struct that is for internal use I can probably send a draft PR for mythtv with the minimum amount of changes I think would be required Following is probably the only thing that needs changing, did however see some other related code that can be simplified, so will send a PR for that:
@warpme: many thx for insights! This sounds very promissing. mythtv guys are preparing to ffmpg update to ffmpeg7. Then - as @MarkKendal left mythtv - i'll probably be person who will update 4l2_request code to deal with mythtv's build-in ffmpeg7.... |
OK, the out of tree patches are still alive. If use of the new/out of tree private FFmpeg header can be removed, as in #929, that would be good since that would be the last internal FFmpeg header used. @warpme you will have to verify everything works as expected, but I don't expect you'll need to do too much since MythTV would only be using public headers (but I could be wrong). Once the patches actually land in FFmpeg, I could cherry-pick them into MythTV's version of FFmpeg 7.0, if that would be helpful. |
If I am not mistaken the
I am hoping the newer v4l2-request FFmpeg patches hit the ffmpeg-devel mailing list tomorrow after a final round of tests. |
I think @warpme might define it for his version of MythTV in his MiniMyth2 distribution. You are correct that MythTV does not normally define |
Current support in MythV4L2M2MContext was a haphazard guess at what might be required to get request support working.
The text was updated successfully, but these errors were encountered: