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

Getting distorted images - possible error in decoder format? #71

Open
MarcinMroczkowski-Reakto opened this issue Jan 29, 2024 · 3 comments

Comments

@MarcinMroczkowski-Reakto

Hello. I am using this decoder to decode video stream coming from Janus WebRTC. Now, it works, that means, it receives frames and decodes them, but the problem is, i am getting very distorted images.
This is incoming stream configuration in Janus:

rtp-sample101: {
        type = "rtp"
        id = 101
        description = "herelink"
        metadata = "You can use this metadata section to put any info you want!"
        audio = false
        video = true
        videoport = 5101
        videopt = 96
        videortpmap = "H264/90000"
        secret = "adminpwd"
}

Now, i set up the ffmpeg endpoint to decode this incoming stream:

VideoFormat videoFormat = new(96, "H264");
           _videoSink.RestrictFormats(format => format.Codec == VideoCodecsEnum.H264);
            _videoSink.SetVideoSinkFormat(videoFormat);`
           _videoSink.SetVideoSourceFormat(videoFormat);

Then, i save this frame to file:

Mat imageMatrix = new Mat((int)height, (int)width, DepthType.Cv8U, 3);
imageMatrix.SetTo(sample);`
Image<Rgb, byte> image = imageMatrix.ToImage<Rgb, byte>();
Console.WriteLine("creating photo...");
image.Save($"MIS_{missionId}_photo_{photoCount + 1}.jpg");

The above code is implemented using Emgu.CV, I get following image no matter if i use Rgb or Bgr format, it is always distorted:

MIS_1_photo_1
Now, i do not really know where is the problem. Is it a problem with incorrect format? Does ffmpeg need to include h264 library? or is this the problem with actual decoding?

@MarcinMroczkowski-Reakto
Copy link
Author

Follow-up explanation: Only the topmost part of the photo appears correct.

@MarcinMroczkowski-Reakto
Copy link
Author

This photo is better, but still distorted:
MIS_1_photo_28

@ha-ves
Copy link
Contributor

ha-ves commented Jul 8, 2024

if ffmpeg doesnt complain, then it is most probably a problem with your usage of Emgu.CV and/or the source encoding (since you said the top part is correct).

  1. if possible, try decoding locally at the the source, this means omit Janus, which i believe you had done.
  2. since you use Janus, try receiving in web browser, i believe Janus has an example in this.
  3. if the above example doesn't show the same "distorted" frames, then it is most likely some missed steps with using images in Emgu.CV, please open issue in Emgu.CV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants