Add video format detection and support for 4:2:2 formats
Preface: I don't have much experience with Go, but this has worked for me and I figured I might as well open a PR for visibility. I don't plan on adjusting the PR. Feel free to take the code as is or use it as inspiration for a more proper implementation; or simply close the PR if this is not something that is desirabe to have.
I use go-transcode to be able to preview stock videos (many of them quite old and with now outdated video encoding) on the web as part of a larger media management system (for a custom-built DAM service). I ran into the issue that transcoding a video with a 4:2:2 format didn't work, because the high preset doesn't support 4:2:2 chroma subsampling. To fix this, I added basic video format detection and made it so that the high422 profile is used if a video with any 4:2:2 format is detected.
According to the ffmpeg docs the high422 profile only supports yuv420p, yuv422p, yuv420p10le and yuv422p10le, which is something I only realized after looking up all the 4:2:2 formats I was able to find. I still kept all of them in the is422Format check and using the high422 profile might or might not work for them.