[FFmpeg-user] Chunked request when using "-progress"

Nicolas George nicolas.george at normalesup.org
Thu Dec 13 16:32:59 CET 2012

Le tridi 23 frimaire, an CCXXI, Вадим Лазовский a écrit :
> I have encountered a problem when using new "-progress" option.
> FFmpeg uses chunked request that is not supported by nginx web server up to
> the last version 1.3.9 released on 2012-11-27 (Feature: support for chunked
> transfer encoding while reading client request body).
> All other versions of nginx are unable to handle chunked input and respond
> with "411 Length Required".
> command line:
> ffmpeg -i 329635 -progress http://conv.example.com/progress.php -codec:v
> libx264 -strict -2 -codec:a aac -ar 44100 -b:v 800k -f mp4 -y /tmp/123.mp4

So exact problem is that you want to post the progress to an HTTP server.
Got it.

Note: you provided the exact command line, but not the corresponding full
output. In this particular it is not necessary, but it is usually, and it is
better to include it anyway.

> client request headers (from tcpdump):
> POST /progress.php HTTP/1.1
> Transfer-Encoding: chunked
> User-Agent: Lavf54.29.104
> Accept: */*
> Connection: close
> Host: conv.example.com
> server response (from tcpdump):
> HTTP/1.1 411 Length Required Server: nginx/1.2.3 Date: Thu, 13 Dec 2012
> 10:37:09 GMT Content-Type: text/html Content-Length: 180 Connection: close
> <html> <head><title>411 Length Required</title></head> <body
> bgcolor="white"> <center><h1>411 Length Required</h1></center>
> <hr><center>nginx/1.2.3</center> </body> </html>
> web server log entry:
> - - [13/Dec/2012:14:30:57 +0400] "POST /progress.php HTTP/1.1" 411
> 180 "-" "Lavf54.29.104"
> Is it possible to make ffmpeg do requests in a "traditional" way: not
> chunked, specifying Content-Length header?

This will not work, for two reasons. First, to use the "traditional" way,
ffmpeg would need to know the exact size of the data when it starts writing
the progress, and it can not know it, obviously. Second, if nginx is
anything like the web servers I know, it will read the whole body before
calling the CGI script.

You could get the expected result using something like that:

ffmpeg -progress /tmp/progress.txt ... &&
curl -d @/tmp/progress.txt http://localhost:1234/

but that defeats the purpose of the progress option.

The other solution would be to implement a new protocol, maybe ffmultihttp,
that would make a new request for each packet written (the progress option
is already ready for that because it can work with UDP). That would not be
too difficult a task, probably.

Another solution: I notice that Debian package for nginx seems to include a
patch for chunked POST data. Maybe you should look at it.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20121213/83bb1899/attachment.asc>

More information about the ffmpeg-user mailing list