mirror of https://bitbucket.org/ausocean/av.git
Merged in mjpeg-output-v4l (pull request #292)
Mjpeg output v4l Approved-by: Saxon Milton <saxon.milton@gmail.com>
This commit is contained in:
commit
94380ef17e
|
@ -202,6 +202,8 @@ func handleFlags() config.Config {
|
|||
cfg.InputCodec = codecutil.PCM
|
||||
case "ADPCM":
|
||||
cfg.InputCodec = codecutil.ADPCM
|
||||
case "MJPEG":
|
||||
cfg.InputCodec = codecutil.MJPEG
|
||||
default:
|
||||
log.Log(logger.Error, pkg+"bad input codec argument")
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||
"bitbucket.org/ausocean/av/device"
|
||||
"bitbucket.org/ausocean/av/revid/config"
|
||||
"bitbucket.org/ausocean/utils/logger"
|
||||
|
@ -113,18 +114,31 @@ func (w *Webcam) Set(c config.Config) error {
|
|||
// Start will build the required arguments for ffmpeg and then execute the
|
||||
// command, piping video output where we can read using the Read method.
|
||||
func (w *Webcam) Start() error {
|
||||
br := w.cfg.Bitrate * 1000
|
||||
|
||||
args := []string{
|
||||
"-i", w.cfg.InputPath,
|
||||
"-f", "h264",
|
||||
"-r", fmt.Sprint(w.cfg.FrameRate),
|
||||
"-b:v", fmt.Sprint(br),
|
||||
"-s", fmt.Sprintf("%dx%d", w.cfg.Width, w.cfg.Height),
|
||||
}
|
||||
|
||||
switch w.cfg.InputCodec {
|
||||
default:
|
||||
return fmt.Errorf("revid: invalid input codec: %v", w.cfg.InputCodec)
|
||||
case codecutil.H264:
|
||||
args = append(args,
|
||||
"-f", "h264",
|
||||
"-maxrate", fmt.Sprint(br),
|
||||
"-bufsize", fmt.Sprint(br/2),
|
||||
)
|
||||
case codecutil.MJPEG:
|
||||
args = append(args,
|
||||
"-f", "mjpeg",
|
||||
)
|
||||
}
|
||||
|
||||
br := w.cfg.Bitrate * 1000
|
||||
args = append(args,
|
||||
"-b:v", fmt.Sprint(br),
|
||||
"-maxrate", fmt.Sprint(br),
|
||||
"-bufsize", fmt.Sprint(br/2),
|
||||
"-s", fmt.Sprintf("%dx%d", w.cfg.Width, w.cfg.Height),
|
||||
"-",
|
||||
)
|
||||
|
||||
|
|
|
@ -191,7 +191,15 @@ func (r *Revid) reset(c config.Config) error {
|
|||
panic("unknown input codec for raspivid input")
|
||||
}
|
||||
case config.InputFile, config.InputV4L:
|
||||
st = mts.EncodeH264
|
||||
switch r.cfg.InputCodec {
|
||||
case codecutil.H264:
|
||||
st = mts.EncodeH264
|
||||
case codecutil.MJPEG:
|
||||
st = mts.EncodeMJPEG
|
||||
encOptions = append(encOptions, mts.PacketBasedPSI(int(r.cfg.MinFrames)))
|
||||
default:
|
||||
panic("unknown input codec for v4l or input file input")
|
||||
}
|
||||
case config.InputRTSP:
|
||||
switch r.cfg.InputCodec {
|
||||
case codecutil.H265:
|
||||
|
@ -329,7 +337,12 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
|||
|
||||
case config.InputV4L:
|
||||
r.input = webcam.New(r.cfg.Logger)
|
||||
r.lexTo = h264.Lex
|
||||
switch r.cfg.InputCodec {
|
||||
case codecutil.H264:
|
||||
r.lexTo = h264.Lex
|
||||
case codecutil.MJPEG:
|
||||
r.lexTo = mjpeg.Lex
|
||||
}
|
||||
|
||||
case config.InputFile:
|
||||
r.input = file.New()
|
||||
|
|
Loading…
Reference in New Issue