jrottenberg / ffmpeg

Docker build for FFmpeg on Ubuntu / Alpine / Centos / Scratch / nvidia / vaapi
https://hub.docker.com/r/jrottenberg/ffmpeg/
Apache License 2.0
1.39k stars 454 forks source link

Is threading within a container supported? #228

Open yafesdev opened 4 years ago

yafesdev commented 4 years ago

The following snippet takes around 10 minutes with the docker image, but only 2 mins with my local ffmpeg. I was wondering if docker isn't able to multi thread?

I tried as well passing --cpu=8 to docker's run command.

docker run -it -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg -y -i input.mp4 -c:v libaom-av1 -strict -2 -b:v 3000K -maxrate 6000K -bufsize 3000k -g 48 -keyint_min 48 -sc_threshold 0 -tile-columns 1 -tile-rows 0 -threads 8 -cpu-used 8 -passlogfile ffmpeg2pass-0.log -pass 2 output.webm
skj-dev commented 3 years ago

A container is just a process running on a host, so it can use all the available CPU resources unless specifically restricted. That context is for the host that the Docker Engine is running on. If you're running on a Linux host, then the container can use all the CPU resources since it's running natively. If you're running on a macOS or Windows host then Docker is actually running within a VM that Docker Desktop sets up. That VM can be assigned some number of CPUs up to the total number on the host. If, in that case, the Docker Desktop VM is assigned 2 CPUs, then that is the total amount of CPU resource that will be usable by any containers since it is within that VM that the containers are actually running.