RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
238 stars 29 forks source link

FirstFrameReady not fired on specific iOS devices #1266

Closed christianYS closed 1 year ago

christianYS commented 2 years ago

Describe the issue We have received reports from some of our users that any MP4 videos won't start playing on iPhones and iPads. This seems to be a rare issue, but when it occurs it persists even after uninstalling and reinstalling the app. We haven't been able to reproduce the issue in-house, but it seems to be happening out in the wild. From our observations seems that the AvPro plugin does not fire the FirstFrameReady event, which we use to automatically start the video. Trying to reproduce the issue on the same phone model and iOS version (but different device) doesn't seem to guarantee a reproduction. So my question is:

What are the causes for FirstFrameReady not triggering on iOS, and is it possible that somehow something gets jammed in a specific device so that even uninstalling the app won't solve the issue? Is it a caching issue?

Your Setup (please complete the following information):

To Reproduce

  1. Call OpenMedia(<remotePath>, autoPlay: false)
  2. Wait for FirstFrameReady event
  3. Call .Play()

Observation: in some specific iOS devices FirstFrameReady is not called, no errors are thrown, video loads indefinitely. Expected: FirstFrameReady or Error event is triggered

We have tried to mitigate the issue by forcing Start() after some time, but that results in the video texture being black, and only audio plays. I'll send a reproduction video via email.

Chris-RH commented 2 years ago

Hi @christianYS,

I just wanted to double check, this is for all your videos, not just some of them? Our iOS/macOS dev is on holiday this week, but he should be back from 30th August.

christianYS commented 2 years ago

When it happens, it's on all videos.

Chris-RH commented 2 years ago

Email received, thank you. I'll get the dev to look at it next week. I'm sorry that it can't be any sooner.

MorrisRH commented 2 years ago

Thanks for sending on links to the videos you're using. Unfortunately I've not been able to reproduce the issue here however I am wondering if your user had been using AirPlay previously to running your application.

I noticed in the image of the player settings you sent over that "Allow External Playback" was checked, this means that media will playback over the external route automatically if AirPlay has already been enabled. This does explain why the "FirstFrameReady" event wouldn't fire as the MediaPlayer instance would no longer be responsible for decoding the video.

If you don't need AirPlay support in your application then I would recommend unchecking "Allow External Playback".

huujiee commented 2 years ago

Same. Unity version: 2018.4.30f AVPro Video version: 2.5.1 Devices: iPhone 11; iOS 15.6

And "Allow External Playback" is not checked.

Our user reports is most on iOS 15.6+.

MorrisRH commented 2 years ago

The common factor here does seem to be iOS 15.6 although frustratingly I am running iOS 15.6.1 and not seeing this issue.

It would seem that this is not related to AirPlay in any way.

If you're able, could you enable "Use single player item" in the iOS section of the media player properties and see if that fixes things? (Even if it doesn't it will help rule out some possibilities).

Any further information you can provide about how your media player instances are configured and how you are using them from script would be very useful.

huujiee commented 2 years ago

Thanks a lot, and we will try it :).

Chris-RH commented 2 years ago

@huujiee Did that help? Are you still having problems? if so could you provide any further info?

huujiee commented 2 years ago

It does not work.

The iOS device upgrade to 16.0.2 with same, so maybe the device os version is not the main issue;

And we found that the player.TextureProducer.GetTextureCount() always returns 0 even it is playing only sound.

Here is the video info:

{ "streams": [ { "index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_tag_string": "avc1", "codec_tag": "0x31637661", "width": 1920, "height": 1080, "coded_width": 1920, "coded_height": 1080, "closed_captions": 0, "film_grain": 0, "has_b_frames": 1, "pix_fmt": "yuv420p", "level": 41, "color_range": "tv", "color_space": "bt709", "color_transfer": "bt709", "color_primaries": "bt709", "chroma_location": "left", "field_order": "progressive", "refs": 1, "is_avc": "true", "nal_length_size": "4", "id": "0x1", "r_frame_rate": "30/1", "avg_frame_rate": "30/1", "time_base": "1/600", "start_pts": 0, "start_time": "0.000000", "duration_ts": 17140, "duration": "28.566667", "bit_rate": "13484003", "bits_per_raw_sample": "8", "nb_frames": "857", "extradata_size": 35, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "creation_time": "2022-10-10T06:58:34.000000Z", "language": "und", "handler_name": "Core Media Video", "vendor_id": "[0][0][0][0]", "encoder": "H.264" } }, { "index": 1, "codec_name": "aac", "codec_long_name": "AAC (Advanced Audio Coding)", "profile": "LC", "codec_type": "audio", "codec_tag_string": "mp4a", "codec_tag": "0x6134706d", "sample_fmt": "fltp", "sample_rate": "44100", "channels": 2, "channel_layout": "stereo", "bits_per_sample": 0, "initial_padding": 0, "id": "0x2", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/44100", "start_pts": 0, "start_time": "0.000000", "duration_ts": 1259520, "duration": "28.560544", "bit_rate": "124536", "nb_frames": "1233", "extradata_size": 2, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "creation_time": "2022-10-10T06:58:34.000000Z", "language": "und", "handler_name": "Core Media Audio", "vendor_id": "[0][0][0][0]" } } ], "format": { "filename": "166538536822290d3a0370c7c4529e9eaea35d3c6b5f1.mp4", "nb_streams": 2, "nb_programs": 0, "format_name": "mov,mp4,m4a,3gp,3g2,mj2", "format_long_name": "QuickTime / MOV", "start_time": "0.000000", "duration": "28.566667", "size": "48614382", "bit_rate": "13614295", "probe_score": 100, "tags": { "major_brand": "qt ", "minor_version": "0", "compatible_brands": "qt ", "creation_time": "2022-10-10T06:58:34.000000Z" } } }

MorrisRH commented 2 years ago

Hey @huujiee Thanks for the video info. Is it being played locally or being streamed? If streamed is it HLS?

huujiee commented 2 years ago

Hey @huujiee Thanks for the video info. Is it being played locally or being streamed? If streamed is it HLS?

Streamed url like https://***.mp4

Chris-RH commented 1 year ago

Closing for now as we still can't reproduce this