Just like ExifInterface.TAG_ORIENTATION's working for JPEG, how can I retrieve orientation info for video ?
For example I record a video in portrait mode, the orientation of video should be 90 or 270.
And when I record a video in landscape mode, the value should be 0 or 180.
When playing video, MediaPlayer in SDK always works correctly, but I don't find any way to retrieve this info.
Finally, if I cannot get orientation of video using android SDK, can I get this info using FFMPEG ?
Thanks very much for your help~
You can do this using FFmpeg:
$ ffprobe -show_streams input.avi | grep rotate
TAG:rotate=90
$
I found the following blog post that shows how to get the metadata of a media file. All functionality requires API level >= 10 though.
Related
I'm building a website. I'm trying to load my first video onto it. This mp4 video is in portrait orientation and was recorded on an Android device.
When I load this mp4 onto my website, it plays perfectly (in portrait orientation) on Chrome; however, it plays in landscape orientation on Firefox & IE. I realise that this is because Chrome is using the rotation metadata that is stored within the mp4 to play the video in the correct orientation, while FF & IE don't use this metadata.
I've tried to correct this issue using FFMPEG, and various combinations of the Transpose, Metadata & Rotate commands. I am using MediaInfo to view the metadata associated with the files that I produce using FFMPEG.
My problem is:
1) If I use Transpose=1, then on FF & IE & Windows Media Player, the resulting video is actually rotated through 180 degrees, and the metadata shows the file width and depth to be the same as the original file.
2) If I use -metadata:s:v rotate=0 (I've also tried rotate=90), then MediaInfo tells me that the resulting files width & depth are now portrait, but FF & IE & WMP will not play the resulting file. WMP plays the sound but no image, and FF gives an error message "Error Loading This Resource".
What ffmpeg command do I need to use to convert a portrait MP4 recorded an android device into an mp4 that will play in the correct orientation on Firefox?
Thanks in advance
You will have to re-encode it to "physically" rotate the video if you want the browsers or players that do not respect the rotation metadata to play it using the proper orientation.
A modern version of ffmpeg will automatically rotate the video according to the rotation metadata (and will avoid copying the input rotation metadata to the output), so just run:
ffmpeg -i input.mp4 -c:a copy -movflags +faststart output.mp4
Hello android developers,
I am using camera API, and facing a problem which cause the front camera video flip mirror when finish record and display on videoView.
So is there a solution to scale the Camera/VideoView mirroring?
If the problem was in picture I could use matrix scale on the image.
Thanks for helping.
You cannot do this with MediaRecorder because it's not an orientation problem, it's about frames that you have to mirroir yourself to achieve this result.
The optimal solution is to use ffmpeg which is one of the best tool to do the video morroring with command line. With this tool you can still record with MediaRecorder and use ffmpeg command after recording to reverse frames but if your video is too large it can be long to treat and therefore does not meet the need.
Another way would be using OpenCV with ffmpeg to get the mirorred video at the end of the recording.
I have developed an android/ios video sharing app that records a video and uploads it to amazon s3. For compatibility both android/ios record in mp4 format with H264/AAC codecs.
The users might shoot portrait or landscape and the app, getting info from the sensors, set the rotation of the file (mediarecorder.setOrientationHint on android and something similar on iOS)
The videos from iOS play fine on android and vice versa. The problem is when i want to play a video on a web browser. The browsers that support mp4 format (ie, chrome) display the video but ignore the rotation metadata. The same thing happens when i playback those videos with mplayer on linux.
The first solution that comes to mind is
ffmpeg -i in.mp4 -vf transpose=<rotation value> out.mp4
Is there a reason why browsers ignore rotation metadata? Is it a bug? Could i do something to fix this while recording the video?
Here are 2 sample from iOS and android respectively.
Thansk
ios video
android video
Method 1: Rotate the HTML Element if the aspect ratio is not horizontal
Chrome HTML5 Video Flipping Portrait Sideways
Method 2: Re-encode the iPhone-Video
Displaying vertical videos with html5 on chrome
Method 3: Set orientation properly on iOS-Devices (Advanced)
iOS AVFoundation: Setting Orientation of Video
Method 4: Ask this guy if he has found an answer
Use FFmpeg to rotate the video based on its <rotate> metadata? Why does Android put the wrong metadata?
How to get video orientation using ffmpeg? I am using ffmpeg on android.
It seems ffmpeg not taking care automatically, in android lower versions I could not find api, so trying using ffmpeg. In android there is metadataretriver but it's api level is 17.
Please suggest way for this.
Are you looking for the syntax of the transpose filter? For instance, to rotate the input by 90 degrees counter-clockwise:
ffmpeg -i input -vf "transpose=1" output
If not, could you detail your request a little bit more?
I want to change the video call quality . i have just started using Quickblox so any help regarding it is appreciated.
My requirement is transmitting 720p video at 30fps and i also want to know whats the max best video quality that quickblox can transmit.
Unfortunately with current version some issues may occur with 720p. We are now working on new realization (WebRTC SDK for Web,iOS,Android) with which 720p video streaming will be possible. We expect to release it by the end of January.