chih-chun chan
chih-chun chan

Reputation: 146

Green screen when using mobile VLC to play rtsp streaming on iOS

I have a player on iOS based on VLC via mobileVLCKit.framework.

When executing and playing a h264 rtsp stream, iPhone will show the video correctly. However, in the beginning few seconds, there is GREEN SCREEN shown. I think the reason is that I-Frame has not arrived, and yuv=000 is mapped to green color in rgb.

Could I add some option or operation that force player to play after receiving I-Frame? Or is there some other method to avoid green screen problem?

Here is my Code

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super init];
    if (self) {
        self.player =  [[VLCMediaPlayer alloc] init];
        self.player.delegate = self;
        self.player.media = [VLCMedia mediaWithURL:[NSURL URLWithString:@"rtsp://...."]];
        self.player.drawable = self.contentView;
    }

    return self;
}

- (void)play
{
     if (self.player && !self.player.isPlaying) {
         [slef.player play];
     }
}

Any reply would be appreciated. Thanks!

Upvotes: 0

Views: 1958

Answers (1)

chih-chun chan
chih-chun chan

Reputation: 146

Actually, the modification should be in the function static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) of /modules/codec/avcodec/video.c.

Add following code in the beginning of DecodeVideo() function to skip non-I frame so that the green screen problem can be solved.

if (p_sys->b_first_frame && b_gotpicture) {
    if (AV_PICTURE_TYPE_I != frame->pict_type) {
        av_frame_unref(frame);
        break;
    }
}

And then, build mobileVLCKit.framework myself.

Upvotes: 1

Related Questions