You are not logged in.
Pages: 1
Hello. When encoding a video for my android phone with ffmpeg I get a lot of overread-messages and a blurred playback. I use this command: ffmpeg -i myfile.avi -vcodec mpeg4 -s 480x262 myoutputfile.mp4. I don't need to convert sound. The sound is mp3.
Offline
The quality of your video is bad for a few reasons. First, you didn't specify a bitrate. FFmpeg's defaults assume streaming media and in consequence are low bitrate. Second, their H264 encoder isn't one of the better ones. x264 is aways a better choice.
(Hopefully the following will work. I don't have an Android and I'm not using the FFmpeg or x264 from the repos)
I've read that I-Pod and I-Phone encoded streams will work with Android. You can try something like for two pass:
ffmpeg -i myfile.avi -an -vcodec libx264 -vpre fastfirstpass -b 512k -bt 512k -threads 0 -s 480x262 myoutfile.mp4
Say yes to overwriting with the next command:
ffmpeg -i myfile.avi -acodec copy -vcodec libx264 -vpre hq -vpre ipod320 -b 512k -bt 512k -threads 0 -s 480x262 myoutfile.mp4
Offline
Thank you. I will try that.
Jan
Offline
(Hopefully the following will work. I don't have an Android and I'm not using the FFmpeg or x264 from the repos)
I've read that I-Pod and I-Phone encoded streams will work with Android. You can try something like for two pass:
ffmpeg -i myfile.avi -an -vcodec libx264 -vpre fastfirstpass -b 512k -bt 512k -threads 0 -s 480x262 myoutfile.mp4
Say yes to overwriting with the next command:
ffmpeg -i myfile.avi -acodec copy -vcodec libx264 -vpre hq -vpre ipod320 -b 512k -bt 512k -threads 0 -s 480x262 myoutfile.mp4
skottish gave you some excellent settings, but I believe you need to add the pass options and add -vpre ipod320 to the first encode to equalize the number of b-frames. You can also combine both FFmpeg commands:
ffmpeg -i myfile.avi -pass 1 -an -vcodec libx264 -vpre fastfirstpass -vpre ipod320 -b 512k -bt 512k -threads 0 -s 480x262 \
-f rawvideo -y /dev/null && ffmpeg -i myfile.avi -pass 2 -acodec copy -vcodec libx264 -vpre hq -vpre ipod320 -b 512k -bt 512k \
-threads 0 -s 480x262 myoutfile.mp4
Note: I am also not using FFmpeg or x264 from the repos.
Offline
-vpre ipod320 sets B-frames to 0. So, chaining -vpre hq -vpre ipod320 creates a high profile H264 stream with none. I read somewhere when this post came up that Android can't handle B-frames.
Offline
I added -vpre ipod320 to the first pass because -vpre fastfirstpass by default uses -bf 3. Without this addition I get a failed second pass encode:
[libx264 @ 0xa28e590]different number of B-frames than 1st pass (0 vs 3)
...
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
Last edited by DrZaius (2009-09-22 00:42:52)
Offline
I added -vpre ipod320 to the first pass because -vpre fastfirstpass by default uses -bf 3. Without this addition I get a failed second pass encode:
[libx264 @ 0xa28e590]different number of B-frames than 1st pass (0 vs 3) ... Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
Yikes! That's what I get for posting about something that I didn't test. Thanks for the correction.
Offline
When running command from first answer I get a video with acceptable video. Trying to use DrZaius twopass command fails.
Pass 1 runs to an end but when pass 2 starts I get this output:
Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (30000/1) -> 23.98 (24000/1001)
Input #0, avi, from 'Amarcord1.avi':
Duration: 01:08:19.84, start: 0.000000, bitrate: 1443 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 496x272 [PAR 1:1 DAR 31:17], 23.98 tbr, 23.98 tbn, 30k tbc
Stream #0.1: Audio: mp3, 24000 Hz, 2 channels, s16, 56 kb/s
[libx264 @ 0x1b3a1e0]width or height not divisible by 16 (480x262), compression will suffer.
[libx264 @ 0x1b3a1e0]using SAR=214/215
[libx264 @ 0x1b3a1e0]frame MB size (30x17) > level limit (396)
[libx264 @ 0x1b3a1e0]VBV buffer (3000) > level limit (2000)
[libx264 @ 0x1b3a1e0]MB rate (12227) > level limit (11880)
[libx264 @ 0x1b3a1e0]using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0x1b3a1e0]direct=auto not used on the first pass
[libx264 @ 0x1b3a1e0]profile Baseline, level 1.3
[mp4 @ 0x1b31fe0]track 1: codec frame size is not set
Output #0, mp4, to 'amar1.mp4':
Stream #0.0: Video: libx264, yuv420p, 480x262 [PAR 214:215 DAR 10272:5633], q=10-51, pass 2, 512 kb/s, 24k tbn, 23.98 tbc
Stream #0.1: Audio: libmp3lame, 24000 Hz, 2 channels, s16, 56 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Could not write header for output file #0 (incorrect codec parameters ?)
[jan@acer Amarcord]$
Offline
That's strange. Works for me using both FFmpeg from the repository and compiled FFmpeg SVN. What version of FFmpeg are you using? Give the output of "ffmpeg -version" and paste your FFmpeg command.
Offline
Pages: 1