undefined reference to `x264_encoder_open_142'

375 views
Skip to first unread message

Pete Helgren

unread,
Mar 24, 2016, 8:57:40 AM3/24/16
to javacv
I have been using this tooling for a couple of years.  After a painful learning curve I was able to get a compiled version of this working for RHEL5 and Java 6 a couple of years ago.  It's been working great.  Recently though I ran across an issue where the encoding for h264 wasn't working.  I thought I had compiled in support for it two years ago when I originally built the binaries and jar but apparently I didn't because I get this error when I run my app:

org.bytedeco.javacv.FrameRecorder$Exception: avcodec_find_encoder() error: Video codec not found.
        at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:333)
        at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:273)
        at org.bsfinternational.filemgr.MergeUsingFFMPEG.run(MergeUsingFFMPEG.java:237)
        at java.lang.Thread.run(Thread.java:662)

The codec is #28

So I decided to go ahead an rebuild ffmpeg with h264 enabled.  Fortunately I had preserved the original compile environment in a VM so I didn't have to walk through all the details to get a RHEL5 compile environment set up.  All *seems* well but when I run cppbuild,sh in  javacpp-presets to build ffmpeg 2.2.1 I see the following errors:

LD      ffmpeg_g
libavcodec/libavcodec.so: undefined reference to `x264_encoder_open_142'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1
make: *** Waiting for unfinished jobs....
LD      ffplay_g
libavcodec/libavcodec.so: undefined reference to `x264_encoder_open_142'
collect2: ld returned 1 exit status
make: *** [ffplay_g] Error 1

The final entry in the listing is:

LD      ffmpeg_g
libavcodec/libavcodec.so: undefined reference to `x264_encoder_open_142'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1


A little research says this is an issue with an older set of libraries being referenced but the only libraries I can find are the ones built by cppbuild with the current date and time.  If I remove the reference to --enable-libx264 in the build script, it compiles and builds just fine.

It has been a while since I have done this so I must have missed something.  Ideas?  I understand I am running an "old" version here but I have to compile in RHEL5 and use Java 6.  

Thanks

Pete Helgren

unread,
Mar 24, 2016, 12:53:36 PM3/24/16
to javacv
Went through the entire listing with a few things that piqued my interest.  The most interesting were:

"mkdir: cannot create directory `ffmpeg/cppbuild': File exists"

Both curl requests pulled no data (presumably because the prior file was still there)

I assumed that part of the problem was due to the cppbuild folder being in existence so I renamed it and rebuilt.  This time it completed without error.  The maven build failed with:

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6:deploy (default-deploy) on project ffmpeg: Execution default-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6:deploy failed: Server credentials with ID "sonatype-nexus-staging" not found! -> [Help 1]

However, the jars that were built for ffmpeg did work when I deployed them to RHEL5 and the error about h264 is gone.

So I am assuming that the prior build was getting in the way of rebuilding ffmpeg with h264 enabled.  But, all is well now.


Samuel Audet

unread,
Mar 26, 2016, 9:31:02 PM3/26/16
to jav...@googlegroups.com
Good to hear you got it working!

BTW, I've since created build instructions, and keep them up to date
with recent changes:
https://github.com/bytedeco/javacpp-presets/wiki/Build-Environments
So it'll probably be easier to follow them next time you need to rebuild :)

Samuel
Reply all
Reply to author
Forward
0 new messages