#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2016, Florent Thiery

import os

temp = "gst-launch-1.0 videotestsrc num-buffers=10 ! video/x-raw\,\ format\=\(string\)%s\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\ framerate\=\(fraction\)30/1 ! vaapipostproc ! vaapih264enc rate-control=2 bitrate=20000 keyframe-period=30 ! fakesink"

csp = 'I420, YV12,  NV12, YUY2, UYVY, AYUV, RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, Y444, v210, v216, NV21, NV16, NV61, NV24, GRAY8, GRAY16_BE, GRAY16_LE, v308, IYU2, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE, I422_10LE, I422_10BE, Y444_10LE, Y444_10BE, GBR, GBR_10LE, GBR_10BE, NV12_64Z32, A420_10LE, A420_10BE, A422_10LE, A422_10BE, A444_10LE, A444_10BE, P010_10LE, P010_10BE'

ok = list()
fail = list()

for c in csp.split(', '):
    p = temp % c
    if os.system(p) == 0:
        ok.append(c)
    else:
        fail.append(c)

print('Success: %s' % ok)
print('Fail: %s' %fail)

