bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.53k stars 1.58k forks source link

avio_open error() error -5: Could not open 'null' #1457

Open alyk opened 4 years ago

alyk commented 4 years ago

Hi, is it known issue: _ffmpegRecorder error: org.bytedeco.javacv.FrameRecorder$Exception: avioopen2 error() error -5: Could not open 'null' constantly after first successful pass

ffmpegRecorder = new FFMpegRecorder(streamUrl + streamKey); // little delay solves the problem -- Thread.sleep(600); ffmpegRecorder.startRecording();

saudet commented 4 years ago

That's a problem with your server. Check the log for more information.

alyk commented 4 years ago

that's a new video platform video.api. I've got no access to logs( but you mean 'null' comes from server?

saudet commented 4 years ago

If you don't see anything displayed on the console, make sure FFmpegLogCallback.set() gets called.

alyk commented 4 years ago

ok. that's the difference

this is normal behaviour:

2020-06-25 14:19:39.163 12271-12340/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder initialize - ok 2020-06-25 14:19:40.180 12271-12340/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder starting... 2020-06-25 14:19:40.352 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] using cpu capabilities: none! 2020-06-25 14:19:40.357 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] profile High, level 1.3 2020-06-25 14:19:40.357 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] 264 - core 155 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 lookahead_threads=3 sliced_threads=1 slices=3 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=28.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 2020-06-25 14:19:40.822 12271-12388/com.boxtox I/System.out: Output #0, flv, to 'rtmp://broadcast.api.video/s/XXXXX': 2020-06-25 14:19:40.822 12271-12388/com.boxtox I/System.out: Metadata: 2020-06-25 14:19:40.825 12271-12388/com.boxtox I/System.out: encoder : 2020-06-25 14:19:40.825 12271-12388/com.boxtox I/System.out: Lavf58.12.100 2020-06-25 14:19:40.825 12271-12388/com.boxtox I/System.out: Stream #0:0 2020-06-25 14:19:40.825 12271-12388/com.boxtox I/System.out: : Video: h264 (Constrained Baseline) ([7][0][0][0] / 0x0007), yuv420p, 320x240, q=2-31, 512 kb/s 2020-06-25 14:19:40.825 12271-12388/com.boxtox I/System.out: , 2020-06-25 14:19:40.825 12271-12388/com.boxtox I/System.out: 1k tbn 2020-06-25 14:19:40.826 12271-12388/com.boxtox I/System.out: [API][Audio] cannot start Audio Recorder. API is not active! 2020-06-25 14:19:40.841 12271-12340/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder | video recording started. 2020-06-25 14:19:40.842 12271-12340/com.boxtox I/System.out: [ SOCK ] [ OUT ] MEDIA box:cdfa5b0c-f4c0-40b0-a97e-a7742b64035e preview:@GZIP ***** type:STREAM ... 2020-06-25 14:19:40.896 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 34 | frames_in: 1 2020-06-25 14:19:40.903 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 6 | frames_in: 2 2020-06-25 14:19:40.933 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 5 | frames_in: 3 2020-06-25 14:19:40.970 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 6 | frames_in: 4 2020-06-25 14:19:41.017 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 13 | frames_in: 5 2020-06-25 14:19:41.067 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 20 | frames_in: 6

...

2020-06-25 14:19:44.486 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 8 | frames_in: 79 2020-06-25 14:19:44.548 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 5 | frames_in: 80 2020-06-25 14:19:44.586 12271-12385/com.boxtox I/System.out: RxComputationThreadPool-2 | proc_time: 4 | frames_in: 81 2020-06-25 14:19:44.615 12271-12388/com.boxtox W/System.err: Warning: [flv @ 0xc281ca00] Failed to update header with correct duration. 2020-06-25 14:19:44.615 12271-12388/com.boxtox W/System.err: Warning: [flv @ 0xc281ca00] Failed to update header with correct filesize. 2020-06-25 14:19:44.618 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] frame I:1 Avg QP:24.24 size: 4741 2020-06-25 14:19:44.619 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] frame P:80 Avg QP:17.63 size: 140 2020-06-25 14:19:44.619 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] mb I I16..4: 6.7% 52.7% 40.7% 2020-06-25 14:19:44.620 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 5.5% 0.0% 0.0% 0.0% 0.0% skip:94.5% 2020-06-25 14:19:44.620 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] 8x8 transform intra:52.7% inter:28.1% 2020-06-25 14:19:44.620 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] coded y,uvDC,uvAC intra: 83.0% 32.3% 6.0% inter: 1.7% 1.8% 0.0% 2020-06-25 14:19:44.621 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] i16 v,h,dc,p: 15% 15% 35% 35% 2020-06-25 14:19:44.622 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 16% 18% 5% 10% 11% 4% 9% 7% 2020-06-25 14:19:44.622 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 24% 20% 4% 5% 6% 2% 6% 3% 2020-06-25 14:19:44.629 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] i8c dc,h,v,p: 64% 13% 20% 3% 2020-06-25 14:19:44.630 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] Weighted P-Frames: Y:0.0% UV:0.0% 2020-06-25 14:19:44.630 12271-12388/com.boxtox I/System.out: [libx264 @ 0xb9737b80] kb/s:47.34 2020-06-25 14:19:44.630 12271-12340/com.boxtox I/System.out: [ MED ] [ INFO ] STREAM @Apivideo | state changed: COMPLETE 2020-06-25 14:19:44.631 12271-12340/com.boxtox I/System.out: [ MED ] [ INFO ] [ Test Stream ] stop 2020-06-25 14:19:44.632 12271-12340/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder stop... 2020-06-25 14:19:44.754 12271-12340/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder stopped. 2020-06-25 14:19:44.798 12271-12302/com.boxtox I/com.boxtox: NativeAlloc concurrent copying GC freed 47323(2321KB) AllocSpace objects, 1(152KB) LOS objects, 49% free, 4794KB/9588KB, paused 754us total 151.419ms 2020-06-25 14:19:45.201 12271-12306/com.boxtox D/HostConnection: HostConnection::get() New Host Connection established 0xe2ab2e70, tid 12306 2020-06-25 14:19:45.201 12271-12306/com.boxtox D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 2020-06-25 14:19:46.978 12271-12419/com.boxtox D/HostConnection: HostConnection::get() New Host Connection established 0xd9d5b490, tid 12419 2020-06-25 14:19:46.979 12271-12419/com.boxtox D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 2020-06-25 14:19:47.390 12271-12340/com.boxtox I/System.out: [ SOCK ] [ OUT ] KeepAlive

so I'm able to recieve and push frames to the server

next time (without mentioned delay):

2020-06-25 14:24:30.288 12488-12539/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder stopped. 2020-06-25 14:24:34.042 12488-12539/com.boxtox I/System.out: [ SOCK ] [ OUT ] KeepAlive 2020-06-25 14:24:35.517 12488-12539/com.boxtox I/System.out: [ MED ] [ INFO ] STREAM @Apivideo | state changed: CREATE 2020-06-25 14:24:35.976 12488-12539/com.boxtox I/System.out: [ TOX ] [ INFO ] [ Test Stream ] got access token:XXXXXXX 2020-06-25 14:24:36.043 12488-12539/com.boxtox I/System.out: [ MED ] [ INFO ] [ Test Stream ] got stream ID: li20sksnfQOJgeE24lcgyfKf | live: false 2020-06-25 14:24:36.043 12488-12539/com.boxtox I/System.out: [ MED ] [ INFO ] STREAM @Apivideo | state changed: LIVE 2020-06-25 14:24:36.043 12488-12539/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder initialize - ok 2020-06-25 14:24:36.058 12488-12608/com.boxtox I/System.out: [libx264 @ 0xd9dc2d80] using cpu capabilities: none! 2020-06-25 14:24:36.060 12488-12608/com.boxtox I/System.out: [libx264 @ 0xd9dc2d80] profile High, level 1.3 2020-06-25 14:24:36.061 12488-12608/com.boxtox I/System.out: [libx264 @ 0xd9dc2d80] 264 - core 155 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 lookahead_threads=3 sliced_threads=1 slices=3 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=28.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 2020-06-25 14:24:36.149 12488-12539/com.boxtox I/System.out: [ BOX ] [ INFO ] ffmpeg recorder starting... 2020-06-25 14:24:36.392 12488-12539/com.boxtox I/System.out: [ MED ] [ ERR ] [STREAM: Apivideo] ffmpegRecorder error: org.bytedeco.javacv.FrameRecorder$Exception: avio_open2 error() error -5: Could not open 'null' 2020-06-25 14:24:36.394 12488-12539/com.boxtox I/System.out: [ MED ] [ INFO ] STREAM @Apivideo | state changed: ERROR 2020-06-25 14:24:36.395 12488-12539/com.boxtox I/System.out: [ MED ] [ INFO ] [ Test Stream ] stop

so that's missing log part:

Output #0, flv, to 'rtmp://broadcast.api.video/s/XXXXXXXX': Metadata: encoder : Lavf58.12.100 Stream #0:0 : Video: h264 (Constrained Baseline) ([7][0][0][0] / 0x0007), yuv420p, 320x240, q=2-31, 512 kb/s ...

rings a bell? any async process during FFmpegFrameRecorder initialization?

saudet commented 4 years ago

If you're missing an "Output", that probably means you didn't call start()...

saudet commented 4 years ago

If you're using threads, make sure to use JavaCV 1.5.4-SNAPSHOT: http://bytedeco.org/builds/. There's been a few things fixed/enhanced for that. There could also be bugs in libx264 about that, so make sure to try and disable its multithreading.

alyk commented 4 years ago

thanks definitely it's about start() the problem is it was hard to debug it, because if you stop there everything is ok (that's where my little delay helps) so it really looks like multithreading issue I will try with 1.5.4-SNAPSHOT, but from the first attempt I didn't manage to compile my project

Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'org.bytedeco.gradle-javacpp-platform' not found.

before I had:

implementation group: 'org.bytedeco', name: 'javacv', version: "$javacv_ver"
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: "4.0.1-$javacv_ver", classifier: 'android-arm'
implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: "4.1-$javacv_ver", classifier: 'android-arm'

is new api ... javacv-platform line is instead of implementation ... javacv?

saudet commented 4 years ago

The group name changed: http://bytedeco.org/news/2019/04/11/beyond-java-and-cpp/

saudet commented 4 years ago

Try to use javacv-platform only, without anything else. If you still have problems with that, please let me know.

alyk commented 4 years ago

thx for keeping me updated. I will try but maybe in few weeks, and let you know

On Wed, Aug 19, 2020 at 4:21 AM Samuel Audet notifications@github.com wrote:

Try to use javacv-platform only, without anything else. If you still have problems with that, please let me know.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-675812702, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNA4RVXAHL6633Q3JJILSBMZJXANCNFSM4OIFBNLQ .

alyk commented 4 years ago

Hi Samuel,

  1. trying 1.5.4-snapshot

buildscript { repositories { ... maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // bytedeco 1.5.4 }

}

dependencies { ...

api 'org.bytedeco:javacv-platform:1.5.4-SNAPSHOT'

}

==

ERROR: Failed to resolve: org.bytedeco:javacv-platform:1.5.4-SNAPSHOT Show in Project Structure dialog Affected Modules: app

  1. not sure it's related to cpp-presets

my gradle splits is not working correctly

android { ... splits { abi { enable true reset() include "x86", "armeabi-v7a", "arm64-v8a", "x86_64" universalApk false } }

in each platform dependent APK I can see folders/libraries from all the platforms

On Wed, Aug 19, 2020 at 10:10 AM Alex Lykov alyk74@gmail.com wrote:

thx for keeping me updated. I will try but maybe in few weeks, and let you know

On Wed, Aug 19, 2020 at 4:21 AM Samuel Audet notifications@github.com wrote:

Try to use javacv-platform only, without anything else. If you still have problems with that, please let me know.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-675812702, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNA4RVXAHL6633Q3JJILSBMZJXANCNFSM4OIFBNLQ .

saudet commented 4 years ago

I don't think adding repositories to the buildscript { } block works, see http://bytedeco.org/builds/#gradle.

alyk commented 4 years ago

my bad for repositories block, thx

api 'org.bytedeco:javacv-platform:1.5.4-SNAPSHOT' - that works

implementation group: 'org.bytedeco', name: 'opencv-platform', version: "4.4.0-1.5.4-SNAPSHOT", classifier: 'android-arm' - not working

wrong preset version maybe?

On Wed, Aug 26, 2020 at 1:32 PM Samuel Audet notifications@github.com wrote:

I don't think adding repositories to the buildscript { } block works, see http://bytedeco.org/builds/#gradle.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-680823436, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNAZNQJS2R6VSEEHUZN3SCTXDDANCNFSM4OIFBNLQ .

saudet commented 4 years ago

avio_open() is a function from FFmpeg, not OpenCV.

alyk commented 4 years ago

it was just for example I use both FFmpeg and OpenCV

On Tue, Sep 1, 2020 at 6:54 AM Samuel Audet notifications@github.com wrote:

avio_open() is a function from FFmpeg, not OpenCV.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-684239648, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNA7IM7HBO4PSA7AFGWDSDR5CFANCNFSM4OIFBNLQ .

saudet commented 4 years ago

Right, so you'll need to use FFmpeg, not OpenCV.

alyk commented 4 years ago

sorry. i didn't get you. you're asking if I need openCV? I create video stream with ffmpeg recorder and treat video with openCV at the same time

On Tue, Sep 1, 2020 at 9:58 AM Samuel Audet notifications@github.com wrote:

Right, so you'll need to use FFmpeg, not OpenCV.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-684530114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNA3WX7VDNA5JAROOTS3SDSSS3ANCNFSM4OIFBNLQ .

saudet commented 4 years ago

That's fine, but you're still going to need FFmpeg.

alyk commented 4 years ago

to clarify my current situation - there's the config that still working good

def javacv_ver = '1.4.4' implementation group: 'org.bytedeco', name: 'javacv', version: " $javacv_ver".4.4 implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: "4.0.1-$javacv_ver", classifier: 'android-arm' implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: "4.0.1-$javacv_ver", classifier: 'android-x86' implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: "4.1-$javacv_ver", classifier: 'android-arm' implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: "4.1-$javacv_ver", classifier: 'android-x86' implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: "4.0.1-$javacv_ver", classifier: 'android-arm64' implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: "4.0.1-$javacv_ver", classifier: 'android-x86_64' implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: "4.1-$javacv_ver", classifier: 'android-arm64' implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: "4.1-$javacv_ver", classifier: 'android-x86_64'

at some moment I tried to make a version upgrade and I got the initial avio_open error message. you proposed to switch to 1.5.4-snapshot

If you're using threads, make sure to use JavaCV 1.5.4-SNAPSHOT: http://bytedeco.org/builds/.

the current problem is I didn't manage to build the project with that version. gradle doesn't complain about "api 'org.bytedeco:javacv-platform:1.5.4-SNAPSHOT'" but it complains about both ffmpeg and opencv. that's why I asked about cpp-preset versions.

On Tue, Sep 1, 2020 at 11:12 AM Samuel Audet notifications@github.com wrote:

That's fine, but you're still going to need FFmpeg.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-684631074, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNA4UZ5HUN66MUCRGEZLSDS3HLANCNFSM4OIFBNLQ .

saudet commented 4 years ago

You'll need to put the right versions of FFmpeg and OpenCV, of course.

alyk commented 4 years ago

yes, that was the question) I don't' get where should I find those versions to use with org.bytedeco:javacv-platform:1.5.4-SNAPSHOT? implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: ????????, classifier: '.....'

On Tue, Sep 1, 2020 at 1:41 PM Samuel Audet notifications@github.com wrote:

You'll need to put the right versions of FFmpeg and OpenCV, of course.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-684789973, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNA45VEDAWU6H4T5E2S3SDTMVPANCNFSM4OIFBNLQ .

saudet commented 4 years ago

It's in the pom.xml file, for example, here: https://github.com/bytedeco/javacv/blob/master/pom.xml

alyk commented 4 years ago

hmm

ffmpeg 4.3.1-${javacpp.version}

seems like I tried that one - but I'll double check today ${javacpp.version} == 1.5.4-SNAPSHOT ?

On Wed, Sep 2, 2020 at 10:56 AM Samuel Audet notifications@github.com wrote:

It's in the pom.xml file, for example, here: https://github.com/bytedeco/javacv/blob/master/pom.xml

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bytedeco/javacv/issues/1457#issuecomment-685457166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5WNA6LNLNW5FFN2TOBYRTSDYCCLANCNFSM4OIFBNLQ .

saudet commented 4 years ago

Yes, that's what it says in the pom.xml file.

saudet commented 4 years ago

BTW, JavaCV 1.5.4 has been released, so please try again with this version.