Skip to content
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

6.1.0 Error encoding/writing frame: Invalid argument #1222

Closed
HauptlingHD opened this issue Nov 7, 2024 · 12 comments
Closed

6.1.0 Error encoding/writing frame: Invalid argument #1222

HauptlingHD opened this issue Nov 7, 2024 · 12 comments
Labels
component:FFmpeg FFmpeg related issue state:Done This issue has been resolved/dismissed

Comments

@HauptlingHD
Copy link

I'm trying to use realesrgan-plus in the latest release (6.1.0) and always run into the error in the title. (full log below) I'm using a somewhat old .avi file as input. The output file I get is always 12,7 KB in size and also ends in .avi (.processed.avi) despite the Container Format being the default .mp4. All details of the output file are correct as reported by Windows file probates (25 fps, Sterio Audio, etc.) but the file seams to only contain one frame.

Other system Info:
Win 11
Core Ultra 7 165U (Using iGPU)
32 GB RAM

[...]
[libx264 @ 000002631dd0ad80] non-strictly-monotonic PTS
[2024-11-07 11:33:27.495] [debug] Processed frame 75/21994
[2024-11-07 11:33:27.495] [debug] Frame not ready
[libx264 @ 000002631dd0ad80] non-strictly-monotonic PTS
[libx264 @ 000002631dd0ad80] frame=   0 QP=27.20 NAL=3 Slice:I Poc:0   I:10208 P:0    SKIP:0    size=3142 bytes
[2024-11-07 11:33:43.109] [debug] Processed frame 76/21994
[2024-11-07 11:33:43.109] [debug] Frame not ready
[libx264 @ 000002631dd0ad80] frame=   1 QP=21.16 NAL=2 Slice:P Poc:2   I:8012 P:303  SKIP:1893 size=15630 bytes
[avi @ 000002631dd0ba40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: -9223372036854775807 >= -9223372036854775807
[2024-11-07 11:33:57.557] [error] Error muxing packet
[2024-11-07 11:33:57.558] [critical] Error encoding/writing frame: Invalid argument
[2024-11-07 11:33:57.558] [critical] Error processing frames: Invalid argument
[AVIOContext @ 000002631dcf6040] Statistics: 1031558 bytes read, 4 seeks
[AVIOContext @ 000002631dd1dc40] Statistics: 13070 bytes written, 0 seeks, 1 writeouts
[libx264 @ 000002631dd0ad80] frame I:1     Avg QP:27.20  size:  3142
[libx264 @ 000002631dd0ad80] frame P:1     Avg QP:21.16  size: 15630
[libx264 @ 000002631dd0ad80] mb I  I16..4:  1.2% 98.0%  0.8%
[libx264 @ 000002631dd0ad80] mb P  I16..4: 61.1% 16.8%  0.6%  P16..4:  2.9%  0.0%  0.0%  0.0%  0.0%    skip:18.5%
[libx264 @ 000002631dd0ad80] 8x8 transform intra:64.3% inter:43.2%
[libx264 @ 000002631dd0ad80] coded y,uvDC,uvAC intra: 3.3% 13.1% 0.3% inter: 2.0% 8.1% 0.1%
[libx264 @ 000002631dd0ad80] i16 v,h,dc,p: 45% 17%  4% 34%
[libx264 @ 000002631dd0ad80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 84%  2%  4%  1%  2%  1%  2%  1%  2%
[libx264 @ 000002631dd0ad80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 38% 15%  2%  2%  3%  4%  1%  4%
[libx264 @ 000002631dd0ad80] i8c dc,h,v,p: 71% 19%  6%  4%
[libx264 @ 000002631dd0ad80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000002631dd0ad80] kb/s:inf
@k4yt3x
Copy link
Owner

k4yt3x commented Nov 7, 2024

I'll publish 6.1.1 soon which may fix this issue.

@k4yt3x k4yt3x added the state:Backlog This issue will be worked on in the future label Nov 7, 2024
@k4yt3x
Copy link
Owner

k4yt3x commented Nov 8, 2024

Could you plz try 6.1.1?

@HauptlingHD
Copy link
Author

I have tried 6.1.1, and I am getting the same error. On another system with an AMD GPU I am also getting the exact same error.

My guess is that it has to do with my particular video file. I will provide a link to a download of the file below.

https://drive.google.com/file/d/1xm6gck4dHxtDfGw20KMGQqjfFLObzAsJ/view?usp=drive_link

@k4yt3x
Copy link
Owner

k4yt3x commented Nov 9, 2024

@HauptlingHD You aren't sharing it correctly. It's asking me to sign in.

@HauptlingHD
Copy link
Author

Sorry, my bad. Here you go:

https://drive.google.com/file/d/1xm6gck4dHxtDfGw20KMGQqjfFLObzAsJ/view?usp=sharing

@k4yt3x
Copy link
Owner

k4yt3x commented Nov 9, 2024

OK thanks I'm working on it now.

@k4yt3x
Copy link
Owner

k4yt3x commented Nov 9, 2024

I was able to reproduce the error:

image

Yeah I think it's just compatibility issue with the old video codec format. Video2X passes the frame to the H.264 encoder without changing anything, and H.264 can't handle it. I'll see how I can fix it.

At the mean time, you could first re-encode the video with the modern H.264 format with FFmpeg and then Video2X would be able to correctly process that:

ffmpeg -i '001. Warum betreibt man Astronomie (27.09.98).avi' -c:v libx264 astronomie.mp4

@k4yt3x k4yt3x added component:FFmpeg FFmpeg related issue state:InProgress This issue is being worked on and removed state:Backlog This issue will be worked on in the future labels Nov 9, 2024
@HauptlingHD
Copy link
Author

OK, I thought so. I was hoping to avoid re-encoding so I wouldn't lose any quality. I guess I'll just re-encode the video at a stupidly high quality and try again. Thanks for checking!

@k4yt3x
Copy link
Owner

k4yt3x commented Nov 9, 2024

I don't think you'll be losing much quality over this re-encode... but if you really want lossless, you could try using a lossless codec like:

ffmpeg -i astronomie.avi -c:v ffv1 astronomie.mkv

... and Video2X should be able to process that output file without issues.

@k4yt3x
Copy link
Owner

k4yt3x commented Nov 9, 2024

I think I fixed it. The fix is actually quite simple:

image

I'll do some more validation and keep you posted. So far it processed your video without issues. It's just that the total frame estimation seemed off:

image

@HauptlingHD
Copy link
Author

Thanks for the quick update. For now the workaround of re-encoding the video first seems to work with 6.1.1.

@k4yt3x
Copy link
Owner

k4yt3x commented Nov 10, 2024

I've pushed the fix in commit. It will be rolled out in the next release.

@k4yt3x k4yt3x closed this as completed Nov 10, 2024
@github-actions github-actions bot added state:Done This issue has been resolved/dismissed and removed state:InProgress This issue is being worked on labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:FFmpeg FFmpeg related issue state:Done This issue has been resolved/dismissed
Projects
None yet
Development

No branches or pull requests

2 participants