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

Why WriteFrame can't work on ubuntu, but it can work well on mac? #109

Open
yummybian opened this issue Jun 21, 2017 · 1 comment
Open

Comments

@yummybian
Copy link

yummybian commented Jun 21, 2017

var buf []image.Image
// the codec is h264
cap := opencv.NewFileCapture("video.avi")
if cap == nil {
	panic("can not open video")
}
for {
		ipli := cap.QueryFrame()
		if ipli == nil {
			break
		}
		i := ipli.ToImage()
		buf = append(buf, i)
}

props := videoProps{
	fps:    cap.GetProperty(opencv.CV_CAP_PROP_FPS),
	fourcc: cap.GetProperty(opencv.CV_CAP_PROP_FOURCC),
	width:  cap.GetProperty(opencv.CV_CAP_PROP_FRAME_WIDTH),
	height: cap.GetProperty(opencv.CV_CAP_PROP_FRAME_HEIGHT),
}
// fourcc is always 0 on mac, but it works well
w := opencv.NewVideoWriter(v.destFile, int(props.fourcc), float32(props.fps), int(props.width), int(props.height), 1)
for _, img := range buf {
	w.WriteFrame(opencv.FromImage(image))
}
cap.Release()
w.Release() 

On my mac, the above code can write video correctly, but it can just output a corrupt file when it runs on ubuntu. The corrupt file is very small, and can't be opened.

@yummybian
Copy link
Author

@lazywei Could you give me a little hint? Tks.

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

1 participant