Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

MP4-video not playing on any platform

Discussion in '5.6 Beta' started by roumenf, Mar 27, 2017.

  1. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    Hi there,

    Can someone tell me what's wrong with this video: https://ratemt.com/downloads/portrait-gafni.mp4
    I can send it as file, as well.

    The audio plays OK, but video is missing. The codec is H264, frame rate: 25, resolution: 640x352. It is even playable as video clip in Inspector, but the VideoPlayer-component doesn't want to play it, on any platform I tried so far. I use Unity 5.6.0f1.
     
    Last edited: Mar 27, 2017
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi roumenf,

    I cannot download your video (403 forbidden...). Can you submit a bug with the platform info so we can reproduce and a minimal project that uses it?

    Thanks!

    Dominique
    A/V developer at Unity
     
  3. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    Hi Dominique,

    Thank you for the rapid response! I uploaded the same video here: https://ratemt.com/downloads/portrait-gafni.mp4
    I can send you more videos as well, with the same format (and same result), but they are longer and bigger in size than this one. The videos are in German, but the audio/speech is not important at the moment.

    Now it's almost midnight here, tomorrow I'll submit a bug, if still needed. The platforms I tested so far the video on are: Windows Standalone, Android, Mac OS X, UWP (Windows-10), with the same result. Tomorrow I'll check the iOS build, too.

    The scene is just a video plane (UI RawImage) with controls to play/pause and seek time, with AudioSource-component, and a script that creates the VideoPlayer and processes the UI controls input. The issues are:
    1. Prepare() doesn't finish within 5 seconds and times out.
    2. When I play the video, the plane remains white, while the audio starts between 5th and 6th second, as expected.

    Greetings!
     
  4. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi again!

    OK, I got your file. Trying it on OSX, I do get the same problem as you are mentioning. AVFoundation (the library used to play on OSX and iOS) reports this file may not be playable (no explanation so far but I'm on it). Maybe it's the resolution (640x352 is a little odd) or some of the encoding settings. Can you tell us how the video was produced in case it helps explaining what's happening (and ultimately how to support these types of files?).

    Submitting a bug would be best as this is the central place for us to track issues.

    Thanks for bringing this to our attention and hope we can find a workaround (or a fix) quickly!

    Dominique
     
  5. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi roumenf,

    Following-up: I was able to re-encode your video so it is supported by AVFoundation - the OSX system library used by Unity to implement video playback. I noticed your video was encoded using the H.264 codec High profile, level 3.1. This doesn't appear to be a very well supported profile on AVFoundation. I can dig more to find exactly what feature of this profile level causes AVFoundation to be incapable of playing the file; I may do just that when I investigate the bug you'll submit, as well as investigate what happens on the other platforms.

    Re-encoding using the H.264 Baseline profile, level 3.0, provided a movie with the same frame rate, resolution and audio track as the original, but this one plays fine in Unity on OSX. The size becomes a bit smaller: 28970128 bytes instead of 38712975 for the original.

    To experiment and investigate with video file formats, my two tools of choice are mediainfo (https://mediaarea.net/en/MediaInfo) and ffmpeg (https://ffmpeg.org).

    On OSX, issuing

    mediainfo -f portrait-gafni.mp4

    on the command-line gave me the information I needed about the video codec parameters.

    And

    ffmpeg -i portrait-gafni.mp4 -c:v libx264 -profile:v baseline -strict -2 test.mp4

    gave me a test video that was playable. In a real production, you'd probably try to encode your video with this profile in the first place, since transcoding like I did from your file adds one generation of digital degradation due to the aded decode-encode cycle. You can of course decide to live with this slight quality loss, it really depends on how you use the media and how critically you are trying to control the viewing quality.

    Over time, we'll improve the VideoPlayer and the VideoClipImporter so they give more information about the file's content and detect better the reason why a given file is not supported. Showing the codec profile and level in the importer, for instance, will have to be added soon because this is a critical piece of information.

    Hope this helps and again, thanks for reporting this issue!

    Dominique
     
  6. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    Hi Dominique,

    Thank you again, for following up the issue so quickly, and for the workaround suggestions, as well! I'll try to re-code some videos as you suggested, try again, and then I'll share my experience here. Anyway, I still don't understand this: When you select the video clip in Assets there is a preview of the video. You can click play, and the videos play correctly...

    I submitted a bug today, as you requested, with the same name as this thread. I included this one and one more similar video, as well as the reference 'big_buck_bunny.mp4' video, which plays correctly on all platforms except Android. By the way, do you know the problem with VideoPlayer on Android still persists? I started keeping track on the VideoPlayer-component developments since Unity5.6.0b9, but since then no video I tried has ever been played correctly on Android, even the reference video. Or, I'm missing some player setting there.. ;)

    FYI: We're about to develop a multi-platform school app, in which the VideoPlayer (play, pause, seek forward & backward) will play central role. And, because of the multi-platform capabilities and the upcoming native video-player component, we have decided for Unity as primary development tool for this app.

    Greetings,
    Rumen
     
    Last edited: Mar 28, 2017
  7. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi Rumen!

    A few precisions:

    At least on the OSX editor, the code that creates the thumbnail and the code that does the playback is not the same, so it's expected there will be differences in capabilities. These capabilities even vary between OSX versions. On my side, I never got the playback (in-game or in preview) to work before I transcoded the video. So our job here is not necessarily to "always make it play" (this may be simply impossible if the OSX libraries don't do it), but at least to tell you something like "it doesn't play because this video has profile xyz, please try encoding with profile abc instead".

    Excellent! Please post the bug number on this thread so others can follow and I can make sure it's directed to us.

    We've been making good improvements to the Android side of things up until the very last minute of the 5.6 release, so make sure you try with the latest build you can get your hands on. The Android development and testing has been focused on Android 6.0.1+ until recently, so many issues with OSes 4.x and 5.x went unnoticed until very recently. 4.1.x and 4.2.x are still causing trouble on some devices but we'll keep improving this. It'd be nice if you could also post the Android device and OS info that you are using to this thread so I can make sure to add these to our coverage testing if not done already.

    Again here: please submit bugs (after you had a chance to try a recent build of course) so we can make sure we test your scenarios. As you are finding out: the potential for variations in videos is just endless, so every new type of video we can get our hands on will make the VideoPlayer more robust (provided they're within Android and vendor specs of course).

    Very good to hear! Keep us informed of your progress and report back here if you have trouble, we'll be happy to help.

    Dominique
     
  8. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Another update: I tried the portrait-gafni.mp4 video (original format) on my Windows 10 machine and it plays fine, both in the preview and play mode. This is on the latest 5.6 version (what is likely to become the official 5.6 release).

    So please let me know if this behaves differently for you on this latest Unity version and state your Windows version if so, as well as the error message you get, if any.

    Dominique
     
  9. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    Wow, that sounds great! Do you mind Unity 5.6.0f2? I just saw it is available as beta since recently.
    I'll install and test it tomorrow on all platforms I have, and then will tell you how it goes.
    Here is the link to the bug I filed today: https://fogbugz.unity3d.com/default.asp?895741_jb1c2f45v9vspegp
    Thanks again, Dominique!
     
  10. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Internally, we have an f3 that we are working on, but it is not released yet: this will probably be the the final one. f3 will include a number of Android-specific VideoPlayer fixes as well as a few non-platform-specific VideoPlayer fixes (which I doubt would affect the behaviour of the playback for this video anyways).

    Not sure how much luck you will have with this video given the Android profile recommendations (baseline, as stated here: https://developer.android.com/guide/topics/media/media-formats.html#video-formats), but vendors are free to go beyond the minimum recommendations so your mileage will vary depending on device and OS version.

    For OSX / iOS : the profile and level definitely have to be reworked on your side as the OS libraries simply don't support this profile as far as I can see (we'll look deeper when working on the bug though).

    For Windows : it worked out of the box for me on a Windows 10 machine. I have a hard time seeing what changed between f1 and f3 that would cause it to not work for you but work for me, so let's wait and see. What was the Windows version for your standalone? And what system did your UWP build run on?

    Dominique
     
    roumenf likes this.
  11. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    A short report regarding Unity5.6.0f2: Not much has changed since 5.6.0f1 ;) The video-player results are absolutely the same for the gafni-video, as before. I checked the Windows-standalone, Mac-standalone, Android, iOS & UWP platforms. The reference big-buck-bunny video still doesn't play on Android (v6.0.1). The UWP I test against is Windows-10, Target Build 14393 (Min. Build 10240).
     
  12. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    OK, thanks for verifying. As I mentioned, transcoding the video will probably help on all platforms. The fact that this works on Windows for me but not for you points to a config difference (does the video play in Windows Media Player?).

    We'll sort this all out when we get to this item in the bug fixing!

    Dominique
     
    roumenf likes this.
  13. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    Yes the video plays fine in all 'Movies & TV', 'VLC media player' and 'Windows Media Player'.

    Transcoding the video may help, but in our use-case the video will be downloaded at runtime before starting the scene with the video player. I suppose it will be played by setting the videoPlayer.url. What should I do in this case, to transcode it for the respective platform, before the playback?
     
  14. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Unless you can find a format that plays adequately on all target platforms, one thing to consider is to have various encodings for various platforms and each one would download the one that is meant for the current platform.

    http:// myserver/mygame/<platform>/video.mp4

    This is more or less what web video distribution systems do (YouTube, Netflix, ...): they adapt what they give to your player depending on what are the known capabilities of the player.

    Of course we'll make sure that every platform supports the widest range of options as possible, but since each platform does have limitations, the strategy described above is the most robust one.

    Dominique
     
    roumenf likes this.