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

[problem] [swscaler] Slice parameters 0, 720 are invalid #1

Open
nowgood opened this issue May 10, 2018 · 1 comment
Open

[problem] [swscaler] Slice parameters 0, 720 are invalid #1

nowgood opened this issue May 10, 2018 · 1 comment

Comments

@nowgood
Copy link

nowgood commented May 10, 2018

platform:
maxOS version 10.13.4 (17E202)
opencv_version 3.4.1

I come cross error "Slice parameters 0, 720 are invalid" when I run this file. the reason is following code which set camera frame size don't work.

 cam.set(cv::CAP_PROP_FRAME_WIDTH, width);
 cam.set(cv::CAP_PROP_FRAME_HEIGHT, height);

you can debug code to find camera property CAP_PROP_FRAME_WIDTH and CAP_PROP_FRAME_HEIGHT, in my case, both of them are 1280, not 800 or 600.

the solution is to add cv::resize(image, image, cv::Size(width, height)); to stream_video function

do
  {
    cam >> image;
    cv::resize(image, image, cv::Size(width, height));
    const int stride[] = {static_cast<int>(image.step[0])};
    sws_scale(swsctx, &image.data, stride, 0, image.rows, frame->data, frame->linesize);
    frame->pts += av_rescale_q(1, out_codec_ctx->time_base, out_stream->time_base);

    write_frame(out_codec_ctx, ofmt_ctx, frame);
  } while (!end_of_stream);

@berli
Copy link

berli commented May 23, 2018

same problem
open VID_20160502_162358.mp4 success!
ret=0
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid
[swscaler @ 0x1582d00] Slice parameters 0, 720 are invalid

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