i'm starting decode/encode videos app , seems bigflake's site authoritative reference working video code. i've copied extractmpegframestest_egl14.java project , modified use different file paths, nothing else. extracts frames pre recorded videos copy device. however, when trying use video recorded device's camera frames horizontal lines:
after testing different recorded videos realised problem comes rotated videos. device's camera encodes frames come framebuffer , slaps rotation tag on video. can extracted mediaformat object:
int rotation = format.getinteger("rotation-degrees"); unfortunately swapping width/height of saved image doesn't alter anything, images still corrupted. has done save code handle rotated frames correctly?
as hinted source code comment pointed out answer, opengl requires transforming image. original invert boolean helps sources have not been rotated or have rotation of 180 degrees. other orientations (90 , 270) display flipped image, have flipped too.
here changes did handle rotation correctly:
- read
rotation-degreesattribute (when available) source media. - modify
codecoutputsurfaceconstructor accept numerical rotation parameter, stored inmrotationinstance variable. - modify original
invertcode used when rotation 0 or 180. - use different matrix transformation when rotation 90 or 270.
you can full modified version the following gist take @ individual changes mentioned above.

Comments
Post a Comment