25 May 2016, 05:44

ffmpeg WebDAV uploading

A question came in on IRC about getting ffmpeg to upload to WebDAV. Since I have been messing with ffmpeg and have a WebDAV server running, I thought I’d figure it out.

There are a few different methods:

  1. Mount WebDAV and write to filesystem
  2. Use ffmpeg http support directly
  3. Use ffmpeg pipe to output stream and then use curl/wget to upload

The solution accepted, in chat, was to use ffmpeg http support directly. However, my initial attempts at this failed because I was not using the correct HTTP method. Additionally, there are some weird things about ffmpeg and https.

Mount WebDAV and write to filesystem

This was my default answer:

Command would be:

mount ... path/to/folder
ffmpeg inputs ... -f format path/to/folder/filename

According to the user the remote mount will lag and corrupt the video. A bit surprising, but it could make sense since any temporary writing errors from ffmpeg are probably going to be ignored.

Use ffmpeg http support directly

I initial fough with option 3, below, looking at ffmpegs http support. There is this option:

    When used as a client option it sets the HTTP method for the request.

Which means we can now support a WebDAV style PUT.

We can now use a single command:

ffmepg inputs ... -method PUT -f format https://.../webdav/filename


This is supposed to work, but my WebDAV server has a non-valid TLS cert (there are no external connections to this server). There does not seem to be any options for SSL/TLS in ffmpegs http support (that I’ve seen). For my own uses I think I have to use another method.

Error reporting:

Any errors with the HTTP endoint with this method seem to be completely masked with the default logging. Even with an invalid password we seem get a 100 OK from WebDAV, but I think that is due to the user agent or an initial non-PUT method?

Use ffmpeg pipe to output stream and then use curl/wget to upload

ffmpeg allows you to use a pipe as an output:

ffmpeg inputs ... -f format pipe:1 # 1 for stdout

We can merge this with a curl command to upload to WebDAV:

curl --data-binary @- -X PUT https://.../webdav/filename

The full command is:

ffmpeg inputs ... -f format pipe:1 | curl --data-binary @- -X PUT https://.../webdav/filename

This seems to be the most robust solution as I have full control over my HTTPs request.

Additional notes


I’m seeing mixed answers about cookie support in WebDAV, so I have not included any examples for either ffmpeg or curl.