diff --git a/ffmpeg/snapshot.go b/ffmpeg/snapshot.go index 7cca08c..df3e4fe 100644 --- a/ffmpeg/snapshot.go +++ b/ffmpeg/snapshot.go @@ -16,7 +16,8 @@ func snapshot(width, height uint, inputDevice, inputFilename string) (*image.Ima fileName := fmt.Sprintf("snapshot_%s.jpeg", time.Now().Format(time.RFC3339)) filePath := path.Join(os.TempDir(), fileName) - arg := fmt.Sprintf("-f %s -framerate 30 -i %s -s %dx%d -frames:v 1 %s", inputDevice, inputFilename, width, height, filePath) + // height "-2" keeps the aspect ratio + arg := fmt.Sprintf("-f %s -framerate 30 -i %s -vf scale=%d:-2 -frames:v 1 %s", inputDevice, inputFilename, width, filePath) args := strings.Split(arg, " ") cmd := exec.Command("ffmpeg", args[:]...) diff --git a/ffmpeg/stream.go b/ffmpeg/stream.go index 46b53af..4a6c210 100644 --- a/ffmpeg/stream.go +++ b/ffmpeg/stream.go @@ -47,7 +47,8 @@ func (s *stream) start(video rtp.VideoParameters, audio rtp.AudioParameters) err " -an" + fmt.Sprintf(" -codec:v %s", s.videoEncoder(video)) + " -pix_fmt yuv420p -vsync 2" + - fmt.Sprintf(" -video_size %dx%d", video.Attributes.Width, video.Attributes.Height) + + // height "-2" keeps the aspect ratio + fmt.Sprintf(" -video_size %d:-2", video.Attributes.Width) + fmt.Sprintf(" -framerate %d", video.Attributes.Framerate) + // 2018-08-18 (mah) Disable profile arguments because it cannot be parsed // [h264_omx @ 0x93a410] [Eval @ 0xbeaad160] Undefined constant or missing '(' in 'high'