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

delayed video on rtsp stream #20

Open
tulkas85 opened this issue May 7, 2014 · 13 comments
Open

delayed video on rtsp stream #20

tulkas85 opened this issue May 7, 2014 · 13 comments

Comments

@tulkas85
Copy link

tulkas85 commented May 7, 2014

I have about 6 seconds of delay on live video rtsp streams in local wifi network, using vlc app I have only 1 second of delay using same source.
Is possible to reduce this time ?
I use Android tv.danmaku.ijk.media.widget.VideoView

@bbcallen
Copy link
Contributor

bbcallen commented May 7, 2014

Modify these macros to reduce latency.

#define DEFAULT_HIGH_WATER_MARK_IN_BYTES    (128 * 1024)

#define DEFAULT_MAX_HIGH_WATER_MARK_IN_MS       (5 * 1000)
#define DEFAULT_NORMAL_HIGH_WATER_MARK_IN_MS    (2 * 1000)
#define DEFAULT_FAST_HIGH_WATER_MARK_IN_MS      (100)

#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
#define MIN_FRAMES 50000

@bbcallen
Copy link
Contributor

bbcallen commented May 7, 2014

FYI, The original MIN_FRAMES in ffplay is

#define MIN_FRAMES 5

@tulkas85
Copy link
Author

tulkas85 commented May 7, 2014

Thank you, but I have now other questions.

I must change these values af ff_ffplay_def.h , is right ?
Can you suggest me some value ?
I could set

#define DEFAULT_MAX_HIGH_WATER_MARK_IN_MS       ( 1000)
#define DEFAULT_NORMAL_HIGH_WATER_MARK_IN_MS    (500)
#define DEFAULT_FAST_HIGH_WATER_MARK_IN_MS      (100)
#define MIN_FRAMES 5

but these ????

#define DEFAULT_HIGH_WATER_MARK_IN_BYTES    (128 * 1024)
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)

After edit file, from which step of your guide I have to start with the compilation? ndk-build ???

I've read something about analyzeDuration :
https://bbs.vitamio.org/topics/220/parts/51751e9d1b27a78e1c0000fe?locale=zh-CN

It can help ?

@bbcallen
Copy link
Contributor

bbcallen commented May 8, 2014

Your value is fine, ndk-build is enough.

The macros should work with HLS. But for rtsp/rtmp/etc, I don't have much knowledge about them.

The analyzeDuration can be set through ijkmp_set_codec_option(), which could be easily exposed to java layer as ijkmp_set_format_option() does.

@tulkas85
Copy link
Author

tulkas85 commented May 8, 2014

with these values I have a delay of 3 secs ... now is better.
I have rtsp stream, so this values work with rtsp too.
But now how can I further reduce the delay?

@bbcallen
Copy link
Contributor

bbcallen commented May 8, 2014

Set these values to 0 is OK. In fact, the original ffplay doesn't have these limit.

#define DEFAULT_MAX_HIGH_WATER_MARK_IN_MS       (0)
#define DEFAULT_NORMAL_HIGH_WATER_MARK_IN_MS    (0)
#define DEFAULT_FAST_HIGH_WATER_MARK_IN_MS      (0)

I add them for streaming video on network with bad quality traffic.

Also have a look at these code commented out by me.

#ifdef FFP_MERGE
        if (is->paused != is->last_paused) {
            is->last_paused = is->paused;
            if (is->paused)
                is->read_pause_return = av_read_pause(ic);
            else
                av_read_play(ic);
        }
#endif
#if CONFIG_RTSP_DEMUXER || CONFIG_MMSH_PROTOCOL
        if (is->paused &&
                (!strcmp(ic->iformat->name, "rtsp") ||
                 (ic->pb && !strncmp(ffp->input_filename, "mmsh:", 5)))) {
            /* wait 10 ms to avoid trying to get another packet */
            /* XXX: horrible */
            SDL_Delay(10);
            continue;
        }
#endif

I'm not sure if they are related to the delay.

@tulkas85
Copy link
Author

I confirm that MIN_FRAMES 5 reduce delay, but video stream is less stable on long durate. Videoview often goes in error state.
I don't see improvements by varying other parameters

@bbcallen
Copy link
Contributor

No idea at all. Try your local ffplay from apt-get, yum, macport, hombrew, blablabla.

@loveq369
Copy link

What's the meaning "FFP_MERGE".

@adilmalik07
Copy link

I'm getting a delay of 4-7 seconds on iOS using this library while ffplay has <=1 second delay on mac using local wifi. Any idea how to resolve this issue?

@progamertr
Copy link

Which client do you get under 1 second latency ?

Are you sure that both your clients use same transport layer ?

@adilmalik07
Copy link

I try to play stream using ffplay from terminal and there was a latency for ~1 second.

Also what is the best to integrate this library in another project because currently files being used are very scattered.

@jsumitro-appscore
Copy link

I try to play an UDP stream and I am experiencing a significant delay, about 7 seconds.
I have modify the macros in ff_ffplay_def.h and re-compile the library by running the compile-ffmpeg and compile-ijk again. However, the delays remains the same.

Any idea why? Is there any macros that needs to be changed as well?

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

6 participants