bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.46k stars 8.12k forks source link

Video is too slow but audio is fine. #1818

Open glm4 opened 8 years ago

glm4 commented 8 years ago

Hello, thanks for this awesome work. I have an issue with an RTMP live stream playback. The thing is the audio is OK but the video is running too slow(like in slow motion). Here is my code

    let options = IJKFFOptions.optionsByDefault()
    player = IJKFFMoviePlayerController(contentURLString: "rtmp://192.168.1.167:1935/live/streamName", withOptions: options)

    player!.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
    player!.view.frame = view.bounds
    player!.scalingMode = .AspectFit
    player!.setPauseInBackground(true)
    view.autoresizesSubviews = true
    liveView.insertSubview(player!.view, belowSubview: activityIndicator)
    player!.prepareToPlay()
    player!.play()

Thanks in advance.

xinzhengzhang commented 8 years ago

Can you provide any sample stream for this issue?

glm4 commented 8 years ago

My encoding configuration is the following:

stream.captureSettings = [

audioSettings = [ "bitrate": 44100 ]

Lowering the bitrates and quality of video makes no difference.

xinzhengzhang commented 8 years ago

Have a look real fps at hud view (click right top button in ijk demo) From your description, it seems that the fps of decoded stream was much slower than you pushed.

To ensure the pushed stream was fine, please check it in some different player like VLC. If it works fine, I need some more information outputted in the console.

thinkperson commented 8 years ago

I have the same problem.Here is my hud view:

xinzhengzhang commented 8 years ago

@thinkperson where?

thinkperson commented 8 years ago

Attachment could't be submit.The key is : vcodec VideoToolBox fps 6.65/6.66 v-cache 48.40 sec, 2.83MB, 1210 packets a-cache 9.73 sec, 98.1 KB, 304 packets delay 0.000 38.363

6david9 commented 8 years ago

I have the same proplem when playing rtmp. The video is delayed than audio. Test stream is: rtmp://live.hkstv.hk.lxdns.com/live/hks

takezou621 commented 8 years ago

me too.I build with ver k0.6.2.2. (no customized) test stream is same above rtmp://live.hkstv.hk.lxdns.com/live/hks. When I check with VLC is fine. How do I configure this?

6david9 commented 8 years ago

Create player with below options can fix video/audio not sync problem:

IJKFFOptions *options = [IJKFFOptions optionsByDefault];
[options setPlayerOptionIntValue:1      forKey:@"framedrop"];

@sherm4n90 @takezou621

JKalash commented 7 years ago

Having same problem. HUD shows fps of 10/11 where was RTMP source stream is 24fps. Any idea?

xinzhengzhang commented 7 years ago

Mostly it is your decoder speed can not keep up with display speed.

  1. Try hardware decoding mediacodec for Android and videotoolbox for iOS.
  2. Compress your source quality.