E
E
ewowko12412021-05-28 14:10:35
Nginx
ewowko1241, 2021-05-28 14:10:35

How to set up a stream in two pass encoding?

At the moment we have a config

worker_priority -19;
user www-data;
worker_processes  auto;
events {
  worker_connections 8192;
  use epoll;
  multi_accept on;
}
rtmp_auto_push on;
rtmp {
  server {
    listen 1935;
    max_message 10M;
    chunk_size 8192;
    max_streams 32;
    sync 10ms;
    application potok<>{
      live on;
      record off;
      exec nice --20 ffmpeg -re -i rtmp://127.0.0.1/potok -vcodec libx264 -g 60 -preset slow  -b:v 7800k -maxrate 7800k -bufsize 7800k -s 1664x936 -x264opts nal-hrd=cbr:force-cfr=1:keyint=120:scenecut=0 -sws_flags lanczos  -acodec copy -r 60 -f flv rtmp://127.0.0.1:1935/transcode_potok;
    }
    application transcode_potok {
      live on;
      meta copy;
      push rtmp://сайт с ключем;
    }


Everything works great. But I would like to study two-pass coding.
No matter how much I try, the stream does not want to go.
exec nice --20 ffmpeg -re -i rtmp://127.0.0.1/potok -vcodec libx264 -g 60 -preset slow  -b:v 7800k -maxrate 7800k -bufsize 7800k -s 1664x936 -x264opts nal-hrd=cbr:force-cfr=1:keyint=120:scenecut=0 -sws_flags lanczos  -acodec copy -r 60-pass 1 -f flv /dev/null;
exec nice --20 ffmpeg -re -i rtmp://127.0.0.1/potok -vcodec libx264 -g 60 -preset slow  -b:v 7800k -maxrate 7800k -bufsize 7800k -s 1664x936 -x264opts nal-hrd=cbr:force-cfr=1:keyint=120:scenecut=0 -sws_flags lanczos  -acodec copy -r 60 -pass 2 -f flv rtmp://127.0.0.1:1935/transcode_potok;

Such sensation that the first line is started, and the second does not want. Toli nginx does not allow two encodings to run at once, or unknown forces.
If you separate these two lines into separate scripts and run them simultaneously, everything works. But I don't want to manually run them every time I start a stream

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question