ffplay how to play HEVC or H264 with hardware acceleration on Mac?
In FFmpeg, I can specific encoder by -c:v h264_videotoolbox
to use Videotoolbox with GPU acceleration to do transcode.
But I don't know what commands I should give to ffplay to utilize Videotoolbox with hardware decoding?
ffplay -hwaccel_flags my.mp4 // no GPU usage up
ffplay -pixel_format videotoolbox_vld my.mp4 // Option pixel_format not found
ffplay -decoders | grep "box" // only decoders with (AudioToolbox) shows
ffplay -buildconf // the --enable-videotoolbox is showed
Solution 1:
You can pipe the result of ffmpeg
to ffplay
. I tested on an 1080p video using VAAPI acceleration, the CPU rate decreased about 10% altogether.
See HWAccelIntro here. It talks about ffmpeg
, but you can pipe the result of ffmpeg
to ffplay
.
For example, play test.mp4 using VAAPI on Linux:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i test.mp4 \
-vcodec rawvideo -acodec copy -f matroska - | ffplay -i -
Use rawvideo
for video encoding, and use -f
to specify a container. Videotoolbox
should be similar. If you managed to decode a video with Videotoolbox
in ffmpeg, just pipe to ffplay
in this way.