I'm working on a project for courier service. I have developed an Android Application for our employees wich works as a camera app, they can make photos and video records with. When the photo or video file is ready, this app can automatically upload it to the server (if WiFi connection is active). The server maintains a web site where we can see each employee's daily job, including links to photo and video files. Of course, there is no problem accessing photos through any browser, but there is such problem with video files.
We don't restrict Android devices with which an employee works, only that it is powered by Android 2.3.3 or later (and certainly must have a camera). Video is written with CamcorderProfile.QUALITY_LOW setting, so it's format is up to device's decision what this CamcorderProfile.QUALITY_LOW is. There is no problem in viewing video files from varying devices on a desktop (Windows). Me and my chief have some browser plugins so this files can be open in a browser. But we want to have a video viewing solution on site that does not require any browser plugin or additional software at the client's side.
So the questions are:
What is the best video format that can enable online video viewing without downloading the whole file to the client's side (like at YouTube), video records can be very long (an hour, two hours or even more).
What tool I need for a universal conversion of Android-recorded video files to that format, without manually specifying input file format (as it can be quite different)? Our server is powered by "SMP Debian 3.2.63-2+deb7u1 x86_64".
I may have missed something. I'm sorry, this is my first project to deal with video, I lack knowledge.
I answer my own question, as it all seems decided already. After further research I came to decision that we will stream everything at our site with tag, the only source will be .mp4 (H.264), as we thought that 99.9% of our users will have no problem with it. I'a a windows user, and I have no problem with watching H.264 video in Google Chrome, Mozilla Firefox and Microsoft Internet Explorer, and so most of our clients will do.
As for video conversion into H.264, ffmpeg will do the job. I have already done some tests, all great. The real problem was to manage video rotation, as all video is recorded from Android phones in portrait mode, and it appeared that at Android this is done by recording frames in landscape mode (native camera orientation), but specifying 90 degree rotation attribute in meta data. And a great quantity of video players and Firefox refused to understand it. The problem can be solved by "transpose" and "rotate" in a command like this:
ffmpeg -i 1.avi -vf "transpose=1" -r 25 -b:a 64k -b:v 256k -metadata:s:v:0 rotate=0 r1.mp4
-vf "transpose=1" physically rotates frames 90 degrees
-metadata:s:v:0 rotate=0 clears rotation attribute in meta data because rotation is already done
Left is the job to tune parameters for output quality, write a batch conversion script, put it on crontab, and write HTML and JS to allow people to watch this video.
Related
I am building a mobile app (first in iOS), where user records one minute video and share. I searched on Internet to find out about best practices for transcoding, but nothing fruitful showed up.
My questions are:
1) Where should I transcode the video (to h264 format .mp4), in the mobile phone or send the raw video to server and then transcode there?
2) Is it even possible to transcode video locally in iOS and Android?
3) If I send video to server, then it will consume hell lot of bandwidth of user's network :(, in other hand if I transcode video locally (if thats possible), then it will drain battery and use lots of resources.
4) Any idea what would be the average file size of 1 minute of recorded video on iOS and Android? (I know its influenced by many factors and hence differs)
I checked Twitter's android mobile app, and they send 30 seconds video to server for transcoding and from their h264 .mp4 gets accessed by their web and mobile (may be)
Any suggestion and/or pointer would be appreciated
First of all you MUST transcode locally. Second, if you are in full control of capturing process then you can set the output format before starting to capture. If you are not in full control of the video capturing process then you can use ffmpeg to transcode the given video and then upload to server.
I am (at long last) at the very end of a VOD project. It works perfectly, except on Android. Basically, on Android video will not play until the entire video has downloaded. A media server was well out of scope, so we are just serving the videos up from AWS S3. Works fantastically on iOS. Both streaming and downloading the video works exactly as you would expect it to. On Android, it just doesn't seem to want to play before the download finishes. It works well when using a server on the local network (I even see the occasional buffer, so I know it's not just quickly downloading), but nothing remote.
My only guess is that it is to do with the differences in the way iOS and Android stream video. On iOS, video streams via byte-range requests. Every few seconds, it will time itself out and request another range of bytes for the file. On Android, it only sends a single request for the entire file. Not sure how that could be fixed, however.
Does anyone have any tips or pointers here? Any help would be greatly appreciated here.
Happens on Android 4.4 and 4.3.
Using both a remote prod server we own and AWS S3.
AIR 3.9 with Flex 4.11
Utilizing StageVideo and NetStream
Test devices are a Nexus 5 and a Nexus 4
The issue was with the videos themselves. AIR for Android uses the standard approach to streaming where the entire file is requested and it reads it bit-by-bit (as opposed to iOS which requests specific byte-ranges repeatedly).
The problem here is that the player cannot begin playback until the video's metadata has been read. A standard h.264 encode sees the metadata (moov atom) located at the very end of the file, so the video does not begin until the entire video has been downloaded.
Easiest way I have found to fix this is re-encoding the videos through Handbrake with the "Web Optimized" option selected. This will ensure the metadata is located at the very beginning (byte 24, I believe) so the video should begin playing instantly.
Explanation from Adobe
Thread that gave me the idea to use the "Web Optimized" option
When i run my application on the tablet(android) and hit the pause button it pauses the screen of the video but the video will jump a head how ever many seconds the pause when i un-pause the video. So if i start the video and then click pause and walk away i can come back and un-pause the video and it well jump right to the end.
The code i am using is ns.togglePause(); This same code works on the desktop and works with .flv and .f4v but will not work when i am using a mp4 on the tablet.
Has anyone seen this before or know why it would do something like this?
i am using flashdevelop to debug the application.
I found out that my problem is caused by encoding. This helped me solve my problem.I found this on adobes forms.
Video encoding is very important.
For example, use baseline profile level 3.1 for H264 for mobile
(and not High profile level 4.1 recommended for desktop).
For more information, see the MAX session of Fabio Sonnati:
"Encoding for Performance on Multiple Devices"
And if you have an Android phone/tablet, there is my AIR application
to watch Adobe MAX 2011 videos :
https://market.android.com/details?id=air.fr.inway.maxVideos2011
Search "Sonnati" for this session's video.
(For info, i use a video player based on OSMF 1.6)
The pdf presentation is available on Sonmati's blog:
http://sonnati.wordpress.com/
I am working on an Android app, that needs to do the following:
- capture a (animated) view to video including audio (from a mp3 file)
- encode the captured video (probably a bunch of raw image buffers) and audio to avi.
After searching, FFMPEG seems the most suitable. Does anybody have a sample code to accomplish what I need. I would really appreciate.
Whyhow
It's not clear what you mean by 'a (animated) view' to capture, but be aware that android apps running with normal permissions cannot access the raw framebuffer. The computation part of ffmpeg builds in the ndk without undue work and there's a lot you can read about on the web, but the output (or in your case input) drivers are a bit of a permissions problem. Also you should expect encoding to be much slower than real time unless you can somehow manage to leverage hardware acceleration features of your particular device's SOC.
if u are building your app for android then u can use .avi writer code. You can get this code from "Koders website". Search for "Koders site" on google .you will get the link. I have tested the .avi file writer code and its working fine.
I'm researching the development of an Android (2.2) app/service that will enable users to record short (I do emphasize short, < 30seconds) video on their phones and then upload that video (HTTP) to a server that will then transcode the video to other formats. That same user can download videos from other Android users and play them.
Now, I get a bit lost with everyones recommended approaches to all the issues in doing something like this because I haven't seen any ask this in a cohesive context. Ideally I would like a non commercial solution to this (as in no vendor/service being needed for the the video hosting/transcoding), but, feel free to include those as a recommendation (I've marked this as a wiki) as I know many like to use youtube and vimeo for the middle layer in all this.
The questions are
What server technologies do you
recommend for hosting and
transcoding?
What technology do you
recommend for streaming the video (it
would be nice to offer a high and
low quality encoding depending on
the users network connection)
What video format and software do you recommend for converting the uploaded video on the server to be viewable later by other Android owners.
Im assuming it's bad to do any transcoding on the phone prior to upload (battery/proc issues), but, if I'm wrong with that assumption what do you recommend?
Some things that may help you...
The video will only need to render on an Android device, and in the future in a webkit html5 browser.
Bandwidth isnt cheap (even with numerous 30 second videos), so a good mix of video quality and video file size is important (streaming if needed to ensure quality vs. download).
This is for android 2.2 devices with a video camera of course and medium to high density screen of 800x400 min.
Open source solutions (server to receive the uploads, code to do the transcoding, server to do the streaming) are preferred, but not required.
CDN's are an option, but I don't think that really figures in to the picture right now.
Check out this page to see all the video formats that Android supports for encoding and decoding.
http://developer.android.com/guide/appendix/media-formats.html
For encoding use FFmpeg or a service like encoding.com