如何在我的ffmpeg流中获取nginx rtmp服务器的音频?

时间:2013-11-26 05:11:48

标签: flash audio nginx stream ffmpeg

我目前有一个nginx服务器设置,带有用于视频流的rtmp插件。我正在使用ffmpeg进行流式传输,然后使用adobe flash player在网络浏览器上显示流。

我有成功的视频流,但我无法获得音频。

这是我用来启动流的ffmpeg命令

ffmpeg -f video4linux2 -s 320x240 -r 16 -i /dev/video0 -f alsa -i hw:0 -an -f flv rtmp://123.456.789.51:31002/rover/mystream

然后流转到在此conf文件上运行的nginx

worker_processes  1;

error_log  logs/user/error.log debug;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 31002;

        application rover {
            live on;
            #meta copy;
            #interleave on;
            allow publish all;
            allow play all;

            hls on;
            #record keyframes;
            #record_path /tmp;
            #record_max_size 128K;
            #record_interval 30s;
            #record_suffix .this.is.flv;

            #on_publish http://localhost:8080/publish;
            #on_play http://localhost:8080/play;
            #on_record_done http://localhost:8080/record_done;
        }
    }
}

http {
    server {
        listen      26360;

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root nginx-rtmp-module-master/;
        }

        location /control {
            rtmp_control all;
        }

        #location /publish {
        #    return 201;
        #}

        #location /play {
        #    return 202;
        #}

        #location /record_done {
        #    return 203;
        #}

        location /rtmp-publisher {
            root /path/to/test;
        }

        location / {
            root nginx-rtmp-module-master/test/www;
        }
    }
}

然后我使用此设置为adobe flash player和strobe media player从浏览器访问流。

<object width="470" height="320">
    <param name="movie" value="http://osmf.org/dev/2.0gm/StrobeMediaPlayback.swf">
    </param>
    <param name="flashvars" value="src=rtmp%3A%2F%2F184.173.103.51%3A31002%2Frover%2Fmystream&autoPlay=true"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <param name="wmode" value="direct"></param>
    <embed src="http://osmf.org/dev/2.0gm/StrobeMediaPlayback.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="direct" width="470" height="320" flashvars="src=rtmp%3A%2F%2F184.173.103.51%3A31002%2Frover%2Fmystream&autoPlay=true"></embed>
</object>

我可以获得一些关于如何获取音频的建议吗?我正在从我的网络摄像头流式传输视频,并从我的麦克风中指定音频。

1 个答案:

答案 0 :(得分:5)

你知道ffmpeg中的“-an”选项吗?如果您想要音频,则不应使用它。