Forráskód Böngészése

优化参数,调整代码,支持console 启动

zhzhenqin 1 éve
szülő
commit
34c0c744d8

+ 1 - 0
.gitignore

@@ -24,3 +24,4 @@ target/
 # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
 hs_err_pid*
 /*.iml
+vedio

+ 29 - 0
pom.xml

@@ -37,6 +37,8 @@
         <fastjson.version>1.2.4</fastjson.version>
         <javacv.version>1.5.4</javacv.version>
         <expiringmap.version>0.5.9</expiringmap.version>
+
+        <java.main.class>com.coyee.stream.StreamApplication</java.main.class>
     </properties>
     <parent>
         <groupId>org.springframework.boot</groupId>
@@ -120,6 +122,33 @@
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.6.0</version>
+                <configuration>
+                    <mainClass>${java.main.class}</mainClass>
+                    <arguments>
+                    </arguments>
+                    <!--
+                    <executable>java</executable>
+                    <arguments>
+                        <argument>-Xmx64m</argument>
+                        <argument>-classpath</argument>
+                        <classpath />
+                        <argument>${java.main.class}</argument>
+                    </arguments>
+                    -->
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>java</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>

+ 1 - 1
src/main/java/com/coyee/stream/config/StreamServerConfig.java

@@ -48,6 +48,6 @@ public class StreamServerConfig {
     /**
      * 当m3u8文件超过时间没有更新时,则认为已过期
      */
-    private long m3u8ExpireMills=1000*60*3;
+    private long m3u8ExpireMills=1000 * 60 * 3;
 
 }

+ 10 - 7
src/main/resources/application.yml

@@ -1,3 +1,10 @@
+server:
+  port: 8081
+  tomcat:
+    uri-encoding: UTF-8
+  servlet:
+    context-path: /stream
+
 spring:
   profiles:
     active: dev
@@ -15,15 +22,11 @@ spring:
     multipart:
       maxFileSize: 50Mb
       maxRequestSize: 50Mb
-server:
-  port: 8081
-  tomcat:
-    uri-encoding: UTF-8
-  servlet:
-    context-path: /stream
+
+# Stream 服务器
 streamserver:
   expireMills: -1
-  hlsStoreDir: /home/hls
+  hlsStoreDir: /Volumes/Study/Work/beizhi/coyee-stream-converter/vedio
   hlsTime: 5
   hlsWrap: 10
   hlsListSize: 8

+ 14 - 14
src/main/resources/static/flv.html

@@ -1,20 +1,20 @@
 <!DOCTYPE html>
 <html lang="en" dir="ltr">
 <head>
-    <meta charset="utf-8">
-    <title>rtmp测试</title>
-    <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
-    <script src="https://cdn.bootcss.com/flv.js/1.4.0/flv.min.js"></script>
+  <meta charset="utf-8">
+  <title>rtmp测试</title>
+  <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
+  <script src="https://cdn.bootcss.com/flv.js/1.4.0/flv.min.js"></script>
 </head>
 <body>
-<div>
+  <div>
     <video id="rtmpPlayer"
            class="video-js vjs-default-skin vjs-big-play-centered" controls
            preload="auto" autoplay="autoplay" width="500" height="400"
            data-setup='{}'>
     </video>
-</div>
-<div>
+  </div>
+  <div>
     <h3>1.地址注册</h3>
     <p>
         <label>源地址:</label>
@@ -22,13 +22,13 @@
         <input type="button" onclick="register()" value="注册"/>
     </p>
     <p><label>编码:</label><label id="keyText"></label></p>
-</div>
-<div>
+  </div>
+  <div>
     <h3>2.播放RTMP流</h3>
     <input type="text" size="120" value="" id="rtmpUrl"/>
     <input type="button" onclick="playRtmp()" value="播放"/>
-</div>
-<script type="text/javascript">
+  </div>
+  <script type="text/javascript">
     var baseUrl = window.location.href.split("/static/")[0];
 
     function register() {
@@ -38,12 +38,12 @@
             return;
         }
         var url = baseUrl + "/converter/register";
-        $.post(url, {url: sourceUrl,format:"flv"}, function (json) {
+        $.post(url, {url: sourceUrl, format: "flv"}, function (json) {
             if (json.status == 200) {
                 var key = json.data;
                 $("#keyText").text(key);
                 $("#key").val(key);
-                $("#rtmpUrl").val(baseUrl+"/live/"+key+".flv");
+                $("#rtmpUrl").val(baseUrl + "/live/" + key + ".flv");
             } else {
                 alert("错误:" + json.message);
             }
@@ -68,6 +68,6 @@
             flvPlayer.play();
         }
     }
-</script>
+  </script>
 </body>
 </html>

+ 14 - 14
src/main/resources/static/hls.html

@@ -4,17 +4,17 @@
     <meta charset="utf-8">
     <title>HLS测试</title>
     <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
-    <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
+    <script src="https://cdn.bootcss.com/flv.js/1.4.0/flv.min.js"></script>
 </head>
 <body>
-<div>
+  <div>
     <video id="video"
-           class="video-js vjs-default-skin vjs-big-play-centered" controls
-           preload="auto" autoplay="autoplay" width="500" height="400"
-           data-setup='{}'>
+          class="video-js vjs-default-skin vjs-big-play-centered" controls
+          preload="auto" autoplay="autoplay" width="500" height="400"
+          data-setup='{}'>
     </video>
-</div>
-<div>
+  </div>
+  <div>
     <h3>1.地址注册</h3>
     <p>
         <label>源地址:</label>
@@ -22,13 +22,13 @@
         <input type="button" onclick="register()" value="注册"/>
     </p>
     <p><label>编码:</label><label id="keyText"></label></p>
-</div>
-<div>
+  </div>
+  <div>
     <h3>2.播放HLS流</h3>
     <input type="text" size="120" value="" id="hlsUrl"/>
     <input type="button" onclick="playHls()" value="播放"/>
-</div>
-<script type="text/javascript">
+  </div>
+  <script type="text/javascript">
     var baseUrl = window.location.href.split("/static/")[0];
 
     function register() {
@@ -38,12 +38,12 @@
             return;
         }
         var url = baseUrl + "/converter/register";
-        $.post(url, {url: sourceUrl,format:"hls"}, function (json) {
+        $.post(url, {url: sourceUrl, format: "hls"}, function (json) {
             if (json.status == 200) {
                 var key = json.data;
                 $("#keyText").text(key);
                 $("#key").val(key);
-                $("#hlsUrl").val(baseUrl+"/live/"+key+"/play.m3u8");
+                $("#hlsUrl").val(baseUrl + "/live/" + key + "/play.m3u8");
             } else {
                 alert("错误:" + json.message);
             }
@@ -65,6 +65,6 @@
             video.play();
         });
     }
-</script>
+  </script>
 </body>
 </html>