One-stop transcoding, on-demand, live, time-shifting playback services, greatly simplifies the development and integration work. The vod version mainly includes uploading, transcoding and distribution. The live version mainly includes: live broadcast, video, live broadcast support RTMP input, RTMP/HLS/HTTP-FLV distribution output; Videos can be saved for a customized duration, retrieved and downloaded. Provides rich secondary development interface, jSON-based packaging and HTTP call. Provides security guarantees such as broadcast and push stream authentication. Provides user and permission management configurations.

One, quick installation

  1. Download address
  2. Download the installation package for the required environment
  3. Decompress the installation package
  4. In Windows, double-click Liveqing. exe to start directly
  5. In Linux, decompress the directory and run./start.sh
  6. See: blog.csdn.net/Marvin1311/…

Note: The path cannot contain Chinese characters

Second, secondary development

In secondary development, you can invoke the streaming media login interface from the back-end login interface of your own service system to obtain the required SID or token

1. Closed Intranet use

In service use, if LiveQing is used only to provide video distribution capability and does not expose interface port 10080(the default port), you can directly disable interface authentication. The default user name and password for logging in to http://localhost:10080 are admin and admin. On the basic configuration page, switch interface Authentication.

2. Interconnect service systems

2.1 the cookie way

Note: HttpOnly = true Client apis (such as JavaScript) cannot access HTTP-only cookies. This restriction eliminates the threat of cookie theft through cross-site scripting (XSS).

  1. Connect to back-end business code, such as Java/PHP/Node.js
  2. If the LiveQing login interface is successfully invoked, sid will be written to the cookie requesting Headers
  3. Retrieve sid from cookie
  4. The SID is passed in request header cookies when other interfaces are called
  5. Content-Type:application/x-www-form-urlencoded
  6. Interface request path example: http://localhost:10080/login

2.1.1 Front-end JS Cross-domain request Example

The client does not need to display saving tokens to cookies. All interfaces that interact with the service need to add cross-domain configurations, such as xhrFields: {withCredentials: true} and crossDomain: true, if the server is configured to allow cross-domain configurations.

The following is an example of invoking the cross-domain login interface:

$.ajax({ type: "GET", url: "http://other-domain:10080/login", xhrFields: { withCredentials: true }, crossDomain: true, data: { username: 'admin', password: '21232f297a57a5a743894a0e4a801fc3' }, success: function(data) { console.log(data); }})Copy the code

Back-end code example: Java

2.1.2 obtain sid

import java.io.DataOutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; public class GetLoginSid { public static void main(String[] args) throws Exception { URL url = new URL("http://demo.liveqing.com:10080/login"); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); // Initiate a POST request and pass the username and password parameters (md5 encryption required). conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); String content = "username=admin&password=21232f297a57a5a743894a0e4a801fc3"; out.writeBytes(content); out.flush(); out.close(); Map<String, List<String>> headerFields = conn.getHeaderFields(); Set<String> headerFieldsSet = headerFields.keySet(); Iterator<String> hearerFieldsIter = headerFieldsSet.iterator(); while (hearerFieldsIter.hasNext()) { String headerFieldKey = hearerFieldsIter.next(); if ("Set-Cookie".equalsIgnoreCase(headerFieldKey)) { List<String> headerFieldValue = headerFields.get(headerFieldKey); for (String headerValue : headerFieldValue) { String[] fields = headerValue.split("; \\s*"); for (int j = 0; j < fields.length; j++) { if (fields[j].indexOf('=') > 0) { String[] f = fields[j].split("="); if ("Expires".equalsIgnoreCase(f[0])) { System.out.println("Expires:" + f[1]); } else if ("Max-Age".equalsIgnoreCase(f[0])) { System.out.println("Max-Age:" + f[1]); }else if ("sid".equalSignoRecase (f[0])) {// Get sid system.out.println ("sid:" + f[1]); } } } } } } } }Copy the code

Run the following

2.1.3 Invoking other Interfaces with SID

import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class RequestOtherAPI { public static void main(String[] args) throws Exception { URL url = new URL("http://demo.liveqing.com:10080/live/list"); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); SetRequestProperty ("Cookie","sid=Hwsd2R;") ); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); String content = "start=0&limit=10"; out.writeBytes(content); out.flush(); out.close(); conn.connect(); StringBuffer sbf = new StringBuffer(); InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String strRead = null; while ((strRead = reader.readLine()) ! = null) { sbf.append(strRead); sbf.append("\r\n"); } reader.close(); System.out.println(sbf.toString()); }}Copy the code

2.2 token way

  1. Invoke the login interface to obtain the token
  2. Content-Type:application/x-www-form-urlencoded
  3. Other interface calls pass additional token input arguments

Code example: Java

2.2.1 access token

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class GetLoginToken {

public static void main(String[] args) throws Exception {
        URL url = new URL("http://localhost:10080/login");
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
		conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestMethod("POST");      
        conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
        DataOutputStream out = new DataOutputStream(conn.getOutputStream());  
        String content = "username=admin&password=21232f297a57a5a743894a0e4a801fc3";
        out.writeBytes(content); 
        out.flush();  
        out.close();
        
        conn.connect();
        StringBuffer sbf = new StringBuffer();
        InputStream is = conn.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        String strRead = null;
        while ((strRead = reader.readLine()) != null) {
            sbf.append(strRead);
            sbf.append("\r\n");
        }
        reader.close();
        System.out.println(sbf.toString());
    }
  }
Copy the code

Run the following

2.2.2 Invoking Other Interfaces with a Token

When other interfaces call, the token input parameter is appended

import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class RequestOtherAPIByToken { public static void main(String[] args) throws Exception { URL url = new URL("http://localhost:10080/live/list"); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); String content = "start=0&limit=10&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Mzc3NzExNTAsInB3IjoiMjEyMzJmMjk3YTU3YTVhNzQzODk 0YTBlNGE4MDFmYzMiLCJ0bSI6MTUzNzY4NDc1MCwidW4iOiJhZG1pbiJ9.b1U-R-_HVKV9reWRD50327B1ztUqs3gowUGi_lDzlmU"; out.writeBytes(content); out.flush(); out.close(); conn.connect(); StringBuffer sbf = new StringBuffer(); InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String strRead = null; while ((strRead = reader.readLine()) ! = null) { sbf.append(strRead); sbf.append("\r\n"); } reader.close(); System.out.println(sbf.toString()); }}Copy the code

Run the following