Skip to content

Commit

Permalink
Fix pix_fmt yuv420p for hardware transcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Oct 15, 2023
1 parent e367940 commit f74c709
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions internal/ffmpeg/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## Transcoding pix_fmt

convert `yuvj420p` to `yuv420p`

- `h264_vaapi` - not supported, `scale_vaapi` should be used
- `h264_v4l2m2m` - supported, should be set, or fail
- `h264_nvenc` - supported, may be set, or warning
- `h264_qsv` - supported, may be set, or warning
- `h264_videotoolbox` - not supported, will get warning anyway

## FFplay output

[FFplay](https://stackoverflow.com/questions/27778678/what-are-mv-fd-aq-vq-sq-and-f-in-a-video-stream) `7.11 A-V: 0.003 fd= 1 aq= 21KB vq= 321KB sq= 0B f=0/0`:
Expand Down
6 changes: 3 additions & 3 deletions internal/ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ var defaults = map[string]string{
"mjpeg/vaapi": "-c:v mjpeg_vaapi",

// hardware Raspberry
"h264/v4l2m2m": "-c:v h264_v4l2m2m -g 50 -bf 0",
"h264/v4l2m2m": "-c:v h264_v4l2m2m -g 50 -bf 0 -pix_fmt:v yuv420p",
"h265/v4l2m2m": "-c:v hevc_v4l2m2m -g 50 -bf 0",

// hardware NVidia on Linux and Windows
// preset=p2 - faster, tune=ll - low latency
"h264/cuda": "-c:v h264_nvenc -g 50 -bf 0 -profile:v high -level:v auto -preset:v p2 -tune:v ll",
"h264/cuda": "-c:v h264_nvenc -g 50 -bf 0 -profile:v high -level:v auto -preset:v p2 -tune:v ll -pix_fmt:v yuv420p",
"h265/cuda": "-c:v hevc_nvenc -g 50 -bf 0 -profile:v high -level:v auto",

// hardware Intel on Windows
"h264/dxva2": "-c:v h264_qsv -g 50 -bf 0 -profile:v high -level:v 4.1 -async_depth:v 1",
"h264/dxva2": "-c:v h264_qsv -g 50 -bf 0 -profile:v high -level:v 4.1 -async_depth:v 1 -pix_fmt:v yuv420p",
"h265/dxva2": "-c:v hevc_qsv -g 50 -bf 0 -profile:v high -level:v 5.1 -async_depth:v 1",
"mjpeg/dxva2": "-c:v mjpeg_qsv -profile:v high -level:v 5.1",

Expand Down

0 comments on commit f74c709

Please sign in to comment.