-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display transformation matrix functions unavailable #263
Comments
go it but need few days - tipped over kids toy got a minor injury - dominant hand so need few days |
@KaFo I needed that function lately too, so I've just recoded from FFmpeg to C#. Here it is if you need it until it will be included in FFmpeg.Autogen:- static double Hypot(double x, double y) => Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
static double CONVFP(double x) => x / (1 << 16);
public static double av_display_rotation_get(byte* matrixBytes)
{
if (matrixBytes == null)
return 0;
var matrix = (UInt32*) matrixBytes;
double[] scale = new double[2];
scale[0] = Hypot(CONVFP(matrix[0]), CONVFP(matrix[3]));
scale[1] = Hypot(CONVFP(matrix[1]), CONVFP(matrix[4]));
if (scale[0] == 0 && scale[1] == 0)
return 0;
double rotation = -(Math.Atan2(CONVFP(matrix[1]) / scale[1], CONVFP(matrix[0]) / scale[0]) * 180 / Math.PI);
return rotation < 0 ? 360 + rotation : rotation;
} And this is how I use it:- double rotation = av_display_rotation_get(av_stream_get_side_data(AVStream, AVPacketSideDataType.AV_PKT_DATA_DISPLAYMATRIX, null)); (didn't tested it much yet so I hope is not buggy) P.S.: @Ruslan-B hope you feel better soon and come back with a stronger hand ;) |
In which versions this needs to be added? |
Co-authored-by: Ruslan Balanukhin <[email protected]>
Co-authored-by: Ruslan Balanukhin <[email protected]>
* Add display.h #263 (#265) Co-authored-by: Ruslan Balanukhin <[email protected]> * Fix codegen parameters in workflow (#262) --------- Co-authored-by: Ruslan Balanukhin <[email protected]> Co-authored-by: Nick Darvey <[email protected]>
Available in 5.1.2.3 and 6.0.0.2 |
great, thanks! And also thank you @SuRGeoNix for the workaround. |
Since ffmpeg 5.X, information about rotated videos (like phone recordings) are now longer provided via a stream metadata property "rotate" (with 90, 180, 270 values), but instead vbia a side_data of type DISPLAYMATRIX. See https://stackoverflow.com/a/75526656 for how to use.
To get from matrix to rotation angle, access to 3 simple display transformation matrix functions is needed:
https://ffmpeg.org/doxygen/trunk/group__lavu__video__display.html
Long story short: these functions are not yet available in FFmpeg.AutoGen and should be added.
The text was updated successfully, but these errors were encountered: