From within my app I create a video from images that the user has taken using Ffmpeg. I the play this using MediaController and a VideoView. When I run the app using the Genymotion emulator for a Google Nexus 4 the video file plays without issue. When I use the Genymotion emulator for a Samsung Galaxy S4 I get an error from the VideoView on error listener say "Can't play video".
Thanks for your help.
Converting the video using ffmpeg worked fine for my application. I hope this helps:
ffmpeg -i old.mp4 -c:v libx264 -profile:v baseline -level 1 -strict -2 new.mp4
I found this line of code somewhere else on Stack Overflow but I could not retrace where, unfortunately. So, in case someone comes across it, please link it here. The original one did not have the -strict -2 in the command.
Simply because the extension is .mp4 cannot guarantee it will be played by the MediaPlayer. If its not a supported encoding it wont play it. Please do have a look at all the supported media formats in Android here.
So introspect your code and find the type of encoding your video uses. Also if you are looking more an even powerful way to play video, you can also try out Google's Exoplayer, here.
Related
I am using ffmpeg to scale down and compress videos to be used in Android app.
The original files are played with no problem and have no metadata issues. When I re-encode them however, the Android player is able to play them, but displays wrong durations. My app is in production and it is using official player implementations, so I wonder if there is a way to fix the corruption using ffmpeg or adding some metadata to the generated files. Hopefully that's possible, but if not - any other possible fixes will be highly appreciated :)
My ffmpeg command is complex, including scaling and encoding but I can confirm this issue is reproducible on my end with the simplest ffmpeg -i video.mp4 -c:v libx264 videogen.mp4 command.
I'm leaving links to the two files if that's helpful for reference.
video.mp4
videogen.mp4
Any ideas what could be causing this and how to fix it?
Player issues showcase:
video.mp4 (original)
videogen.mp4 (re-encoded)
After some testing I found out that the player was playing fine files with the following metadata:
major_brand=mp42
encoder=Lavf58.24.101
So I used ffmpeg -movflags use_metadata_tags to set the working metadata :)
https://ymcasports.org/index.cfm/action/ynational_highlights/content_action/ynational_highlights/league/3636/album/4314#15083
The videos on this page play fine on Android but do not play on chrome for android and only audio for firefox for android.
Your Video has 4:2:2 colorspace but most hardware decoders only support 4:2:0 profile currently (in a few years future, this might change).
Anyway, i see the video was created using ffmpeg already. All you need to do is to add -pix_fmt yuv420p to the ffmpeg command.
[EDIT] for video format related questions, in future, please post a mediainfo report as well: https://mediaarea.net/MediaInfoOnline
Hello I'm trying to put video .mp4 auto-captured by my webcam using ffmpeg into HTML (running ffmpeg in desktop-linux), and then activated my localhost so my android will able to see it.
the video.mp4 was able to run in linux, and in html-desktop.
the video in my android-browser(html-android) WAS ABLE to play too BUT it's all white and pixels error, so it's a fail.
I thought because android has difference surface because in my desktop it runs perfectly, then i keep searching and trying with ogv/webm.
In the end, I just use a downloaded another mp4 and it runs perfectly tho.
now I think the problem was coming from my mp4-webcam created by ffmpeg(run in cmd)
I compare a mp4-webcam vs mp4-downloaded
5sec vs 1min,
Data-rate: 16477kbps vs 613kbps
framerate: 30frm/s vs 23frm/s
size: 9MB vs 5 MB
even tho it's only 5sec video by webcam, it still has larger data than a 1min video-downloaded maybe it was because without conversion.
but the question, is that the reason of the problem ? android-html(google chrome) wasn't able to display and make a dead pixels since in desktop it runs. it shouldn't be the problem right ?
I really need to transfer webcam-record into android-surface (my web-app).
I have no idea to fix it, any advice ? I've been searching a lot. Maybe there was another problem I do not know yet.
EDIT: my cmd ffmpeg run : ffmpeg -y -f v4l2 -i /dev/video1 -codec:v libx264 -qp 0 -t 0:00:05 hss.mp4
EDIT 2: my 2nd thought because ffmpeg encoder that I used(libx264) isnot support for android. but i still no idea
I just converted mp4-ffmpeg to webm , webm is more friendly for video-browser
I'm developing a function that I click next button then the pause video will seekto next part and start.For example when video.getCurrentPosition is 8000, I click button to make video seekto(10000),because the video show same content between 8000 and 10000.
This function on some android devices runs smoothly,such as Samsung s6 edge,OnePlus,Xiaomi,Smartison...
But the issue is that on some devices,such as Huawei,Moto Nexus 6,
when video on 8000 and I click the button,it has some "delay time".It looks like about 1sec. later,the video finally starts.
By contrast,I specially change the seekto(10200),which is wrong parameter,and these "problem devices" runs smoothly likes "normal devices".However,the video on previous "normal devices" skip some frame and start at 10200.
Is anyone know why cause this issue?Hope your answer,thank you.
Was the video encoded using h264? Re-encoding as using the mpeg4 codec, as suggested in a comment to this SO question, has resolved for me a problem of very odd seekTo behaviour by an Android ViewView.
To check the encoding, and to re-encode, you might be able to use ffmpeg.
$ ffprobe <inputfile>
...
...
Stream #0:0(eng): Video: h264 ...
...
That showed the the file is encoded using h264, which is more recent and generally produces better quality for the same bitrate as mpeg4, but is (presumably as a consequence) harder to seek through, at least for the Android VideoView.
To encode as mpeg4 the following worked for me, but the ffmpeg wiki has more detail.
$ ffmpeg -i <inputfile> -c:v libxvid <outputfile>
I am new to android and trying to streaming video from my server.
When i run the application it gives Error "sorry,this video is not valid for streaming to this Device.." than i download and push to sdcard of my device(samsung Galaxy 5)this time video is playing.... i convert this video by SOTHINK VIDEO CONVERTER..
Any Help??
Thanks..
We ran into exactly the same problem, and I found a solution at this link:
http://code.google.com/p/android/issues/detail?id=9044
In short, if you have access to a Mac, you can encode the videos using HandBrake. Be sure to check the "Web optimized" checkbox. I'm encoding as format:MP4 file, Video Codec: H.264. After I did this and uploaded I was able to view the videos (or at least listen to them) in a 2.1 simulator, which had been giving that exact warning message before. I have not been able to get a hold of an actual 2.1 device, but I suspect it will work. When I confirm that I'll check back in here to let you know.
It seems that you are talking about sothink video encoder engine. Actually this program only supports the apple devices in ios system, for example, iphone, ipad and ipod.
Here is the official product homepage of sothink video encoder engine, and hope it helps!
http://www.sothinkmedia.com/flash-video-encoder-command-line/
The only issue for error "sorry,this video is not valid for streaming to this Device.." is that there is some problem in video format. Just correct the format/codec of mp4 and then it would run gracfully.