简体   繁体   English

在不使用元数据旋转标签的情况下在Android上旋转Mp4

[英]Rotating an Mp4 on android without using the metadata rotation tag

I'm having a problem which I have spent the past few days trying to resolve regarding MP4 file rotation on Android. 我有一个问题,过去几天我一直在尝试解决有关Android上MP4文件旋转的问题。 I'm currently working on application which will send the MP4 file across from an android device as a byte stream to be played on another device. 我目前正在开发应用程序,该应用程序将从android设备发送MP4文件作为字节流,以在另一台设备上播放。

The problem I'm having is that videos recorded in portrait mode on the android device are being displayed rotated 90 degrees on the player receiving the stream. 我遇到的问题是,在Android设备上以纵向模式录制的视频在接收流的播放器上旋转了90度。

I have tried creating a new MP4 from the original with rotation changed using MP4Parser . 我尝试使用MP4Parser从原始文件中创建一个新的MP4,并对其旋转进行了更改。 I have also tried changing the rotation by creating a new MP4 changing the key-rotation in the media format and have also tried changing orientation hint when creating a new Muxer. 我还尝试通过创建新的MP4来更改旋转方式 ,以更改媒体格式中的键旋转 ,并且还尝试了在创建新的Muxer时更改方向提示

All of these methods work but only seem to change the rotation metadata. 所有这些方法都可以工作,但似乎只能更改旋转元数据。 In some players this metadata is being read and a rotation is being applied. 在某些播放器中,正在读取此元数据并正在应用轮换。 However, the player used in the target player used for our application is not capable of reading this metadata. 但是,用于我们应用程序的目标播放器中使用的播放器无法读取此元数据。

my only solution would be to create a temporary MP4 which has had the video data rotated then send that across instead. 我唯一的解决方案是创建一个临时MP4,该视频已旋转了视频数据,然后将其发送出去。 I've found resources to rotate individual YUV image frames within an MP4 but my question is how can I retrieve these frames from an inputted MP4 and write the modified one to a new file? 我找到了在MP4中旋转单个YUV图像帧的资源,但我的问题是如何从输入的MP4中检索这些帧并将修改后的帧写入新文件?


NOTE : I'm building the application with Xamarin and I've tried using FFMPEG but adding the binaries would make the project too large and I also have concerns about licensing. 注意 :我正在使用Xamarin构建应用程序,并且尝试使用FFMPEG,但是添加二进制文件会使项目太大,并且我也担心许可问题。

我们最终使用FFMPEG实现,将文件发送到其他地方进行转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM