3d0c / gmf

Go Media Framework
MIT License
885 stars 170 forks source link

Support for avformat_open_input options #128

Closed ccaum closed 4 years ago

ccaum commented 4 years ago

Previous to this commit, no options could be given to the FmtCtx.OpenInput function. For input formats like video4linux2, that means options to specify input format (rawvideo, h264, etc.) or framerate were impossible.

This commit introduces a new FmtCtx.OpenInputWithOption function that takes a Option parameter. To maintain backwards compatibility, the OpenInput function now just calls the OpenInputWithOption function, but passes a nil value for the Option parameter.

Example usage:

  inputOptionsDict := gmf.NewDict([]gmf.Pair{
          {"white_balance_auto_preset","4"},
          {"input_format", "h264"},
  })

  inputCtx := gmf.NewCtx()
  inputCtx.SetInputFormat("video4linux2")

  inputOption := &gmf.Option{Key: "video4linux_input_options", Val: inputOptionsDict}

  err := inputCtx.OpenInputWithOption("/dev/video0", inputOption)
3d0c commented 4 years ago

Hi, @ccaum. Yes, looks good, but i found two problems:

ccaum commented 4 years ago

Sorry for the delay. Thanks for catching those issues. All fixed.

3d0c commented 4 years ago

I added small fix for format_go112.go. Now everything looks good. Thank you.