百度智能云

All Product Document

          CDN

          Set the Video Drag and Drop

          Baidu Cloud supports the feature of dragging flv ang mp4 false traffic videos, meaning the video process bar dragging; after enabling dragging, the forward-to-origin rate can be reduced and the speed can be accelerated. This interface is used to set video drag parameters. (Note: This interface is a full interface, and you have to write the existing settings together when setting, otherwise the original configurations are overwritten.

          Principle introduction

          • MP4

            Baidu AI Cloud CDN supports pseudo-streaming playback of MP4 files. Usually these files have the extension of .mp4, .m4v and .m4a.

            In a typical Flash player (it may vary for different players), if you drag the progress bar, the player sends an HTTP(S) request with a specified time parameter in the query parameters of the request (usually the parameter name is start, in seconds), and the server responds to the video stream starting at this time. E.g.: http://example.com/elephants_dream.mp4?start=238.88 Similarly, you can also assign the end time (the parameter is normally named as end, with the unit of second), and the server responses the video content of the assigned range from start to end. E.g.: http://example.com/elephants_dream.mp4?start=238.88&end=555.55

            This helps your Flash player realize process bar dragging feature based on the server.

          • FLV

            Baidu AI Cloud CDN also supports pseudo-streaming playback of Flash Video (FLV) files. Usually these files have the extension of .flv.

            The pseudo-streaming mode of FLV files is different from MP4: FLV files are dragged by byte offset of the file.

            Usually (different players may be different), in the process that a user plays a FLV file in the FLash player, when the user drag the progress bar, the player sends a HTTPS (S) request, and the specified file byte offset parameter (usually parameter name is start, with the unit of byte) is carried in the query parameter of such request. The server responds with two different contents according to the configuration:

            • byte mode: The server responds to the file content starting from the byte specified by start in the original FLV file.
            • byteav mode: The server adds the first Video Tag and Audio Tag (usually Metadata) before the content specified by the start byte in the original FLV file as a response. You can reset the decoding parameters of the player because this mode contains Metadata.
              That is, byteav mode responds to two more tags (Metadata) than byte mode.
          Method Path Description
          PUT /v2/domain/{domain}/config?mediaDrag Set video drag parameter

          domain: CDN accelerated domain name.

          Request body

          Parameter Optional Type Description
          mediaDragConf Required MediaDragConf Video dragging settings

          MediaDragConf:

          Parameter Optional Type Description
          mp4 Optional MediaDrag Video drag setting of pseudo-streaming in mp4 type, if it is to cancel the setting, please do not bring this field.
          flv Optional MediaDrag Video drag setting of pseudo-streaming in flv type, if it is to cancel the setting, please do not bring this field.

          MediaDrag:

          Parameter Optional Type Description
          fileSuffix Optional list type, element type is String Baidu AI Cloud CDN supports the pseudo-streaming playback of MP4 files, and the extension of these files is .mp4, .m4v, and .m4a usually; therefore, the fileSuffix value is the set of file extensions, such as: [ "mp4 ", "m4v ", "m4a "], when type is mp4. fileSuffix is [ "mp4 "] by default; when type is flv, fileSuffix is [ "flv "] by default.
          startArgName Optional String Name of the start parameter, and the default is “start ". You can customize the parameter name, but it cannot be the same as ‘endArgName `.
          endArgName Optional String Name of the end parameter, and the default is “end ". You can customize the parameter name, but it cannot be the same as ‘startArgName `.
          dragMode Required string Drag in seconds for the mp4 type and in bytes for the flv type. For the flv type, you can select the “byteAV " or “byte” mode; for the mp4 type, you can only select the “second” mode

          Response code (Http Status Code)

          HTTP Status Code Description
          200 Success
          400 Update failures, parameter errors, etc.

          Request example1

          PUT /v2/domain/myself.baidu.com/config?mediaDrag HTTP/1.1 
          Host: cdn.baidubce.com 
          Content-Length: 130
          Content-Type: application/json
          
          { 
              "mediaDragConf":{ 
                  "mp4":{ 
                      "fileSuffix":[ 
                          "mp4",
                          "m4a" 
                      ], 
                      "startArgName":"startIndex", 
                      "dragMode":"second" 
                  }, 
                  "flv":{ 
                      "dragMode":"byteAV" 
                  } 
              } 
          } 

          Response example

          HTTP/1.1 200 OK 
          Content-Type: application/json; charset=utf-8 
          Transfer-Encoding: chunked 
          
          { 
              "status":"RUNNING" 
          } 

          Request example 2 Cancel the drag settings for pseudo-streaming in flv type and keep the drag settings for pseudo-streaming in mp4 type unchanged. At this time, the flv parameter is not added to the request body, but to retain the drag setting of the pseudo-streaming of the mp4 type unchanged, the mp4 parameter in the request body shall be the same as the current mp4 parameter of the domain. You can get the current mp4 parameter of the domain by querying the video drag interface.

          PUT /v2/domain/myself.baidu.com/config?mediaDrag HTTP/1.1 
          Host: cdn.baidubce.com 
          Content-Length: 130
          Content-Type: application/json
          
          { 
              "mediaDragConf": { 
                  "mp4": { 
                      "fileSuffix": [ 
                          "mp4",
                          "m4a" 
                      ], 
                      "startArgName": "startIndex", 
                      "dragMode": "second" 
                  } 
              } 
          } 

          Response example

          HTTP/1.1 200 OK 
          Content-Type: application/json; charset=utf-8 
          Transfer-Encoding: chunked 
          
          { 
              "status":"RUNNING" 
          } 

          Request example 3 Modify the setting item of dragMode in mp4 type false traffic dragging settings to keep invariant dragging position of flv type false traffic At this point, the dragMode of mp4 parameters in the request body is set to be the target value, and the remaining parameters of mp4 should be consistent with the corresponding parameters corresponding to the domain; otherwise, the value will be overridden as the default value. The flv parameter in the request body shall be the same as the current mp4 parameter of the domain).

          PUT /v2/domain/myself.baidu.com/config?mediaDrag HTTP/1.1 
          Host: cdn.baidubce.com 
          Content-Length: 130
          Content-Type: application/json
          
          { 
              "mediaDragConf":{ 
                  "mp4":{ 
                      "fileSuffix":[ 
                          "mp4",
                          "m4a" 
                      ], 
                      "startArgName":"startIndex", 
                      "dragMode":"second" 
                      "dragMode":"--Target value---" 
                  }, 
                  "flv":{ 
                      "dragMode":"byteAV" 
                  } 
              } 
          } 

          Response example

          HTTP/1.1 200 OK 
          Content-Type: application/json; charset=utf-8 
          Transfer-Encoding: chunked 
          
          { 
              "status":"RUNNING" 
          } 
          Previous
          Query the SEO Switch Attribute
          Next
          Qurey the Video Drag and Drop