-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Corrupt transcoded video with rkmpp decoder. #13709
Comments
Hi, Are you sure this is fixed? |
I tested this separately and I think it's caused by this issue. You're most likely seeing tone-mapping artifacts that will be fixed by setting the peak luminance explicitly. Since the linked PR does just this, it should fix the issue. |
Thankyou very much for getting back to me, I appreciate all the hard work. |
HI, Unfortunately I do still have the same problem on hardware decoded transcoded videos in v1.120. |
Hmm, I guess peak=100 (1000 nits) is off for certain videos. Can you share the output of |
Also, are the videos experiencing issues in 1.120.0 the same videos that looked corrupt in earlier versions? Or do different videos look corrupt now? |
Media Info General Video Audio Other |
Hmm, it doesn't seem like this is an HDR video. Could you follow these steps:
I'm curious to see what the specific command is to see where this is going wrong. |
I set log level to debug, but unfortunately i do not see ffmpeg anything. |
Disregard that, the problem was the option "refresh encoded videos" is not re-encoding the video... maybe i misunderstood the meaning of that feature. I made a new video in low light and uploaded it with hardware decoding on, the result was corruption towards the end of the file. ffmpeg -n 10 /usr/bin/ffmpeg -hwaccel rkmpp -hwaccel_output_format drm_prime -afbc rga -noautorotate -i upload/library/Kirk/2024/2024-11-09/PXL_20241109_133516985.mp4 -y -c:v hevc_rkmpp -c:a aac -movflags faststart -fps_mode passthrough -map 0:2 -map 0:1 -g 256 -tag:v hvc1 -v verbose -vf scale_rkrga=720:-2:format=nv12:afbc=1 -level 153 -rc_mode CQP -qp_init 28 upload/encoded-video/c160480f-610d-42d9-8cea-829489f5a58e/f2/b0/f2b017d0-38f9-4331-8f71-d7c71e48b0c2.mp4 I then renamed the file and reuploaded it with hardware decoding off and the resulting file was fine. ffmpeg -n 10 /usr/bin/ffmpeg -i upload/library/Kirk/2024/2024-11-09/reupload.mp4 -y -c:v hevc_rkmpp -c:a aac -movflags faststart -fps_mode passthrough -map 0:2 -map 0:1 -g 256 -tag:v hvc1 -v verbose -vf scale=720:-2 -level 153 -rc_mode CQP -qp_init 28 upload/encoded-video/c160480f-610d-42d9-8cea-829489f5a58e/8d/4e/8d4e5afc-9692-4169-b813-67ba68b96fdd.mp4 Media info for file General Video Audio Other I think you are right they are not HDR, but with the latest update corruption only seems to happen in low light videos, where as before the update it seemed more random. edit. Just ran a few tests and the artifacts and problems seem to happen when in low light but then a strong light source appears in the video, causing looped video, artifacts and strange colours. |
In the transcoding settings under Advanced, could you set the keyframe interval to 60? I wonder if that has an effect here. |
Wow yes, its seems fine with "Maximum keyframe interval" set to 60, thank you so much. |
It will make the videos very slightly bigger, but otherwise no downside as far as I know. |
Ok, thankyou. Not sure if it's related but i just noticed a very very thin line at the top and bottom of the video that is not there when I use software decoding. |
The default in your case is 256, for reference. Can you try setting it to, say, 128? I'm thinking of changing the default for RKMPP to remedy this, but also trying to minimize the impact to file size. |
cc @nyanmisaka if you have any insight into what's causing this behavior |
After deleting and re-uploading the same to files one a dark video and one bright. |
Since software decode is working fine with rkmpp hardware encode on its defaults, is there not any settings to play with on the hardware decode side? |
A max of 32 for a 60 FPS video is a keyframe roughly every 0.5s. This is okay, but I think it's the lowest that's reasonable to use. What's particularly weird is that this is an encoding setting - it shouldn't be fixed by using software decoding. It's a combination of the frames being outputted by hardware decoding and the keyframe interval that's causing this issue. I think drm_prime is needed for good performance so filters can directly access the frames in the GPU without copying them. |
I'd like to help in anyway I can but I'm not very knowledgeable but i can follow instructions, do any of the devs have access to an rkmpp device? |
I hope it doesn't seem like i'm complaining about the issue too much, I understand you must be busy on other things. |
What’s the SoC model and rockchip linux kernel version? (uname -a) Can u share a sample clip and the full ffmpeg command line? I may have time to take a look tomorrow. |
No worries! It's great that you're reporting on this so we know about it and can fix it. I think the best option would be to open an issue in jellyfin-ffmpeg as I believe most/all of the RKMPP decoders, filters and encoders for FFmpeg are implemented by them. A zipped sample video would be particularly helpful. |
According to OP, this command is problematic:
This command works fine:
And changing the first command to use Also, it seems there's a line at the top and bottom of the video when hardware decoding that doesn't happen with software decoding. I think this happens with |
uname -a Thankyou for the command line noted above and the description is perfect, the line thing happens no matter the -g setting and is only visible in mobile app (android) maybe web viewer clips it off? |
Hiya - running into this issue too but with Intel iGPU hardware acceleration. No issues encoding without iGPU. |
Sample video after Intel iGPU hardware transcode using VAAPI or QuickSync. playback.mp4 |
It's best to switch to a different client and try again. |
Ok, I will try it with the updated immich client, once the fix reaches it maybe it's not an issue anymore. |
Thanks. Yeah it's that bug with the Intel Media Driver link you provided. Not sure if I should open a separate bug now as it seems to be a very very old issue with Proxmox + SRIOV + my new iPhone 16 with HDR videos. I just noticed this issue because of my new iPhone is recording HDR videos vs. my old iPhone XR. Disabling the Tone-Mapping in the Immich Video Transcoding setting now works properly with hardware acceleration. Anyways, sorry for hijacking this thread as it read like the same issue with me. I can open a new bug thread for tips to other folks, if needed. |
I don't have an Intel GPU that supports SRIOV at the moment (Intel ARC A380), you could try looking in the Intel repo to provide some context. But anyway this issue is not related to the downstream software, as the same FFmpeg commands run perfectly on the host. |
@kaaku3 The bug fix for the RKMPP issue should be in 1.120.2. Can you try with that? |
@mertalev that's great news, unfortunately my armbian server that immich was running went down last night. |
Sorry to hear that! There are lots of reasons it could fail, like power loss. But in general, make sure the server is hardened with a reverse proxy, fail2ban, etc. if you're exposing it to the internet. Definitely don't expose Immich (or any other service) directly. |
I was using nginx, I will look into fail2ban too thankyou. |
Hi, I started fresh. I had a lot of problems seems the newer kernel don't fully support hardware acceleration... i'm not quite sure. this is the ffmpeg from immich log ffmpeg -n 10 /usr/bin/ffmpeg -hwaccel rkmpp -hwaccel_output_format drm_prime -afbc rga -noautorotate -i upload/upload/0175ee76-7502-46c4-9685-08b06e26c9dc/a7/f0/a7f09b0f-653d-4920-8a95-ec929b890cc8.mp4 -y -c:v hevc_rkmpp -c:a aac -movflags faststart -fps_mode passthrough -map 0:2 -map 0:1 -g 256 -tag:v hvc1 -v verbose -vf scale_rkrga=720:-2:format=nv12:afbc=1 -level 153 -rc_mode CQP -qp_init 28 upload/encoded-video/0175ee76-7502-46c4-9685-08b06e26c9dc/f9/57/f9578312-e623-4a61-9667-607baed5a02e.mp4 anyway to tell from that that it isn't falling back to software? edit. I there are errors [Nest] 7 - 11/14/2024, 1:30:47 AM ERROR [Microservices:MediaRepository] handler_name : SoundHandle I don't think i can test this right now |
It seems like this is the relevant line:
Does it fail for all videos, or only certain ones? |
Thankyou for pointing that out,it seems to be only one file. |
Thanks for clarifying. I'm assuming the corruption issue is resolved now? I'm not sure what the issue is for that particular video, but if it worked with software decoding then it's most likely a bug. |
Yes, I just transcoded that file and it's fixed, thankyou so much. |
ubuntu-rockchip tends to be recommended as the best for hardware acceleration support. |
Ok, thankyou |
You can also try downgrading back to 1.120.1 to see if you still get the same error. That would make it clear whether the issue is due to the different server environment or the FFmpeg change. |
I just wiped it ;), I'll keep that in mind if it persists |
Sorry to keeps bothering you here... I think the base system is fine now, but in immich when i run transcoding despite having hardware decoding enable... I don't think it is. edit... I just noticed this [Nest] 7 - 11/15/2024, 11:39:53 AM DEBUG [Microservices:MediaService] OpenCL not available for transcoding, so RKMPP acceleration will use CPU decoding So i think its just me and i need to get opencl working on my system |
Yes, the issue is the lack of OpenCL. There's a PR to loosen this restriction so it tries to still use hardware decoding and only do tone-mapping on CPU (if it's an HDR video). The |
Thankyou, yeah I was keeping an eye on jellyfin ffmpeg and I hoped that's what that commit meant. edit... I don't know how or why, but i after reinstalling everything opencl related, it is working now and hardware decoding is working too. Thanks for all your help. |
Hi I just wanted to add that I still have the same |
Unfortunately the fixed version was merged two hours after the release :/ Maybe we can do a patch release. |
Good to hear the fix is still on the way. Thankyou |
Can you confirm if the issue is fully fixed now on 1.122.1? |
Hi, I'm currently away right now. |
Tentatively closing this issue since it sounds like it's fixed |
I have rechecked my videos and I had absolutely no issues at all, including the line that appears in the video player, that appears fixed too. Thankyou |
The bug
X265 4K videos, transcoded down to 720p x265 using rkmmp hardware accelerated encoding and decoding are sometimes corrupted causing looped playback and strange colours and artifacts when played back.
Video seem fine with HW decoding disabled.
It does not happen every time and is inconsistent but happens often.
The OS that Immich Server is running on
Armbian Bookworm
Version of Immich Server
V1.118.2
Version of Immich Mobile App
V1.118.0
Platform with the issue
Your docker-compose.yml content
Same as default
Your .env content
Reproduction steps
...
Relevant log output
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: