I just ran into the same/very similar issue.
Most important thing was to remove the packaged libx264 so that the system finds the right one to link against.
Mainly because if you append the the LD_LIBRARY_PATH like so:
LD will try to use the first version of the library it comes across and if there is another copy of libx264 installed, which was in the original LD_LIBRARY_PATH, it will use that one before it even looks in the path you just appended.
better to do it like so:
By doing the apt-get remove you basically just removed the other copy it was finding.