func (f *FFMpeg) GetTranscodeStream(ctx context.Context, options TranscodeStreamOptions) (*Stream, error) {
	args := options.getStreamArgs()
	cmd := f.Command(ctx, args)
	logger.Debugf("Streaming via: %s", strings.Join(cmd.Args, " "))

	stdout, err := cmd.StdoutPipe()
	if nil != err {
		logger.Error("FFMPEG stdout not available: " + err.Error())
		return nil, err
	}

	stderr, err := cmd.StderrPipe()
	if nil != err {
		logger.Error("FFMPEG stderr not available: " + err.Error())
		return nil, err
	}

	if err = cmd.Start(); err != nil {
		return nil, err
	}

	// stderr must be consumed or the process deadlocks
	go func() {
		stderrData, _ := io.ReadAll(stderr)
		stderrString := string(stderrData)
		if len(stderrString) > 0 {
			logger.Debugf("[stream] ffmpeg stderr: %s", stderrString)
		}
	}()

	ret := &Stream{
		Stdout:   stdout,
		Cmd:      cmd,
		mimeType: options.Codec.MimeType,
	}
	return ret, nil
}
// GetTranscodeStream starts the live transcoding process using ffmpeg and returns a stream.
GetTranscodeStream starts the live transcoding process using ffmpeg and returns a stream.
// GetTranscodeStream starts the live transcoding process using ffmpeg and returns a stream .
func (f *FFMpeg) GetTranscodeStream(ctx context.Context, options TranscodeStreamOptions) (*Stream, error) {
	args := options.getStreamArgs()
	cmd := f.Command(ctx, args)
	logger.Debugf("Streaming via: %s", strings.Join(cmd.Args, " "))
	stdout, err := cmd.StdoutPipe()
	if nil != err {
		logger.Error("FFMPEG stdout not available: " + err.Error())
		return nil, err
	}
	stderr, err := cmd.StderrPipe()
	if nil != err {
		logger.Error("FFMPEG stderr not available: " + err.Error())
		return nil, err
	}
	if err = cmd.Start(); err != nil {
		return nil, err
	}
	go func() {
		stderrData, _ := io.ReadAll(stderr)
		stderrString := string(stderrData)
		if len(stderrString) > 0 {
			logger.Debugf("[stream] ffmpeg stderr: %s", stderrString)
		}
	}()
	ret := &Stream{
		Stdout:   stdout,
		Cmd:      cmd,
		mimeType: options.Codec.MimeType,
	}
	return ret, nil
}
func ( f * FFMpeg ) GetTranscodeStream ( ctx context . Context , options TranscodeStreamOptions ) ( * Stream , error ) { args := options . getStreamArgs ( ) cmd := f . Command ( ctx , args ) logger . Debugf ( " " , strings . Join ( cmd . Args , " " ) ) stdout , err := cmd . StdoutPipe ( ) if nil != err { logger . Error ( " " + err . Error ( ) ) return nil , err } stderr , err := cmd . StderrPipe ( ) if nil != err { logger . Error ( " " + err . Error ( ) ) return nil , err } if err = cmd . Start ( ) ; err != nil { return nil , err } go func ( ) { stderrData , _ := io . ReadAll ( stderr ) stderrString := string ( stderrData ) if len ( stderrString ) > 0 { logger . Debugf ( " " , stderrString ) } } ( ) ret := & Stream { Stdout : stdout , Cmd : cmd , mimeType : options . Codec . MimeType , } return ret , nil }
GetTranscodeStream starts the live transcoding process using ffmpeg and returns a stream.
GetTranscodeStream starts the live transcoding process using ffmpeg and returns a stream .
// stderr must be consumed or the process deadlocks