VLC playback RTSP video delay (conversion)

Source: Internet
Author: User

Original post address: http://blog.chinaunix.net/uid-26611383-id-3755283.html

========================================================== ==========================================================

I have written an article about compiling the VLC player source code on the Android platform on Linux. The VLC player is excellent and open-source, its core is the open-source video codec library FFMPEG. The player also supports the RTSP protocol, which is mainly implemented using the open-source live555. The live555 library needs to be carefully studied later.

I: PC Terminal ( Windows Platform) VLC Play RTSP Video latency

A few days ago, when I played RTSP Streaming Media Using VLC on the PC platform, the latency was long and there was a latency of about 1 s. The effect was not very good. Later I checked the information and found that the delay time could be modified.

Find the tool> preferences, select "all" in the lower left corner of the parameter settings, and select "input codec"> "Network cache" on the left. You can modify the parameters as needed, for details, the value must not be too small. Otherwise, the cache is too small and the video playing process will be very slow.

If the network environment is good, the effect is good within ms, and the real-time performance is good.

II:PCTerminal (LinuxPlatform)VLCPlayRTSPVideo latency

Here, my testing platform is Ubuntu, And the VLC on Linux can be run in the command line mode, while the command line can contain parameters, you only need to specify the delay time in the parameter. The following is a specific command line format. you can adjust it based on your needs.

VLC rtsp: // 192.168.1.1: 8556/test. Avi -- newwork-caching = 300

The RTSP address needs to be modified based on the video address to be played, and the Network Delay Time can also be modified as needed. The smaller the value, the better the real-time performance. Of course, if it is too small, the playback will be very slow, or the set value is invalid. It is generally recommended that the value range be between and.

III.AndroidPlatformVLCPlayRTSPVideo latency

First, the VLC player on the Android platform does not provide the function of setting the delay time in the UI on the Windows platform. Second, it does not support running in command line mode on the Linux platform, we cannot modify the delay time by setting parameters. What should we do? Only the last path is left, the source code is modified, and the delay time is written to the source code, with the experience of setting parameters in the previous Linux platform, you can use the grep tool in the source code to find "network-caching" and find that many files contain this value. The following is the search result.

vlc/src/libvlc-module.c: add_integer( "network-caching", CLOCK_FREQ / 1000, vlc/NEWS: - --network-caching specifies caching for network resources,vlc/modules/gui/macosx/simple_prefs.m: TestCaC("network-caching", 10/3);vlc/modules/gui/macosx/simple_prefs.m: CaC("network-caching", 10/3);vlc/modules/gui/qt4/components/open_panels.cpp: emit methodChanged( qfu( "network-caching" ) );vlc/modules/gui/qt4/components/simple_preferences.cpp: TestCaC( "network-caching", 10/3 );vlc/modules/gui/qt4/components/simple_preferences.cpp: CaC( "network-caching", 10/3 );vlc/modules/access/file.c: *pi_64 = var_InheritInteger (p_access, "network-caching");vlc/modules/access/rtp/rtp.c: *v = INT64_C(1000) * var_InheritInteger (demux, "network-caching");vlc/modules/access/ftp.c: * var_InheritInteger( p_access, "network-caching" );vlc/modules/access/live555.cpp: * var_InheritInteger( p_demux, "network-caching" );vlc/modules/access/http.c: * var_InheritInteger( p_access, "network-caching" );vlc/modules/access/sftp.c: * var_InheritInteger( p_access, "network-caching" );vlc/modules/access/udp.c: * var_InheritInteger(p_access, "network-caching");vlc/modules/access/smb.c: * var_InheritInteger( p_access, "network-caching" );vlc/modules/access/tcp.c: * var_InheritInteger( p_access, "network-caching" );vlc/modules/access/rtsp/access.c: * var_InheritInteger(p_access, "network-caching");vlc/modules/access/mms/mmsh.c: * var_InheritInteger( p_access, "network-caching" );vlc/modules/access/mms/mmstu.c: * var_InheritInteger( p_access, "network-caching" );vlc/modules/access/vnc.c: * var_InheritInteger( p_demux, "network-caching" );vlc-android/jni/libvlcjni.c: libvlc_media_add_option(p_md, ":network-caching=1500"); 

The Code of these files was analyzed, and the object was found in the VLC/src/libvlc-module.c file, so the 1832 lines of the file were modified, as shown in, change clock_freq/1000 to clock_freq/3000. You can modify it based on your needs. The larger the denominator, the smaller the value, and the better the real-time performance. Of course, as mentioned above, it cannot be too small.

 

1832 //add_integer( "network-caching", CLOCK_FREQ / 1000, 1833 // NETWORK_CACHING_TEXT, NETWORK_CACHING_LONGTEXT, true )1834 add_integer( "network-caching", CLOCK_FREQ / 3000,1835 NETWORK_CACHING_TEXT, NETWORK_CACHING_LONGTEXT, true ) 

Finally, we found that the latency was about ms after compilation and running, which is significantly better than the real-time performance before modification. We hope this article can provide some help to friends who need relevant information.

========================================================== ========================================================== ======

It's so powerful. It's exactly what I need. Thanks for the original post.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.