xpra icon
Bug tracker and wiki

Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#281 closed task (fixed)

get the x264 codec to compile on win32 (with encoding bits)

Reported by: Antoine Martin Owned by: ahuillet
Priority: major Milestone: 0.9
Component: platforms Version:
Keywords: Cc:

Description (last modified by Antoine Martin)

This will:

  • cleanup the code from all those ifdefs, making it cleaner and easier to read
  • allow the xpra shadow server to run on win32 with x264 encoding

See patch attached which does not work..

you must include stdint.h or inttypes.h before x264.h

Still appears (and compilation fails) despite the fact that it is there.. I've checked by adding:

#ifdef _MSC_STDINT_H_
#error "not missing _MSC_STDINT_H_"
#endif

And this does fire. The error seems to come from the libx264.h as it gets included from codec.pyx

Build log:

C:\Python27\Python.exe ./setup.py build
(...)
building 'xpra.x264.codec' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IE:\xpra\trunk\src\win3
2 -IC:\libav-win32\win32\usr\include -IC:\x264 -IC:\Python27\include -IC:\Python27\PC /Tcxpra/x264\codec.c /Fobuild\temp
.win32-2.7\Release\xpra/x264\codec.obj
codec.c
You must include stdint.h or inttypes.h before x264.h
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IE:\xpra\trunk\src\win3
2 -IC:\libav-win32\win32\usr\include -IC:\x264 -IC:\Python27\include -IC:\Python27\PC /Tcxpra/x264/x264lib.c /Fobuild\te
mp.win32-2.7\Release\xpra/x264/x264lib.obj
x264lib.c
You must include stdint.h or inttypes.h before x264.h
C:\libav-win32\win32\usr\include\libavutil/rational.h(55) : error C2054: expected '(' to follow 'inline'
(...)

Attachments (2)

x264-ifdef-encoder-win32-v3.patch (5.5 KB) - added by Antoine Martin 7 years ago.
cleanup, remove ifdefs and allow x264 encoding on win32
x264-ifdef-encoder-win32-v4.patch (8.0 KB) - added by Antoine Martin 7 years ago.
updated patch that builds ok but does not link on win32

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by Antoine Martin

cleanup, remove ifdefs and allow x264 encoding on win32

comment:1 Changed 7 years ago by Antoine Martin

Description: modified (diff)

Changed 7 years ago by Antoine Martin

updated patch that builds ok but does not link on win32

comment:2 Changed 7 years ago by Antoine Martin

With the v4 patch above and "libx264" added as a library via setup.py:

building 'xpra.x264.codec' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG \
    -IE:\xpra\trunk\src\win32 \
    -IC:\libav-win32\win32\usr\include \
    -IC:\x264 -IC:\Python27\include \
    -IC:\Python27\PC /Tcxpra/x264\codec.c \
    /Fobuild\temp.win32-2.7\Release\xpra/x264\codec.obj codec.c
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG \
    -IE:\xpra\trunk\src\win32 \
    -IC:\libav-win32\win32\usr\include \
    -IC:\x264 -IC:\Python27\include \
    -IC:\Python27\PC /Tcxpra/x264/x264lib.c \
    /Fobuild\temp.win32-2.7\Release\xpra/x264/x264lib.obj x264lib.c
xpra/x264/x264lib.c(567) : warning C4013: 'round' undefined; assuming extern returning int
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO \
    /LIBPATH:C:\Python27\libs \
    /LIBPATH:C:\Python27\PCbuild
    libx264.lib swscale.lib avcodec.lib avutil.lib \
    /EXPORT:initcodec build\temp.win32-2.7\Release\xpra/x264\codec.obj \
    build\temp.win32-2.7\Release\xpra/x264/x264lib.obj \
    /OUT:build\lib.win32-2.7\xpra\x264\codec.pyd \
    /IMPLIB:build\temp.win32-2.7\Release\xpra/x264\codec.lib \
    /MANIFESTFILE:build\temp.win32-2.7\Release\xpra/x264\codec.pyd.manifest \
    /LIBPATH:C:\libav-win32\win32\usr\lib \
    /LIBPATH:C:\libav-win32\win32\usr\bin /OPT:NOREFLINK : \
fatal error LNK1181: cannot open input file 'libx264.lib'
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' failed with exit status 1181

If I remove "libx264" from setup.py:

C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO \
    /LIBPATH:C:\Python27\libs \
    /LIBPATH:C:\Python27\PCbuild \
    swscale.lib avcodec.lib avutil.lib \
    /EXPORT:initcodec \
    build\temp.win32-2.7\Release\xpra/x264\codec.obj build\temp.win32-2.7\Release\xpra/x264/x264lib.obj \
    /OUT:build\lib.win32-2.7\xpra\x264\codec.pyd \
    /IMPLIB:build\temp.win32-2.7\Release\xpra/x264\codec.lib \
    /MANIFESTFILE:build\temp.win32-2.7\Release\xpra/x264\codec.pyd.manifest \
    /LIBPATH:C:\libav-win32\win32\usr\lib \
    /LIBPATH:C:\libav-win32\win32\usr\bin /OPT:NOREF
Creating library build\temp.win32-2.7\Release\xpra/x264\codec.lib and object build\temp.win32-2.7\Release\xpra/x264\codec.exp
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_open_129 referenced in function _do_init_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_param_apply_profile referenced in function _do_init_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_param_default_preset referenced in function _do_init_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_close referenced in function _do_clean_encoder
x264lib.obj : error LNK2019: unresolved external symbol _x264_picture_alloc referenced in function _csc_image_rgb2yuv
x264lib.obj : error LNK2019: unresolved external symbol _x264_picture_clean referenced in function _free_csc_image
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_encode referenced in function _compress_image
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_reconfig referenced in function _set_encoding_speed
x264lib.obj : error LNK2019: unresolved external symbol _x264_encoder_parameters referenced in function _set_encoding_speed
x264lib.obj : error LNK2019: unresolved external symbol _round referenced in function _set_encoding_speed
build\lib.win32-2.7\xpra\x264\codec.pyd : fatal error LNK1120: 10 unresolved externals
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' failed with exit status 1120

And those symbols can be found in:

$ grep -r x264_encoder_open_129 /cygdrive/c/x264/
Binary file /cygdrive/c/x264/encoder/encoder.o matches
Binary file /cygdrive/c/x264/libx264-129.dll matches
Binary file /cygdrive/c/x264/libx264.a matches
Binary file /cygdrive/c/x264/libx264.dll.a matches
Binary file /cygdrive/c/x264/x264.exe matches
Binary file /cygdrive/c/x264/x264.o matches
Last edited 7 years ago by Antoine Martin (previous) (diff)

comment:3 Changed 7 years ago by Antoine Martin

Resolution: fixed
Status: newclosed

done in r2867

Note: you will need a libx264.lib, see #270

comment:4 Changed 5 years ago by Antoine Martin

As part of #90, I found that cx_freeze picks up the required DLLs from the %PATH%. py2exe cannot because they're not there which is why we already had code to manually add the libx264.dll to the output, the problem is that the libx264.dll builds I have now depend on pthreadGC2.dll too (easily seen with depends.exe once the Encoding_info.exe showed a DLL load error), so r6398 (ugly) tries to find that DLL and bundles it.

Note: See TracTickets for help on using tickets.