Saturday, 21 December 2013

Building FFmpeg with libssh on Windows

FFmpeg recently added support for SFTP protocol through the use of libssh. However if you have tried to use this feature on Windows you would have discovered that FFmpeg will not build without some changes. These changes are pretty simple and are yet another case of the Windows headers not including things that are commonly found in their Linux counterparts. In this case whats missing is some defines used for flagging permissions and other things on read/write operations. So in order to get them to work we just have to add the appropriate defines to the file.

So if your curious as to how to get libssh support in FFmpeg on Windows then all you need to do is add the following lines to libavformat/libssh.c:

@@ -20,12 +20,34 @@
 
 #include <fcntl.h>
 #include <libssh/sftp.h>
+#include <sys/stat.h>
 #include "libavutil/avstring.h"
 #include "libavutil/opt.h"
 #include "avformat.h"
 #include "internal.h"
 #include "url.h"
 
+#if defined(_WIN32)
+#ifndef S_IRUSR
+#define S_IRUSR S_IREAD
+#endif
+#ifndef S_IWUSR
+#define S_IWUSR S_IWRITE
+#endif
+#ifndef S_IRGRP
+#define S_IRGRP 0
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP 0
+#endif
+#ifndef S_IROTH
+#define S_IROTH 0
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH 0
+#endif
+#endif
+
 typedef struct {
     const AVClass *class;
     ssh_session session;


And thats it. After adding those lines then assuming you have a built libssh library then everything should work fine.

No comments:

Post a Comment