简体   繁体   中英

AVPlayer not playing HTTP Live stream without audio

I have an AVPlayer which is streaming a live HLS stream. I am using following code.

-(void)initPlayer{

self.mPlaybackView = [[AVPlayerPlaybackView alloc] initWithFrame:mPlaybackViewFrame];
[mPlaybackView setVideoFillMode:@"AVLayerVideoGravityResizeAspectFill"];

NSURL *url = [NSURL URLWithString:mCamera.url];
self.playerItem = [AVPlayerItem playerItemWithURL:url];
self.mPlayer = [AVPlayer playerWithPlayerItem:playerItem];

[mPlayer addObserver:self forKeyPath:@"status" options:0 context:AVPlayerPlaybackViewControllerStatusObservationContext];

}

//observer

- (void)observeValueForKeyPath:(NSString*)path ofObject:(id)object change:(NSDictionary*)change context:(void*)context
{

AVPlayer* mPlayer1 = (AVPlayer*)object;
if ([path isEqualToString:@"status"])
{
    NSLog(@"Video Player status %i",mPlayer1.status);
    if (mPlayer1.status == 2)
    {
        [self itemDidFinishPlaying];
    }
    if (mPlayer1.status == AVPlayerStatusReadyToPlay)
    {


        [mPlaybackView setPlayer:mPlayer];
        [mPlayer play];

    }
}
}

Reference: https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html#//apple_ref/doc/uid/TP40010188-CH3-SW1

My Problem

AVplayer is not playing my live stream video if there is no audio channel in it. I'm using Wowza as my media server. Live streams are camera feeds. I'm able to play multiple instances of AVPlayer without any problem (with audio).

Media validator tool response

VIDEO 1

mediastreamvalidator: Beta Version 1.1(131115)

Validating http://xx.xx.xx.xx/live/127.stream/playlist.m3u8
Validating child playlist chunklist_w101231837.m3u8 [193.55 kbits/sec]

Segment processing interrupted: chunklist_w101231837.m3u8 - 32 out of 32 segments processed...

--------------------------------------------------------------------------------
http://xx.xx.xx.xx/live/127.stream/playlist.m3u8
--------------------------------------------------------------------------------

Playlist Syntax: 

Warning: (0:-12274) PROGRAM-ID has been deprecated and is no longer a valid attribute for #EXT-X-STREAM-INF
--> #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=193548,CODECS="avc1.66.41, mp4a.40.2",RESOLUTION=640x480

Alternate playlist(s):

--------------------------------------------------------------------------------
chunklist_w101231837.m3u8
--------------------------------------------------------------------------------

Playlist Syntax:    OK

Processed 32 out of 32 segments:

media_w101231837_191.ts:

WARNING: Media segment bandwidth exceeded target playlist bandwidth by 12 % (216.43 kbits/sec vs.193.55 kbits/sec, limit is 10 %).

media_w101231837_192.ts:

WARNING: Media segment bandwidth exceeded target playlist bandwidth by 15 % (221.86 kbits/sec vs.193.55 kbits/sec, limit is 10 %).

 media_w101231837_195.ts:

WARNING: Media segment bandwidth exceeded target playlist bandwidth by 15 % (222.77 kbits/sec vs.193.55 kbits/sec, limit is 10 %).

 Average segment duration: 9.93 seconds
 Playlist target bitrate: 193.55 kbits/sec
 Segment bitrate: Average: 189.54 kbits/sec, Max: 222.77 kbits/sec (exceeds target by 15.10 %)
 Average segment structural overhead: 13.50 kbits/sec (7.13 %)

I am using Stitched Stream Player Given in apple developer's sample code..

May u get help from it..

I don't know if it solves the problem in your case, but this is some important information I've discovered when playing HTTP Live stream videos without audio:

The status of a AVPlayerItem does only change to 'ready to play' when a video layer showing the item is added to the view hierarchy. This is not the case if the video contains audio.

The status of AVPlayer still changes to 'ready to play' even if you don't add a video layer to the view hierarchy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM