larksuite / rsmpeg

A Rust crate that exposes FFmpeg's power as much as possible.
https://docs.rs/rsmpeg/latest/rsmpeg/
MIT License
642 stars 40 forks source link

Corruption Frame after decoding #188

Open Mon-ius opened 1 month ago

Mon-ius commented 1 month ago

Given two examples videos, after decoding we will get frames with heavy lines.

https://github.com/user-attachments/assets/bd06074f-08f2-4340-8719-3b9d2f4c6d81

https://github.com/user-attachments/assets/f4f0c7b8-d85a-4adf-94b0-055a03f9b5a3

And the corrupted frames after decoding:

1 2

SimonRacaud commented 1 month ago

Hello, I had that kind of problem. The content of the resulting AVFrame may not be parsed right.

First, check the value in AVFrame.format after the call to receive_frame(), to see if it's the right format you are trying to display. Then see how the content of the frame is processed (frame.data).

Example:

if frame.format == AV_PIX_FMT_YUV420P {
    /// The frame is in YUV420P format
}
Mon-ius commented 1 month ago

@SimonRacaud Thanks for your reply. I tried your method before, which is not the root cause of this issue. Also, I uploaded the video which is YUV420P format for both 1.mp4 and 2.mp4. I also tried to use scaler to convert it to RGB24, and none of them work.

Codewithteju commented 5 days ago

@Mon-ius , May I know how did you converted the frame which is YUV_420P format into RGB ?

Mon-ius commented 4 days ago

@Codewithteju Yes, I found the rust based ffmpeg solutions all have this issue.

Codewithteju commented 4 days ago

@Mon-ius, Actually I am trying to decode a input video and get the frames out of it for further modification such as converting them to grayscale, etc. With Rsmpeg I can only decode the video in raw format (.264), if i use the .mp4 video files, it\s saying there is -"No start codes found, NAL issues and something like this" ([h264 @ 00000000xyz] No start code is found [h264 @ 00000000xyz] Error splitting the input into NAL units.) Have you tried decoding the input video which is .mp4 format?

Is there any discord channel for the rsmpeg module? I have got some doubts regarding encoding too?

Mon-ius commented 4 days ago

@Codewithteju

Hi, I uploaded these two video which are .mp4 format indeed, you can actually download them by clicking the dots and do more test 🤗

Codewithteju commented 4 days ago

@Mon-ius , I have tried decoding with those videos, but getting the same error. How did you decode it, can you provide any code snippet of rsmpeg ?

ldm0 commented 4 days ago

@Codewithteju Yes, I found the rust based ffmpeg solutions all have this issue.

@Mon-ius Could you provide a minimal reproducible example in Rust and C? It's pretty interesting that's Rust-related. I am happy to do some investigation.