vnc2video
vnc2video copied to clipboard
[Feature Request] Force Input Close on vcodec.Close()
Hi @amitbet , I'm working also with your great library but I found a non expected behaviour.
When I I call:
vcodec.Close()
On by example x264 enconder https://github.com/amitbet/vnc2video/blob/master/encoders/x264-enc.go
ffmpeg doen't save video.
I've been playing by copying the complete x264-enc.go/image-enc.go into my code (renaming as CustomEncode) and 've finally achieved force ffmpeg to save video on vcodec.Close() by forcing input close.
func (enc *CustomEncoder) Close() {
enc.closed = true
err := enc.input.Close()
if err != nil {
debug.PrintStack()
log.Errorf("=============>Error on waiting for stop ffmpeg encoder: %s", err)
}
}
¿ Could yo please add to your encoders please?
Thank you very much
I tried your solution but did not work well, I see the author add a comment in Close
function,//enc.cmd.Process.Kill()
, he maybe think about this long before. I'm trying to fix this problem
using ffmpeg the way I did is kind of a hack in itself, you don't have direct control of the ffmpeg process once you have launched it. The right way would be to use one of the go-ffmpeg wrapper libs, but that was too complex for what I wanted to do (which was to implement a VNC client in go). another solution is to use the MJPEG implementation which is pure go code instead of using ffmpeg, and encode the resulting video to another format later on.
The enc.input.Close()
is working fine for me in production for more than 1 month.
We are recording selenium based browsing inside qemu VNC based vm's inside docker. We control the stop recording and the start of writting mpg file by executing the Close()
method in the recorder image before kill the image, as I told you in my previous message.
enc.input.Close()
works fine, but it didnot work well in a exec.Command goroutine. The file will get moov atom not found
error, this is lseek did not return the right filesize, cause the ffmpeg think he did not get the file. I will try go-ffmpeg.
enc.input.Close()
will force ffmpeg
to properly close the file. I can confirm this works.