-1

我有一个使用 nginx 运行的 RTMP 服务器,它将实时流记录到 flv 文件中,但我想做的是将文件记录为 mp4 格式......这是我的 nginx.conf 文件:

I want when I rtmp livestream going I can convert it from flv to an mp4 file... How can I do this? Here is my nginx.conf file:

​</p>

user  www-data;  
worker_processes auto;  
rtmp_auto_push on;  
events {  
    worker_connections  1024;  
}  
rtmp {  
    server {  
        listen 1935;  
        chunk_size 4096;  
        application s9-live {  
            exec ffmpeg -i rtmp://localhost:1935/s9-rtmp/$name  
            \-c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2500k -f flv -g 30 -r 30 -s 1280x720 -preset superfast -profile:v baseline rtmp://localhost:1935/s9-rtmp/$name;  
            live on;  
            meta copy;  
            hls_cleanup off;  
            record all;  
            record_path /rec/videos;  
            record_max_size 1k;  
            record_unique on;  
            record_suffix %y%m%d_%H%M%S.flv;  
            exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4;  
        }  
    }  
}  
http {   
    default_type application/octet-stream;  
   
    server {   
        listen 8000;   
        location /tv {   
            root /tmp/hls;   
        }  
 \# This URL provides RTMP statistics  
        location /stats {  
            rtmp_stat all;  
        }  
        location /control {  
            rtmp_control all;  
        }  
    }  
   
    types {  
        application/vnd.apple.mpegurl m3u8;  
        video/mp2t ts;  
        text/html html;  
    }   
}

该应用程序运行良好,没有任何问题,我想知道的是如何获取 mp4 或从 flv 文件转换的录制流。

4

1 回答 1

0

您已经在配置中拥有将 flv 转换为 mp4 的命令:

exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4;

录制打开时,您只会看到一个 flv 文件。录制完成后,exec_record_done触发并将 flv 转换为 mp4 文件。然后,您的文件夹中将有一个 flv 和一个相应的 mp4。

于 2021-02-12T10:56:21.373 回答