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 · 20 comments
Closed

6.1.0 Error encoding/writing frame: Invalid argument #1222

HauptlingHD opened this issue Nov 7, 2024 · 20 comments
Labels
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 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
@HauptlingHD
Copy link
Author

I have tried 6.2.0. Unfortunately, the error is unchanged.

[2024-12-14 01:13:53.728] [error] Error muxing packet
[2024-12-14 01:13:53.728] [critical] Error encoding/writing frame: Invalid argument
[2024-12-14 01:13:53.728] [critical] Error processing frames: Invalid argument
[libx264 @ 000002162b763c00] frame I:1     Avg QP:27.47  size:  3209
[libx264 @ 000002162b763c00] frame P:3     Avg QP:21.41  size: 25776
[libx264 @ 000002162b763c00] frame B:3     Avg QP:21.80  size: 17062
[libx264 @ 000002162b763c00] consecutive B-frames: 20.0%  0.0%  0.0% 80.0%
[libx264 @ 000002162b763c00] mb I  I16..4:  1.0% 98.1%  0.9%
[libx264 @ 000002162b763c00] mb P  I16..4: 18.6% 46.4%  0.9%  P16..4: 13.0%  1.9%  1.0%  0.0%  0.0%    skip:18.2%
[libx264 @ 000002162b763c00] mb B  I16..4:  2.5%  1.8%  0.0%  B16..8: 29.4%  2.9%  0.5%  direct: 9.3%  skip:53.7%  L0:27.8% L1:71.0% BI: 1.2%
[libx264 @ 000002162b763c00] 8x8 transform intra:78.1% inter:88.1%
[libx264 @ 000002162b763c00] coded y,uvDC,uvAC intra: 14.7% 32.2% 1.2% inter: 12.4% 25.7% 0.1%
[libx264 @ 000002162b763c00] i16 v,h,dc,p: 20% 25%  4% 51%
[libx264 @ 000002162b763c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 66% 10% 12%  2%  2%  2%  2%  2%  2%
[libx264 @ 000002162b763c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 34% 15%  4%  5%  3%  4%  2%  3%
[libx264 @ 000002162b763c00] i8c dc,h,v,p: 67% 16% 12%  5%
[libx264 @ 000002162b763c00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000002162b763c00] ref P L0: 72.3%  5.1% 22.3%  0.3%
[libx264 @ 000002162b763c00] ref B L0: 99.7%  0.3%
[libx264 @ 000002162b763c00] ref B L1: 85.0% 15.0%
[libx264 @ 000002162b763c00] kb/s:3763.51```

@k4yt3x k4yt3x reopened this Dec 14, 2024
@github-actions github-actions bot added state:Backlog This issue will be worked on in the future and removed state:Done This issue has been resolved/dismissed labels Dec 14, 2024
@k4yt3x k4yt3x added state:InProgress This issue is being worked on and removed state:Backlog This issue will be worked on in the future labels Dec 14, 2024
@k4yt3x
Copy link
Owner

k4yt3x commented Dec 14, 2024

Hmm for real? That's weird.

@k4yt3x
Copy link
Owner

k4yt3x commented Dec 14, 2024

image

I just tried it and it was okay. What's the full command that you're using?

@HauptlingHD
Copy link
Author

I use the GUI with the following settings:

Screenshot 2024-12-15 182636
Screenshot 2024-12-15 182654

@k4yt3x
Copy link
Owner

k4yt3x commented Dec 16, 2024

So I tested it, and it ended up not being a timestamp issue again. It's that the avi container doesn't support the audio codec format for some reason. If you change it to .mkv, it'll process just fine. I'm thinking maybe I should set the default suffix to mkv or mp4.

@k4yt3x
Copy link
Owner

k4yt3x commented Dec 16, 2024

I think this ultimately comes down to user guidance and error message handling. It would be a separate issue.

@k4yt3x k4yt3x closed this as completed Dec 16, 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 Dec 16, 2024
@HauptlingHD
Copy link
Author

I can confirm this partially. As far as I have tested, only ".mkv" as a suffix works. Any other container format I have tested leads to the same error. (avi, mp4, mov)

I have also opened a related issue #1263 regarding the auto generated suffixes in the GUI.

@Raknaren
Copy link

Raknaren commented Jan 18, 2025

Hi, I got the same error with a video today. I'm trying with MKV now. Also using the GUI. I'm sharing my log hoping that helps in any way.

[2025-01-17 21:08:00] [info] Starting Video2X Qt6 6.3.1
[2025-01-17 21:32:06] [warning] [FFmpeg] [mov,mp4,m4a,3gp,3g2,mj2 @ 00000219d7dcbf80] stream 0, timescale not set
[2025-01-17 21:32:06] [info] [FFmpeg] [libx264 @ 00000219dc66e700] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[2025-01-17 21:32:06] [info] [FFmpeg] [libx264 @ 00000219dc66e700] profile High 4:2:2, level 6.0, 4:2:2, 10-bit
[2025-01-17 21:32:06] [info] [FFmpeg] [libx264 @ 00000219dc66e700] 264 - core 164 r3192 c24e06c - H.264/MPEG-4 AVC codec - Copyleft 2003-2024 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=24 lookahead_threads=4 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=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=81 qpstep=4 ip_ratio=1.40 aq=1:1.00
[2025-01-18 14:39:01] [error] [FFmpeg] [mp4 @ 00000219dc66e080] unsupported channel layout 2 channels
[2025-01-18 14:39:01] [critical] Error writing output file trailer: Invalid argument
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] frame I:224   Avg QP:26.41  size:427763
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] frame P:2046  Avg QP:28.78  size:174964
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] frame B:3073  Avg QP:28.82  size:106207
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] consecutive B-frames: 21.0%  4.5%  7.4% 67.1%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] mb I  I16..4: 46.2% 47.4%  6.5%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] mb P  I16..4: 19.0% 12.2%  1.2%  P16..4: 21.8%  3.9%  3.4%  0.0%  0.0%    skip:38.5%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] mb B  I16..4:  1.4%  1.4%  0.2%  B16..8: 21.4%  3.2%  0.7%  direct: 4.6%  skip:67.0%  L0:46.7% L1:48.1% BI: 5.2%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] 8x8 transform intra:40.7% inter:78.4%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] direct mvs  spatial:99.6% temporal:0.4%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] coded y,uvDC,uvAC intra: 24.9% 45.4% 7.0% inter: 9.7% 17.1% 0.8%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] i16 v,h,dc,p: 16% 17%  2% 64%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15%  9% 17%  8% 14% 10% 12%  7%  8%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 13%  8% 10% 15% 11% 12%  8% 10%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] i8c dc,h,v,p: 27% 28% 14% 31%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] Weighted P-Frames: Y:7.9% UV:7.6%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] ref P L0: 70.7% 15.6%  8.4%  4.5%  0.8%  0.0%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] ref B L0: 75.9% 16.7%  5.8%  1.5%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] ref B L1: 93.7%  6.3%
[2025-01-18 14:39:01] [info] [FFmpeg] [libx264 @ 00000219dc66e700] kb/s:28007.21
[2025-01-18 14:59:38] [warning] [FFmpeg] [mov,mp4,m4a,3gp,3g2,mj2 @ 00000219d7dcbf80] stream 0, timescale not set
[2025-01-18 14:59:38] [info] [FFmpeg] [libx264 @ 00000219d7de1680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[2025-01-18 14:59:38] [info] [FFmpeg] [libx264 @ 00000219d7de1680] profile High 4:2:2, level 6.0, 4:2:2, 10-bit
[2025-01-18 14:59:38] [info] [FFmpeg] [libx264 @ 00000219d7de1680] 264 - core 164 r3192 c24e06c - H.264/MPEG-4 AVC codec - Copyleft 2003-2024 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=24 lookahead_threads=4 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=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=81 qpstep=4 ip_ratio=1.40 aq=1:1.00

I wanted to try a different file-format as .mkv seem to be unplayable on my VLC, black screen with sound but I think that's a separate issue. My video editing software opens it fine and I just export in as .mp4

Thanks for all your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:Done This issue has been resolved/dismissed
Projects
None yet
Development

No branches or pull requests

3 participants