xfrr/goffmpeg

Transcoder.Output() doesn't output progress

falzm opened this issue ยท 7 comments

falzm commented

Hi ๐Ÿ‘‹

I'm trying to write a small utility that resizes video files while reporting the progress of the transcoding, so using your package I wrote this snippet that works (i.e. the file transcoding works), but no output is streamed from channel returned by the Transcoder.Output() method:

package main

import (
	"fmt"

	"github.com/xfrr/goffmpeg/transcoder"
)

var inputPath = "test.mkv"
var outputPath = "test.res.mkv"

func main() {
	trans := new(transcoder.Transcoder)

	err := trans.Initialize(inputPath, outputPath)
	if err != nil {
		panic(err)
	}
	trans.MediaFile().SetAudioCodec("copy")
	trans.MediaFile().SetVideoCodec("libx264")
	trans.MediaFile().SetVideoFilter("scale=854:480")
	trans.MediaFile().SetCRF(18)
	trans.MediaFile().SetPreset("veryslow")

	done := trans.Run(true)
	for msg := range trans.Output() {
		fmt.Println(msg) // <- Nothing printed out here
	}

	if err = <-done; err != nil {
		panic(err)
	}
}

I did a bit of digging, and it seems that bufio.Scanner() gets stuck here (no iteration in the loop).

I'm running ffmpeg 4.2.2 on macOS and Go 1.14.0, let me know if you need more information.

LuaxY commented

Problem seem to be caused by this line:

proc.Stderr = &errb

I created a pull request removing the line. Errors do still seem to be printed - and it's not like the current code handles these errb in any way. I tried to use it without the line and it very much does work as I would expect it to.

falzm commented

Thanks @manscrober!

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

falzm commented

wontfix, seriously?

LuaxY commented

#61 is already merged

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.