如何将RTMP nginx直播从Flv转换为mp4文件



我有一个使用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:

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;  
    }   
}

该应用程序运行良好,没有任何问题——只有在可能的情况下,我想知道的是如何从flv文件转换mp4或录制的流。

您已经在配置中有了将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。

最新更新