solid-software / flutter_vlc_player

📺 Flutter VLC powered video player.
521 stars 254 forks source link

RTSP Dropped Frames #290

Open andrewcapatina opened 2 years ago

andrewcapatina commented 2 years ago

Hello,

I am using this package to play rtsp streams. When I use the VLC player app for iphone, I do not see the same performance I am getting with this package. The VLC app on iphone doesn't drop any frames.

The video format sent by rtsp server is h264.

I am seeing dropped frames using this package which results in 3 seconds of a 5 second video being transmitted.

VlcPlayerController videoPlayerController = VlcPlayerController.network(
                        'rtsp://ip_addr:8554/test',
                        hwAcc: HwAcc.FULL,
                        autoPlay: true,
                        options: VlcPlayerOptions(
                            video: VlcVideoOptions([VlcVideoOptions.dropLateFrames(false),
                                                    VlcVideoOptions.skipFrames(false)],),
                          rtp: VlcRtpOptions(['--rtsp-tcp'],),
                          advanced: VlcAdvancedOptions([VlcAdvancedOptions.clockSynchronization(0),
                          ]),
                            sout: VlcStreamOutputOptions([
                            ]),
                          extras: ['--h264-fps=40']
                        ),);

Here are the logs:

E/VLC     (32551): [a8a85fe0/77e] libvlc window: request 1 not implemented
E/VLC     (32551): [a8a85fe0/77e] libvlc window: request 1 not implemented
D/HostConnection(32551): HostConnection::get() New Host Connection established 0xe80b6100, tid 1918
D/HostConnection(32551): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 
D/EGL_emulation(32551): eglCreateContext: 0xa734a180: maj 2 min 0 rcv 2
D/EGL_emulation(32551): eglMakeCurrent: 0xa734a180: ver 2 0 (tinfo 0xb4ee1390) (first time)
E/VLC     (32551): [a8a85fe0/77e] libvlc window: request 0 not implemented
E/VLC     (32551): [a8a85fe0/77e] libvlc window: request 0 not implemented
E/VLC     (32551): [a8a85fe0/77e] libvlc window: request 1 not implemented
I/OMXClient(32551): IOmx service obtained
D/SurfaceUtils(32551): connecting to surface 0xe2961108, reason connectToSurface
I/MediaCodec(32551): [OMX.android.goldfish.h264.decoder] setting surface generation to 33332261
D/SurfaceUtils(32551): disconnecting from surface 0xe2961108, reason connectToSurface(reconnect)
D/SurfaceUtils(32551): connecting to surface 0xe2961108, reason connectToSurface(reconnect)
E/ACodec  (32551): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
D/SurfaceUtils(32551): disconnecting from surface 0xe2961108, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(32551): connecting to surface 0xe2961108, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(32551): set up nativeWindow 0xe2961108 for 1280x720, color 0x13, rotation 0, usage 0x1002900
E/VLC     (32551): [e7f16d20/784] libvlc decoder: output: 19 unknown, 1280x720 stride 1280 720, crop 0 0 0 0
E/VLC     (32551): [a8a85fe0/77e] libvlc window: request 3 not implemented
W/System  (32551): A resource failed to call release. 
I/chatty  (32551): uid=10121(com.example.ad_hoc.ad_hoc_25v) FinalizerDaemon identical 1 line
W/System  (32551): A resource failed to call release. 
E/NdkMediaCodec(32551): sf error code: -38
E/NdkMediaCodec(32551): sf error code: -38
D/SurfaceUtils(32551): disconnecting from surface 0xe2961108, reason disconnectFromSurface

I have tried all of the Advanced and StreamOutput options but I am not seeing any results. Can anyone suggest any options that may be helpful in getting optimal performance? I've been looking at this link and trying to find the optimal set of options: https://wiki.videolan.org/VLC_command-line_help/

But consistently I've been seeing the same frames being dropped no matter what the option I set.

I will try to address the log errors, I think this will be important for getting good performance. The only issue is there aren't many choices for what I can set for options so my choices seem limited.

Any help will be appreciated, thank you.

andrewcapatina commented 2 years ago

I tried a test rtsp source with mp4 format. That worked well. I was even able to adjust framerate. I am investigating on server side now.

andrewcapatina commented 2 years ago

Update:

I changed the file format of the server and now I can stream the entire video. Only complaints are the playback is a bit slower and there is a pixelated gray frame (about a seconds worth) every time I run playback.

Thanks.

EbrahimMosaaed commented 1 year ago

@andrewcapatina can i show playback video with specific start and end date with rtsp ?

andrewcapatina commented 1 year ago

@EbrahimMosaaed Yes, RTSP supports setting the duration. But I don't think this API supports that. There is a seekTo() module for this API though, may want to look into that.