Today I got an idea to watch a movie on my Android smartphone (G1310). Why not? I had plugged USB, copied the file over adb to smartphone and then have clicked the file on FileManager. Android has answered with alert box - "Sorry, this video cannot be played". Well, it seems that the matter needs a little research.
First at all, what's movie formats supports Android? Perhaps there are a lot of them but we need at least one. Let's make a short video with Android camcoder and then analyze the file with ffmpeg. Here the what I got for the file made by Android:
Video: mpeg4 (Simple Profile), yuv420p, 640x480, 1456 kb/s
Audio: amrnb, 8000 Hz, 1 channels, flt, 12 kb/s
Let's compare the above with the movie I wasn't able to watch previously:
Video: mpeg4 (Simple Profile), yuv420p, 320x240
Audio: mp3, 44100 Hz, stereo, s16, 125 kb/s
The video parts of each file seems to be mostly identical. So why Android refused to accept my movie? The answer is a file format or media container. I got it after an hour of detailed analyze because ffmpeg doesn't show it by default. The movie file I tried to watch has AVI format but Android expects 3GP files. So let's try to convert it now. To be on the safe place we will change audio part too to look like the one we have on Android movie I made as an experiment previously.
Or use video codec mpeg4, output file format 3GP, leave one audio channel with audio bitrate 12K, audio sampling frequency 8000, video bit rate 1456K and resolution 640x480.
Once I had converted the movie I uploaded it to my smartphone and found that I can watch it now.
First at all, what's movie formats supports Android? Perhaps there are a lot of them but we need at least one. Let's make a short video with Android camcoder and then analyze the file with ffmpeg. Here the what I got for the file made by Android:
Video: mpeg4 (Simple Profile), yuv420p, 640x480, 1456 kb/s
Audio: amrnb, 8000 Hz, 1 channels, flt, 12 kb/s
Let's compare the above with the movie I wasn't able to watch previously:
Video: mpeg4 (Simple Profile), yuv420p, 320x240
Audio: mp3, 44100 Hz, stereo, s16, 125 kb/s
The video parts of each file seems to be mostly identical. So why Android refused to accept my movie? The answer is a file format or media container. I got it after an hour of detailed analyze because ffmpeg doesn't show it by default. The movie file I tried to watch has AVI format but Android expects 3GP files. So let's try to convert it now. To be on the safe place we will change audio part too to look like the one we have on Android movie I made as an experiment previously.
ffmpeg -i input.avi -vcodec mpeg4 -preset slow -bufsize 500k -threads 0 -ab 96k -ar 8000 -ac 1 -vb 1456k -ab 12k -s 640x480 -f 3gp output.3gp
Or use video codec mpeg4, output file format 3GP, leave one audio channel with audio bitrate 12K, audio sampling frequency 8000, video bit rate 1456K and resolution 640x480.
Once I had converted the movie I uploaded it to my smartphone and found that I can watch it now.