1
0

Updated README.md with working ffmpeg instructions.

Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
This commit is contained in:
James P. Ketrenos 2019-09-19 15:39:16 -07:00
parent 3caec6a48e
commit 6b667a3db0

161
README.md
View File

@ -23,103 +23,120 @@ docker run \
# Usage examples
Download stream:
## Download test content
You will need some test content to run the following tests. You can download a
test stream here:
```bash
mkdir media
cd media
wget https://fate-suite.libav.org/h264-conformance/AUD_MW_E.264
cd ..
```
**NOTE:** In each of the following, if you have a multi-card host system
you may need to change the qsv_device used by changing QSV_DEVICE
to whichever node is connected to your hardware.
You can find out the paths via:
```
ls -l /dev/dri/by-path/pci-*$(lspci | grep Intel.*Graphics | cut -d " " -f1)*
```
On my system, my Intel graphics adapter is /dev/dri/renderD129, so I use:
```
export QSV_DEVICE=/dev/dri/renderD129
[ ! -e media ] && mkdir media
wget -q -O media/AUD_MW_E.264 https://fate-suite.libav.org/h264-conformance/AUD_MW_E.264
```
## Decode
H264 video decode and save as raw file:
### Connect to container
```bash
QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128}
IN_FILE=AUD_WM_E.264
OUT_FILE=AUD_MW.yuv
HOST_MEDIA=$(pwd)/media
docker run \
--rm \
--device=/dev/dri \
--volume $(pwd)/media:/media \
--device /dev/dri \
--volume ${HOST_MEDIA}:/media \
-it \
intel-media-ffmpeg \
ffmpeg -hwaccel qsv -qsv_device ${QSV_DEVICE} \
-c:v h264_qsv -i /media/AUD_MW_E.264 \
ffmpeg \
-hwaccel qsv \
-qsv_device ${QSV_DEVICE:-/dev/dri/renderD128} \
-c:v h264_qsv \
-i /media/${IN_FILE} \
-vf hwdownload,format=nv12 -pix_fmt yuv420p \
/media/AUD_MW.yuv
-y \
/media/${OUT_FILE}
```
### Encode
## Encode
Encode a 10 frames of 720p raw input as H264 with 5Mbps using VBR mode:
```bash
QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128}
IN_FILE=AUD_MW.yuv
OUT_FILE=AUD_MW_E.h264
HOST_MEDIA=$(pwd)/media
docker run \
--rm \
--device /dev/dri \
--volume ${HOST_MEDIA}:/media \
-it \
intel-media-ffmpeg \
ffmpeg \
-loglevel debug \
-init_hw_device vaapi=va:${QSV_DEVICE:-/dev/dri/renderD128} \
-init_hw_device qsv=hw@va \
-filter_hw_device hw \
-f rawvideo \
-pix_fmt yuv420p \
-s:v 176x144 \
-i /media/${IN_FILE} \
-vf hwupload=extra_hw_frames=64,format=qsv \
-c:v h264_qsv \
-b:v 5M \
-frames:v 10 \
-y \
/media/${OUT_FILE}
```
## Transcode
### AVC (H.264) => HEVC (H.265) with 5Mbps using VBR
```bash
IN_FILE=AUD_MW_E.264
OUT_FILE=AUD_MW_E.hevc
HOST_MEDIA=$(pwd)/media
docker run \
--rm \
--device=/dev/dri \
--volume $(pwd)/media:/media \
--volume ${HOST_MEDIA}:/media \
-it \
intel-media-ffmpeg \
ffmpeg -loglevel debug -init_hw_device qsv=hw \
-filter_hw_device hw -f rawvideo -pix_fmt \
yuv420p -s:v 176x144 -i /media/AUD_MW.yuv -vf \
hwupload=extra_hw_frames=64,format=qsv \
-c:v h264_qsv -b:v 5M -frames:v 10 \
-y /media/AUD_MW_E.h264
ffmpeg \
-loglevel debug \
-hwaccel qsv \
-qsv_device ${QSV_DEVICE:-/dev/dri/renderD128} \
-c:v h264_qsv \
-i /media/"${IN_FILE}" \
-c:v hevc_qsv \
-b:v 5M \
-y \
/media/${OUT_FILE}
```
### Transcode
H264 decode && H265 encode with 5Mbps using VBR
### 1:N transcoding
```bash
QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128}
IN_FILE=AUD_MW_E.264
OUT_FILE_BASE=AUD_1N_
HOST_MEDIA=$(pwd)/media
docker run \
--rm \
--device=/dev/dri \
--volume $(pwd)/media:/media \
--volume ${HOST_MEDIA}:/media \
-it \
intel-media-ffmpeg \
ffmpeg -hwaccel qsv -qsv_device ${QSV_DEVICE} \
-c:v h264_qsv -i /media/AUD_MW_E.264 \
-c:v hevc_qsv -b:v 5M AUD_MW_E.hevc
```
1:N transcoding
```bash
QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128}
docker run \
--rm \
--device=/dev/dri \
--volume $(pwd)/media:/media \
-it \
intel-media-ffmpeg \
ffmpeg -hwaccel qsv -qsv_device ${QSV_DEVICE} \
-c:v h264_qsv -i /media/AUD_MW_E.264 \
ffmpeg \
-hwaccel qsv \
-qsv_device ${QSV_DEVICE} \
-c:v h264_qsv \
-i /media/${IN_FILE} \
-filter_complex "split=2[s1][s2]; \
[s1]scale_qsv=1280:720[o1]; \
[s2]vpp_qsv=framerate=60[o2]" \
-map [o1] -c:v h264_qsv -b:v 5M /media/5M.mp4 \
-map [o2] -c:v h264_qsv -b:v 4M /media/4M60FPS.h264
-map [o1] -c:v h264_qsv -b:v 5M /media/"${OUT_FILE_BASE}5M.mp4" \
-map [o2] -c:v h264_qsv -b:v 4M /media/"${OUT_FILE_BASE}4M60FPS.h264"
```
## Developing
@ -201,3 +218,29 @@ tag:
```bash
. MANIFEST ; git tag -f agama-${AGAMA_VERSION}
```
# Appendix A: Multicard
Most of the filters and drivers for ffmpeg will default to connecting to
/dev/dri/renderD128.
If you have multiple cards, the card you want to connect to might be exposed
on a different render interface.
You can configure which interface is used by setting the QSV_DEVICE environment
variable prior to running intel-docker (or by passing -e QSV_DEVICE to docker
if you run it manually.)
You can find out the correct path for your Intel Graphics card by running:
```
ls -l /dev/dri/by-path/pci-*$(lspci | grep Intel.*Graphics | cut -d " " -f1)*
```
If the interface is on /dev/dri/renderD129, set QSV_DEVICE as follows:
```
export QSV_DEVICE=/dev/dri/renderD129
```