esup-pod

Arborescence des pages

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Paramétrage (optimisé) ffmpeg à utiliser dans Pod pour l'encodage GPU

Bloc de code
"""
FFMPEG SETTINGS LOCATE IN :
pod/video/encoding_settings.py
pod/video/encoding_gpu_settings.py
all settings can be overwritte in your settings locale
"""

FFMPEG_USE_GPU = True


FFMPEG_CMD_GPU = "ffmpeg -hwaccel_device 0 -hwaccel_output_format cuda -hwaccel_output_format cuda -hwaccel cuda" cuda"
FFMPEG_PRESET_GPU = "p6"
FFMPEG_LEVEL_GPU = 0

FFMPEG_INPUT_GPU = '-hide_banner -threads %(nb_threads)s -i "%(input)s" '

FFMPEG_LEVEL = 0
FFMPEG_PRESET = "p6"
FFMPEG_PROFILELIBX_GPU = "high"
FFMPEG_LIBX = "h264_nvenc"

FFMPEG_MP4_ENCODE_GPU = (
    '%(cut)s -map 0:v:0 %(map_audio)s -c:v %(libx)s  -vf "scale_cuda=-2:%(height)s:interp_algo=bicubic:format=yuv420p" '
    + "-preset %(preset)s -profile:v %(profile)s "
    + "-level %(level)s "
    + "-forced-idr 1 "
    + "-b:v %(maxrate)s -maxrate %(maxrate)s -bufsize %(bufsize)s -rc vbr -rc-lookahead 20 -bf 1 "
    + '-force_key_frames "expr:gte(t,n_forced*1)" '
    + '-c:a aac -ar 48000 -b:a %(ba)s -movflags faststart -y -fps_mode passthrough "%(output)s" '
)

FFMPEG_HLS_COMMON_PARAMS_GPU = (
    "%(cut)s "
    + "-c:v %(libx)s -preset %(preset)s -profile:v %(profile)s "
    + "-level %(level)s "
    + "-forced-idr 1 "
    + '-force_key_frames "expr:gte(t,n_forced*1)" '
    + "-c:a aac -ar 48000 "
)

FFMPEG_HLS_ENCODE_PARAMS_GPU = (
    '-vf "scale_cuda=-2:%(height)s:interp_algo=bicubic:format=yuv420p" -maxrateb:v %(maxrate)s -b:a:0maxrate %(bamaxrate)s -bufsize %(maxratebufsize)s -rc constqp -b:v 0kb:a:0 %(ba)s -rc vbr -rc-lookahead 20 -bf 1 -qp 32 -2pass 1 -multipass 2 -spatial-aq 1 -aq-strength 11-bf 1 '
    + "-hls_playlist_type vod -hls_time %(hls_time)s  -hls_flags single_file "
    + '-master_pl_name "livestream%(height)s.m3u8" '
    + '-y "%(output)s" '
)

FFMPEG_CREATE_THUMBNAIL_GPU = (
    '-vf "select=between(t\,50\,10%(duration)s)*eq(pict_type\,PICT_TYPE_I),thumbnail_cuda=2,scale_cuda=-2:720:interp_algo=bicubic:format=yuv420p,hwdownload,format=yuv420p" -frames:v 3%(nb_thumbnail)s -vsync vfr "%(output)s_%%04d.png"'
)

Info

La commande FFMPEG_CREATE_THUMBNAIL permet ici de ne garder des miniatures (3) qu'entre les secondes 5 et 10 sur des frames complètes (PICT_TYPE_I).

A adapter en fonction de vos besoins.

...

Bloc de code
cd /etc/init.d/
sudo -E wget https://raw.githubusercontent.com/celery/celery/main/extra/generic-init.d/celeryd
sudo chmod u+x /etc/init.d/celeryd
sudo vi /etc/default/celeryd

	CELERYD_NODES="worker5" # Nom du/des worker(s). Ajoutez autant de workers que de tache à executer en paralelle.
	DJANGO_SETTINGS_MODULE="pod.settings" # settings de votre Pod
	CELERY_BIN="/home/pod/.virtualenvs/django_pod3/bin/celery" # répertoire source de celery
	CELERY_APP="pod.main" # application où se situe celery
	CELERYD_CHDIR="/usr/local/django_projects/podv3" # répertoire du projet Pod (où se trouve manage.py)
	CELERYD_OPTS="--time-limit=86400 --concurrency=1 --max-tasks-per-child=1 --prefetch-multiplier=1" # options à appliquer en plus sur le comportement du/des worker(s)
	CELERYD_LOG_FILE="/var/log/celery/%N.log" # fichier log
	CELERYD_PID_FILE="/var/run/celery/%N.pid" # fichier pid
	CELERYD_USER="pod" # utilisateur système utilisant celery
	CELERYD_GROUP="pod" # groupe système utilisant celery
	CELERY_CREATE_DIRS=1 # si celery dispose du droit de création de dossiers
	CELERYD_LOG_LEVEL="INFO" # niveau d'information qui seront inscrit dans les logs

sudo /etc/init.d/celeryd start
workon django_pod3
celery -A pod.main worker -l info
tail -f /var/log/celery/worker5.log -n200

...