视频文件在使用lighttpd进行流式传输时具有不同的大小

时间:2015-07-23 18:16:52

标签: streaming video-streaming h.264 lighttpd

我正在使用wget下载关于数学的视频讲座。不小心我按下了Ctrl + C并继续wget --continue。在这里,我注意到服务器使用不同文件大小的文件进行响应。服务器使用lighttpd

我想知道为什么lighttpd会针对同一个文件响应不同的文件大小?

服务器响应如下。

首次尝试:

$ wget -S http://www.server.com/lecture11940.mp4

--2015-07-23 20:04:28--  http://www.server.com/lecture/11940.mp4
Resolving www.server.com... 1.2.3.4
Connecting to www.server.com|1.2.3.4|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Date: Thu, 23 Jul 2015 18:03:33 GMT
  Server: Apache
  Location: http://www.server.com:8080/lecture11940.mp4
  Vary: Accept-Encoding
  Content-Length: 239
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=iso-8859-1
Location: http://www.server.com:8080/lecture11940.mp4 [following]

重定向:

--2015-07-23 20:04:35--  http://www.server.com:8080/lecture11940.mp4

Connecting to www.server.com|1.2.3.4|:8080... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  X-Mod-H264-Streaming: version=2.2.9
  Content-Type: video/mp4
  ETag: "745841726"
  Last-Modified: Thu, 23 Jul 2015 12:24:08 GMT
  Content-Length: 533771778
  Date: Thu, 23 Jul 2015 18:03:36 GMT
  Server: lighttpd/1.4.19
Length: 533771778 (509M) [video/mp4]
Saving to: '11940.mp4'

第二次尝试:

$ wget -S --continue http://www.server.com/lecture11940.mp4

--2015-07-23 20:04:51--  http://www.server.com/lecture11940.mp4
Resolving www.server.com... 1.2.3.4
Connecting to www.server.com|1.2.3.4|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Date: Thu, 23 Jul 2015 18:03:49 GMT
  Server: Apache
  Location: http://www.server.com:8080/lecture11940.mp4
  Vary: Accept-Encoding
  Content-Length: 239
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=iso-8859-1
Location: http://www.server.com:8080/lecture11940.mp4 [following]

重定向:

--2015-07-23 20:04:51--  http://www.server.com:8080/lecture11940.mp4

Connecting to www.server.com|1.2.3.4|:8080... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 206 Partial Content
  Expires: Thu, 23 Jul 2015 22:03:49 GMT
  Cache-Control: max-age=14400
  Content-Type: video/mp4
  Accept-Ranges: bytes
  ETag: "1834748875"
  Last-Modified: Thu, 23 Jul 2015 12:24:08 GMT
  Content-Range: bytes 122057-533786493/533786494
  Content-Length: 533664437
  Date: Thu, 23 Jul 2015 18:03:49 GMT
  Server: lighttpd/1.4.19
Length: 533786494 (509M), 533664437 (509M) remaining [video/mp4]
Saving to: '11940.mp4'

2 个答案:

答案 0 :(得分:1)

对初始wget请求的响应是H264 Streaming,由

表示
Content-Range: bytes 122057-533786493/533786494

而对第二个wget请求的响应(wget --continue,一个Range请求)是文件的一部分的字节范围响应( H264 Streaming),由

    choice = int(input("Operations: \n1. Addition \n2. Subtraction \n3: Multiplication \n4. Division\n^ Operation 'ID' please enter the id of your choice\n"))
num1 = int(input("Enter your first number: "))
num2 = int(input("Enter your second number: "))
if choice == 1: #Addition
    num1
    num2
    ans = num1 + num2
    print("Your answer is " + str(ans))
elif choice == 2: #Subtraction
    num1
    num2
    ans = num1 - num2
    print("Your answer is " + str(ans))
elif choice == 3: #Miltiplication
    num1
    num2
    ans = num1 * num2
    print("Your answer is " + str(ans))
elif choice == 4: #Division
    num1
    num2
    ans = float(num1) / float(num2)
    print("Your answer is " + str(ans))

答案 1 :(得分:-1)

这是lighttpd的视频流机制。 Here have some discuss

  

当存在Range Request标头时,请求将被转发到> mod_staticfile模块并跳过H264模块。

     

当没有范围请求标题时,文件由H264>模块处理,并且在重写标题时可能与原始文件大小不同(和/或将moov原子移动到文件的前面,等等...)。