Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock on ffmpeg+x264 for windows encode with tune=zerolatency #480

Closed
n-kai-cj opened this issue Nov 9, 2017 · 4 comments
Closed

Deadlock on ffmpeg+x264 for windows encode with tune=zerolatency #480

n-kai-cj opened this issue Nov 9, 2017 · 4 comments

Comments

@n-kai-cj
Copy link
Contributor

n-kai-cj commented Nov 9, 2017

Hello guys,

I'm using a javacpp-1.3 and ffmpeg+x264 for Windows x64 and facing deadlock problem.

I'd like to encode in real-time, so set a -tune zerolatency that is a x264 option.
Option setting source code below:

av_opt_set(avctx.priv_data(), "tune", "zerolatency", 0)

Actually I don't know about x264 in defails, but this option apparently enables x264 to encode a frame in thread parallel.

Encoding frame and extracting avpkt source code below:

avcodec_send_frame(avctx, frame)
avcodec_receive_packet(avctx, avpkt)

After encoding for a while, the encoding loop is stopped in avcodec_send_frame().
Without x264 zerolatency option, that problem doesn't occur.

I doubted this problem would be a bug on official ffmpeg+x264 at first, but I didn't face the same problem by using below command.

$ ffmpeg.exe -i input -c:v libx264 -tune zerolatency output

I tried some cases and found, official ffmpeg+x264 is using a win32 thread, on the other hand ffmpeg+x264 in javacpp is built with ./configure --disable-win32thread so it's using a pthread by default.
I guess my problem will be resolved if ffmpeg+x264 in javacpp is built without --disable-win32thread.

I have two questions.

  • Why ffmpeg+x264 in javacpp disables win32thread ?
  • If there is not a particular reason, can you rebuild it ?

Thank you.

@saudet
Copy link
Member

saudet commented Nov 10, 2017 via email

@n-kai-cj
Copy link
Contributor Author

Thank you for your quick response, saudet.

I'm really sorry, I'm not used to github and don't understand to send a pull request.
Diff info can be shown instead of a pull request, but is it ok ?

ffmpeg/cppbuild.sh

@@ -561,7 +561,7 @@
         cd ../openh264-$OPENH264_VERSION
         make -j $MAKEJ DESTDIR=./ PREFIX=.. AR=ar ARCH=x86 USE_ASM=No libraries install-static
         cd ../$X264
-        ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --disable-win32thread --host=i686-w64-mingw32
+        ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --host=i686-w64-mingw32
         make -j $MAKEJ
         make install
         cd ../x265-$X265
@@ -609,7 +609,7 @@
         cd ../openh264-$OPENH264_VERSION
         make -j $MAKEJ DESTDIR=./ PREFIX=.. AR=ar ARCH=x86_64 USE_ASM=No libraries install-static
         cd ../$X264
-        ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --disable-win32thread --host=x86_64-w64-mingw32
+        ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --host=x86_64-w64-mingw32
         make -j $MAKEJ
         make install
         cd ../x265-$X265

@saudet
Copy link
Member

saudet commented Nov 10, 2017 via email

@n-kai-cj
Copy link
Contributor Author

@saudet , please check this #481 .
This is for my first time to use a pull request, so tell me if anything wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants