r/ffmpeg • u/News8000 • Nov 17 '25
Bitrate change and scaling transcoding, using Intel iGPU not CPU?
I have 4K 30fps DJI drone videos that come in at 120Mbps bitrate, which makes huge files.
They're 3840 × 2160 H.264 (High Profile) 122566 kbps mp4.
I'm needing more like 2560x1440 at 10-40Mbps max, not 120Mbps. I have to set jellyfin player transcoding down to under 20Mbps bitrate for it to play on most of my not so new machines.
I can set bitrate and scale with ffmpeg using CPU only, using the following:
ffmpeg -i input.mp4 -vf "scale=2560x1440" -b:v 40M output.mp4
The resulting output.mp4 plays nice and looks nice. On anything.
BUT CPU TRANSCODING SO SLOW, cpu fan working hard. i5-10500T machine.
I want to transcode via the iGPU not CPU. I got the following to work and it codes at like 5x the rate the CPU does:
ffmpeg -init_hw_device vaapi=foo:/dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device foo -i input.mp4 -filter_hw_device foo -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi output.mp4
BUT the output has same issue, huge size, bitrate, and still 4K.
How can ffmpeg combine scaling down, and setting a lower bitrate, with the iGPU instead?
I've spent countless hours looking up and trying possible solutions and running out of steam after the latest push. I just want to have a cli tool to quickly bulk copy/transpose the DJI 3.8GB chunks into a more manageable size.
TIA all!
EDIT adding info:
Ubuntu 24.04.3 LTS, i5-10500T
ffmpeg version 7.1.1 via GIT repo
2
u/Erazael Nov 18 '25
Make sure your build supports the encoder
ffmpeg -encoders | grep -E "(qsv|vaapi|nvenc|amf|videotoolbox)"
Then something like this should work
ffmpeg -hwaccel qsv -i input.mkv -vf "scale_qsv=2560:1440:format=nv12" -c:v hevc_qsv -preset medium -b:v 20M -maxrate 20M -bufsize 40M -c:a copy output_1440p_20mbps.mkv
1
u/News8000 Nov 18 '25
OP UPDATE:
Just discovered this gem down the rabbithole: https://www.shutterencoder.com/ and installed their deb package on my Ubuntu 24.04 desktop.
Couldn't enable any GPU decoding, but in another rabbithole found out the Shutter Encoder version of jellyfin wasn't doing its job, so overwrote that executable with my up-to-date /usr/bin/ffmpeg install from github deb package v7.1.1. and set vaapi decoder. It's working!
Command string generated by shutter encoder:
-strict experimental -hide_banner -threads 0 -hwaccel vaapi -i "/raid1/media/jellyfin/DJI/20250901/DJI_20250901182033_0002_D.MP4" -r 60000/1001 -c:v libx264 -b:v 40000k -profile:v high -filter_complex "[0:v]scale=2560:1440[out]" -map "[out]" -c:a aac -ar 48k -b:a 256k -map a? -pix_fmt yuv420p -sws_flags bicubic -metadata creation_time="2025-11-18T19:36:02.779500519Z" -y "/raid1/media/jellyfin/DJI/20250901/encoded/DJI_20250901182033_0002_D_H.265-1440p40fr.mp4"
3.8GB input 120Mbps 4K
0.997GB output 40Mbps 2K
This is good.
Now to try and understand what's going on in that command lol...
BTW haven't tried yet at a terminal, just grabbed the terminal output Shutter Encoder offers. But before messing with this string I'd like to know what each command segment does!
Would also like to get QSV option working, no luck first try, went to vaapi for this.
1
u/pigers1986 Nov 17 '25
You should talk with folks over r/jellyfinn for transcoding
"4K 30fps DJI drone videos that come in at 120fps" - nope , nope.EXE - It's 30 or 120 FPS ?
DJI is 120 FPS at source afaik.
iGPU makes sense only for transcoding - for storage CPU (software) encoding is viable solution.
I tend to re-encode high mbps videos with handbrake for playback (as I have low power nas unit) on my high power PC - disk space is cheap , power not really.
1
u/Sopel97 Nov 18 '25
you can chain filters
1
u/ScratchHistorical507 Nov 18 '25
1440p30 in H264 would yield you up to ~ 30 Mbit/s, depending on your footage (i.e. how busy is it?). If you went with VP9 or AV1 it would be even less. So that shouldn't be an issue. If vaapi is properly set up (you can check that with vainfo, which on Debian-based distros is included in the package of the same name), try something like this:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i input.mp4 -c:v h264_vaapi -vf scale_vaapi=2560:-2:format=nv12 -rc_mode VBR -b:v 30M -maxrate 40M -c:a copy output.mp4With this you do all processing in hardware and have more than enough bitrate to handle everything. At least I very much doubt you have footage that will require more than 40 Mbit/s at 1440p30. If the footage isn't all too busy, you might even get away with setting the bitrate to about 20-25 Mbit/s, I wouldn't go lower than that on h264, not with hardware encoding as that can't make use of multipass encoding.
1
u/Atijohn Nov 17 '25
you can use the
opencl_programfilter to write basically any transformation that will be run on the GPU, e.g.:1
u/transdimensia Nov 18 '25
10500 can use hevc_qsv and h264_qsv for encoding and some basic operations that might suit what you are trying, your ffmpeg version has to have it enabled. The version jellyfin uses internally should have it already turned on.
1
u/[deleted] Nov 18 '25
[removed] — view removed comment