Search Unity

Resolved Color primaries 0 is unknown or unsupported by WindowsMediaFoundation

Discussion in 'Audio & Video' started by _eternal, Oct 23, 2023.

  1. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    When I import an h.264-encoded video into Unity, I'm running into a similar problem as described in this thread: https://forum.unity.com/threads/win...k-to-default-this-may-result-in-rend.1311342/

    According to the explanation given by Unity staff, the warning should go away if you pick a color space for the video instead of leaving it undefined.

    For whatever reason, the color space option in my Premiere Pro is greyed out, even though it defaults to Rec 709. I exported the video anyway, and then figured out how to make a copy of the original video but with the BT.709 tags applied to the metadata. I'm using the following ffmpeg command:

    Code (CSharp):
    1. ffmpeg -i "input.mp4" -c copy -colorspace 1 -color_primaries 1 -color_trc 1 -color_range 1 "output.mp4"
    Here's the resulting metadata of output.mp4 in MediaInfo - note that you can see the BT.709 tags at the bottom.



    However, when I try to import this file into Unity, it's still giving that warning about unknown color primaries! The only way I've been able to get rid of the warning is to re-encode the file with ffmpeg with these tags, but that's obviously not ideal. I just want to apply the metadata tags so that Unity will stop giving the warning, without re-encoding the original video.

    I guess my question is: what is Unity looking at to determine that the color space is unspecified?

    P.S. I know I can avoid the warning by transcoding the video to VP8 in the import settings, but the transcode process is slow, and it seems like the wrong solution to the problem.
     
  2. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    Okay, bug report submitted at IN-58556.

    If any staff are here, please take a look at this. As I discovered in IN-56488, the bug report system is apparently broken, and the QA staff need to manually do something to approve new reports.
     
  3. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Yeah, the issue is that MediaFoundation only reads the metadata in the SPS Nalu and not the colr box in the mp4 header. Meaning it needs to be set by the encoder when encoding. In your case, your command is only setting it in the header. What you should do is:
    Code (CSharp):
    1. ffmpeg -i input.mp4 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range pc -vcodec libx264 -profile:v baseline output.mp4
    Unfortunately, it will still transcode the file but at the very least outside the editor.
     
    _eternal likes this.
  4. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    Interesting, okay. Thanks for the explanation. Someday I might try to figure out why Premiere Pro can't set it itself, but for now I guess transcoding is fine.

    (I can't see/reply to the bug report itself because of the Jira bug, but I get email notifs from it, so I can see your comment there)