2015-04-24 46 views
1

我正在關注ExtractMpegFramesTest後從視頻中提取PNG幀。 這適用於以橫向模式錄製的視頻,但不適用於以縱向模式錄製的視頻。ExtractMpegFramesTest在Android中的肖像模式下錄製的視頻有問題

有誰知道如何使用上述鏈接中提供的解決方案從縱向視頻生成PNG幀嗎?

我已經測試過720p和1080p視頻。

夫婦的事情,我觀察到的,

MediaExtractor給出寬度和高度1280和720p視頻720與取向無關。這應該是橫向1280 x 720和縱向720 x 1280。在1080p視頻中的類似情況。

其他的事情是,當我在反轉參數中的方法drawFrame中傳遞false時,PNG幀很好,但倒過來。

編輯:

隨着ExtractMpegFramesTest我得到這個結果

景觀視頻與反轉參數真正給人完美的形象與 http://postimg.org/image/qdliypuj5/

肖像視頻轉化參數真正讓失真的圖像 http://postimg.org/image/vfb7dwvdx/

縱向視頻與我nvert參數假給人完美的顛倒的圖像。(據@Peter Tran的答案輸出可通過旋轉位圖是固定的。) http://postimg.org/image/p7km4iimf/

+0

你的問題又是什麼? http://stackoverflow.com/help/how-to-ask – shkschneider

+0

@shkschneider問題編輯。 – Ankit

+0

請確定「不起作用」的含義。視頻以設備相機的物理方向進行錄製,並由玩家自行修正方向。 ExtractMpegFramesTest示例會忽略方向提示,因此您會以原始物理方向看到它。 – fadden

回答

1

在爲saveFrame評論ExtractMpegFramesTest,它指出了

 // Making this even more interesting is the upside-down nature of GL, which means 
     // our output will look upside-down relative to what appears on screen if the 
     // typical GL conventions are used. (For ExtractMpegFrameTest, we avoid the issue 
     // by inverting the frame when we render it.) 

這就是爲什麼您提到的drawFrame的布爾參數。

所以這聽起來像你想要做的是保存到PNG之前顛倒位圖。這可以通過將Matrix(with preScale)應用於位圖來完成。在致電bmp.copyPixelsFromBuffer後,您需要修改saveFrame中的代碼。

請參閱此answer for mirroring a bitmap;並使用preScale(-1,1)來反轉正確軸上的圖像。