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
|
cfg.InputCodec = codecutil.PCM
|
||||||
case "ADPCM":
|
case "ADPCM":
|
||||||
cfg.InputCodec = codecutil.ADPCM
|
cfg.InputCodec = codecutil.ADPCM
|
||||||
|
case "MJPEG":
|
||||||
|
cfg.InputCodec = codecutil.MJPEG
|
||||||
default:
|
default:
|
||||||
log.Log(logger.Error, pkg+"bad input codec argument")
|
log.Log(logger.Error, pkg+"bad input codec argument")
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||||
"bitbucket.org/ausocean/av/device"
|
"bitbucket.org/ausocean/av/device"
|
||||||
"bitbucket.org/ausocean/av/revid/config"
|
"bitbucket.org/ausocean/av/revid/config"
|
||||||
"bitbucket.org/ausocean/utils/logger"
|
"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
|
// Start will build the required arguments for ffmpeg and then execute the
|
||||||
// command, piping video output where we can read using the Read method.
|
// command, piping video output where we can read using the Read method.
|
||||||
func (w *Webcam) Start() error {
|
func (w *Webcam) Start() error {
|
||||||
|
br := w.cfg.Bitrate * 1000
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
"-i", w.cfg.InputPath,
|
"-i", w.cfg.InputPath,
|
||||||
"-f", "h264",
|
|
||||||
"-r", fmt.Sprint(w.cfg.FrameRate),
|
"-r", fmt.Sprint(w.cfg.FrameRate),
|
||||||
|
"-b:v", fmt.Sprint(br),
|
||||||
|
"-s", fmt.Sprintf("%dx%d", w.cfg.Width, w.cfg.Height),
|
||||||
}
|
}
|
||||||
|
|
||||||
br := w.cfg.Bitrate * 1000
|
switch w.cfg.InputCodec {
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("revid: invalid input codec: %v", w.cfg.InputCodec)
|
||||||
|
case codecutil.H264:
|
||||||
args = append(args,
|
args = append(args,
|
||||||
"-b:v", fmt.Sprint(br),
|
"-f", "h264",
|
||||||
"-maxrate", fmt.Sprint(br),
|
"-maxrate", fmt.Sprint(br),
|
||||||
"-bufsize", fmt.Sprint(br/2),
|
"-bufsize", fmt.Sprint(br/2),
|
||||||
"-s", fmt.Sprintf("%dx%d", w.cfg.Width, w.cfg.Height),
|
)
|
||||||
|
case codecutil.MJPEG:
|
||||||
|
args = append(args,
|
||||||
|
"-f", "mjpeg",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
args = append(args,
|
||||||
"-",
|
"-",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,15 @@ func (r *Revid) reset(c config.Config) error {
|
||||||
panic("unknown input codec for raspivid input")
|
panic("unknown input codec for raspivid input")
|
||||||
}
|
}
|
||||||
case config.InputFile, config.InputV4L:
|
case config.InputFile, config.InputV4L:
|
||||||
|
switch r.cfg.InputCodec {
|
||||||
|
case codecutil.H264:
|
||||||
st = mts.EncodeH264
|
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:
|
case config.InputRTSP:
|
||||||
switch r.cfg.InputCodec {
|
switch r.cfg.InputCodec {
|
||||||
case codecutil.H265:
|
case codecutil.H265:
|
||||||
|
@ -329,7 +337,12 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
||||||
|
|
||||||
case config.InputV4L:
|
case config.InputV4L:
|
||||||
r.input = webcam.New(r.cfg.Logger)
|
r.input = webcam.New(r.cfg.Logger)
|
||||||
|
switch r.cfg.InputCodec {
|
||||||
|
case codecutil.H264:
|
||||||
r.lexTo = h264.Lex
|
r.lexTo = h264.Lex
|
||||||
|
case codecutil.MJPEG:
|
||||||
|
r.lexTo = mjpeg.Lex
|
||||||
|
}
|
||||||
|
|
||||||
case config.InputFile:
|
case config.InputFile:
|
||||||
r.input = file.New()
|
r.input = file.New()
|
||||||
|
|
Loading…
Reference in New Issue