我的问题是我正在建立一个需要实时视频流的网站。我们有一个来自 arvixe 的 VPS,安装了 red5,但我无法使用 rtmp 连接到 red5。我需要知道这是否是我的代码错误,或者我是否只需要帮助在我的操作脚本 3 中找到要连接的正确 rtmp 地址。
到目前为止,这是我的代码:
import flash.media.Camera;
import flash.media.Video;
import flash.media.Microphone;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;
import flash.display.MovieClip;
import flash.net.*;
import flash.text.*;
var nc:NetConnection = new NetConnection();
nc.connect("rtmp://198.58.95.110:1935/");
var ns:NetStream = new NetStream(nc);
var camera:Camera = Camera.getCamera();
var video:Video = new Video();
video.smoothing = true;
video.attachCamera(camera);
ns.attachCamera(camera);
ns.publish("cam1");
addChild(video);
然后我把它改成这样:
import flash.media.Camera;
import flash.media.Video;
import flash.media.Microphone;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;
import flash.display.MovieClip;
import flash.net.*;
import flash.text.*;
var nc:NetConnection = new NetConnection();
var ns:NetStream = new NetStream(nc);
var camera:Camera = Camera.getCamera();
var video:Video = new Video();
video.smoothing = true;
video.attachCamera(camera);
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://cam320.arvixevps.com:5080");
function netStatusHandler(event:NetStatusEvent):void {
if (event.info.code == "NetConnection.Connect.Success") {
ns.attachCamera(camera);
ns.publish("livecam1");
}
}
我尝试的下一个代码:
import flash.media.Camera;
import flash.media.Video;
import flash.media.Microphone;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;
import flash.display.MovieClip;
import flash.net.*;
import flash.text.*;
var nc:NetConnection = new NetConnection();
nc.connect("rtmp://cam320.arvixevps.com/webapps/oflaDemo");
var ns:NetStream = new NetStream(nc);
var camera:Camera = Camera.getCamera();
var video:Video = new Video();
video.smoothing = true;
video.attachCamera(camera);
nc.addEventListener(NetStatusEvent.NET_STATUS, publish);
addChild(video);
function publish(event:NetStatusEvent):void {
if (event.info.code == "NetConnection.Connect.Success"){
ns.attachCamera(camera);
ns.publish("cam1");
}
}
red5.log 文件如下所示:
2013-02-02 14:07:34,612 [main] INFO org.red5.server.Launcher - Red5 Server 0.9.0 $Rev: 4030 $ (http://code.google.com/p/red5/)
2013-02-02 14:07:34,726 [main] INFO o.s.c.s.FileSystemXmlApplicationContext - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@5ff06dc3: startup date [Sat Feb 02 14:07:34 PST 2013]; root of context hierarchy
2013-02-02 14:07:35,281 [main] INFO o.s.b.f.c.PropertyPlaceholderConfigurer - Loading properties file from class path resource [red5.properties]
2013-02-02 14:07:35,293 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@69d95da8: defining beans [placeholderConfig,red5.common,red5.core,context.loader,pluginLauncher,tomcat.server]; root of factory hierarchy
2013-02-02 14:07:35,326 [main] INFO o.s.c.s.FileSystemXmlApplicationContext - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@7cf01771: startup date [Sat Feb 02 14:07:35 PST 2013]; root of context hierarchy
2013-02-02 14:07:35,546 [main] INFO o.s.b.f.c.PropertyPlaceholderConfigurer - Loading properties file from class path resource [red5.properties]
2013-02-02 14:07:35,552 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1118fa47: defining beans [placeholderConfig,red5.server,jmxFactory,jmxAgent,serializer,deserializer,statusObjectService,rtmpCodecFactory,rtmptCodecFactory,remotingCodecFactory,streamableFileFactory,filePersistenceThread,sharedObjectService,streamService,providerService,consumerService,bandwidthFilter,schedulingService,warDeployService,remotingClient,object.cache,keyframe.cache,flv.impl,flvreader.impl,mp4reader.impl,mp3reader.impl,org.springframework.beans.factory.config.MethodInvokingFactoryBean#0,org.springframework.beans.factory.config.MethodInvokingFactoryBean#1,streamExecutor,playlistSubscriberStream,clientBroadcastStream]; root of factory hierarchy
2013-02-02 14:07:35,717 [main] WARN o.s.b.GenericTypeAwarePropertyDescriptor - Invalid JavaBean property 'enableRmiAdapter' being accessed! Ambiguous write methods found next to actually used [public void org.red5.server.jmx.JMXAgent.setEnableRmiAdapter(java.lang.String)]: [public void org.red5.server.jmx.JMXAgent.setEnableRmiAdapter(boolean)]
2013-02-02 14:07:35,717 [main] WARN o.s.b.GenericTypeAwarePropertyDescriptor - Invalid JavaBean property 'enableSsl' being accessed! Ambiguous write methods found next to actually used [public void org.red5.server.jmx.JMXAgent.setEnableSsl(java.lang.String)]: [public void org.red5.server.jmx.JMXAgent.setEnableSsl(boolean)]
2013-02-02 14:07:35,717 [main] WARN o.s.b.GenericTypeAwarePropertyDescriptor - Invalid JavaBean property 'enableMinaMonitor' being accessed! Ambiguous write methods found next to actually used [public void org.red5.server.jmx.JMXAgent.setEnableMinaMonitor(java.lang.String)]: [public void org.red5.server.jmx.JMXAgent.setEnableMinaMonitor(boolean)]
2013-02-02 14:07:36,400 [main] INFO org.red5.server.service.WarDeployer - War deployer service created
2013-02-02 14:07:36,493 [main] INFO o.s.c.s.FileSystemXmlApplicationContext - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@9c6a99d: startup date [Sat Feb 02 14:07:36 PST 2013]; parent: ApplicationContext 'red5.common'
2013-02-02 14:07:36,683 [main] INFO o.s.b.f.c.PropertyPlaceholderConfigurer - Loading properties file from class path resource [red5.properties]
2013-02-02 14:07:36,691 [main] WARN o.s.b.f.c.CustomEditorConfigurer - Passing PropertyEditor instances into CustomEditorConfigurer is deprecated: use PropertyEditorRegistrars or PropertyEditor class names instead. Offending key [java.net.SocketAddress; offending editor instance: org.apache.mina.integration.beans.InetSocketAddressEditor@77a9f87c
2013-02-02 14:07:36,695 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7bbf68a9: defining beans [customEditorConfigurer,placeholderConfig,rtmpMinaConnManager,rtmpHandler,rtmpMinaIoHandler,rtmpTransport,rtmpMinaConnection,rtmptConnManager,rtmptHandler,rtmptServlet,rtmptConnection,rtmpsMinaIoHandler,rtmpsTransport]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1118fa47
2013-02-02 14:07:36,718 [main] INFO o.r.s.net.rtmp.RTMPMinaTransport - RTMP Mina Transport bound to /0.0.0.0:1935
2013-02-02 14:07:36,719 [main] INFO o.r.s.net.rtmp.RTMPMinaTransport - RTMP Mina Transport Settings
2013-02-02 14:07:36,719 [main] INFO o.r.s.net.rtmp.RTMPMinaTransport - Connection Threads: 4
2013-02-02 14:07:36,719 [main] INFO o.r.s.net.rtmp.RTMPMinaTransport - I/O Threads: 16
2013-02-02 14:07:36,785 [main] INFO o.r.s.net.rtmp.RTMPMinaTransport - TCP No Delay: true
2013-02-02 14:07:36,785 [main] INFO o.r.s.net.rtmp.RTMPMinaTransport - Receive Buffer Size: 65536
2013-02-02 14:07:36,785 [main] INFO o.r.s.net.rtmp.RTMPMinaTransport - Send Buffer Size: 271360
2013-02-02 14:07:36,795 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7bbf68a9: defining beans [customEditorConfigurer,placeholderConfig,rtmpMinaConnManager,rtmpHandler,rtmpMinaIoHandler,rtmpTransport,rtmpMinaConnection,rtmptConnManager,rtmptHandler,rtmptServlet,rtmptConnection,rtmpsMinaIoHandler,rtmpsTransport]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1118fa47
2013-02-02 14:07:36,796 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@69d95da8: defining beans [placeholderConfig,red5.common,red5.core,context.loader,pluginLauncher,tomcat.server]; root of factory hierarchy
2013-02-02 14:07:36,796 [main] INFO o.s.c.s.FileSystemXmlApplicationContext - Closing ApplicationContext 'red5.common': startup date [Sat Feb 02 14:07:35 PST 2013]; root of context hierarchy
2013-02-02 14:07:36,796 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1118fa47: defining beans [placeholderConfig,red5.server,jmxFactory,jmxAgent,serializer,deserializer,statusObjectService,rtmpCodecFactory,rtmptCodecFactory,remotingCodecFactory,streamableFileFactory,filePersistenceThread,sharedObjectService,streamService,providerService,consumerService,bandwidthFilter,schedulingService,warDeployService,remotingClient,object.cache,keyframe.cache,flv.impl,flvreader.impl,mp4reader.impl,mp3reader.impl,org.springframework.beans.factory.config.MethodInvokingFactoryBean#0,org.springframework.beans.factory.config.MethodInvokingFactoryBean#1,streamExecutor,playlistSubscriberStream,clientBroadcastStream]; root of factory hierarchy
2013-02-02 14:09:12,350 [NioProcessor-1] INFO o.red5.server.net.rtmp.RTMPHandler - Connecting to: [WebScope@218c6982 Depth = 1, Path = '/default', Name = 'installer']
2013-02-02 14:09:39,316 [NioProcessor-1] INFO o.red5.server.net.rtmp.RTMPHandler - Connecting to: [WebScope@218c6982 Depth = 1, Path = '/default', Name = 'installer']
2013-02-02 14:15:10,259 [NioProcessor-1] INFO o.red5.server.net.rtmp.RTMPHandler - Connecting to: [WebScope@218c6982 Depth = 1, Path = '/default', Name = 'installer']
2013-02-02 14:34:34,089 [NioProcessor-1] INFO o.red5.server.net.rtmp.RTMPHandler - Scope webapps/oflaDemo not found on cam320.arvixevps.com
2013-02-02 14:34:36,935 [Red5_Scheduler_Worker-11] WARN o.r.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection from 184.63.74.33 : 11053 to cam320.arvixevps.com (in: 3433 out 3266 ), with id 415926013 due to long handshake
2013-02-02 14:34:55,728 [NioProcessor-1] INFO o.red5.server.net.rtmp.RTMPHandler - Scope webapps/oflaDemo not found on cam320.arvixevps.com
2013-02-02 14:34:58,998 [Red5_Scheduler_Worker-12] WARN o.r.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection from 184.63.74.33 : 11081 to cam320.arvixevps.com (in: 3433 out 3266 ), with id 814254349 due to long handshake
2013-02-02 15:59:32,847 [NioProcessor-1] INFO o.red5.server.net.rtmp.RTMPHandler - Scope webapps/oflaDemo not found on cam320.arvixevps.com
2013-02-02 15:59:35,845 [Red5_Scheduler_Worker-10] WARN o.r.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection from 184.63.74.33 : 13181 to cam320.arvixevps.com (in: 3433 out 3266 ), with id 2104928456 due to long handshake
2013-02-02 16:00:27,050 [NioProcessor-1] INFO o.red5.server.net.rtmp.RTMPHandler - Scope webapps/oflaDemo not found on cam320.arvixevps.com
2013-02-02 16:00:30,974 [Red5_Scheduler_Worker-11] WARN o.r.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection from 184.63.74.33 : 13226 to cam320.arvixevps.com (in: 3433 out 3266 ), with id 9885998 due to long handshake
在将网络连接和网络流代码添加到我的操作脚本之前,仍然没有运气让它工作以及网络摄像头曾经出现的位置。当然,我一直试图弄清楚几天,但没有运气。我认为问题出在 nc.connect("rtmp://cam320.arvixevps.com:5080"); 但不确定 red5 的默认 rtmp 的正确地址是什么,所以不知道该放什么。另外我不确定我的代码中是否有任何错误,因为我已经很久没有使用动作脚本了。不幸的是,我有一个截止日期来建立这个网站,而且我的时间不多了。但如果有人能至少指出我正确的方向或告诉我我做错了什么,我可以修复它并完成这个网站。哦,VPS 正在运行 linux centos 5。我希望有人可以在这里帮助我。这个 red5 rtmp 连接问题让我很生气。我只想知道如何解决这个问题并使其正确连接到 red5 而无需在 flex 中创建 webapp。我应该能够使用 Actionscript3 连接到 red5 然后流式传输实时视频,而不必使用 flex 创建应用程序。我应该说,除了 red5 和我的动作脚本之外,我还需要什么来流式传输实时网络摄像头视频吗?在 cam320.arvixevps.com 上找不到范围 weapps/oflaDemo 的真正含义是什么?