Hi guys,
Good news
I have found the solution and know what's the issue. The answer is the ffmpeg-0.8.7. I tried compile another version of ffmpeg using the
snapshot as what suggested by andrew.64, it works !
Let me share what I have found from the whole experiment.
Before I reinstalled with the ffmpeg-snapshot, I tried again with the ffmpeg-0.8.7 from alien bob build:
Code:
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample24.avi
frame= 317 fps= 26 q=31.0 Lsize= 1613kB time=00:00:30.16 bitrate= 437.9kbits/s dup=0 drop=582
video:1094kB audio:471kB global headers:0kB muxing overhead 3.052712%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 23 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample25.avi
frame= 397 fps= 33 q=24.8 Lsize= 1779kB time=00:00:30.08 bitrate= 484.4kbits/s dup=0 drop=502
video:1252kB audio:471kB global headers:0kB muxing overhead 3.223412%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 25 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample26.avi
frame= 393 fps= 31 q=31.0 Lsize= 1757kB time=00:00:30.08 bitrate= 478.4kbits/s dup=0 drop=506
video:1228kB audio:471kB global headers:0kB muxing overhead 3.351449%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 30 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample27.avi
frame= 421 fps= 35 q=24.8 Lsize= 1786kB time=00:00:30.06 bitrate= 486.5kbits/s dup=0 drop=478
video:1254kB audio:471kB global headers:0kB muxing overhead 3.506707%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 32 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample32.avi
frame= 401 fps= 31 q=31.0 Lsize= 1777kB time=00:00:30.06 bitrate= 484.2kbits/s dup=0 drop=498
video:1244kB audio:471kB global headers:0kB muxing overhead 3.608083%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 35 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample33.avi
frame= 376 fps= 28 q=31.0 Lsize= 1732kB time=00:00:30.08 bitrate= 471.7kbits/s dup=0 drop=523
video:1197kB audio:471kB global headers:0kB muxing overhead 3.837146%
If we look at the total frame dropped, sample27.avi is the least. So I'm doing wild guess that fps 30 is the original fps. And this also show that a higher fps is not always good, it got to be sync with the original fps. And, I did try above attempt with (-qscale 5), it gave the same result. So to make the output more flexible, I will continue on with the (-qmin 2 -qmax 8) option. (I read from
stackoverflow saying -qscale will fixed the quantizer, and -qmin,-qmax give ffmpeg more room to play around with the output thus better result.)
So now I remove the ffmpeg-0.8.7, and install with the ffmpeg snapshot. (How I compiled this was I downloaded the ffmpeg-snapshot.tar.bz2, extract it, rename the folder to ffmpeg-0.8.7, and zip it again and put into ffmpeg slackbuild folder I download from alien bob. Of course I have removed the original ffmpeg-0.8.7.tar.bz2)
Before I proceed anything, I do a test on what this new ffmpeg read about the input:
Code:
[09:42:33] 13708-26 sylye@silverphoenix:~/test/ffmpeg$ ffmpeg -i hotel.rmvb
ffmpeg version 0.8.7.git, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 8 2011 08:21:18 with gcc 4.5.2
configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/man --enable-libmp3lame --enable-libfaac --enable-libvo-aacenc --enable-nonfree --enable-libxvid --enable-libopenjpeg --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-libdc1394 --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-amrwbenc --enable-libvpx --enable-libx264 --enable-runtime-cpudetect --enable-vaapi --disable-vdpau --enable-memalign-hack --enable-pthreads --enable-x11grab --enable-bzlib --enable-zlib --enable-shared --enable-static --disable-debug --extra-cflags='-I/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/include -DRUNTIME_CPUDETECT' --extra-ldflags='-L/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/lib -lssl -lcrypto -lz -lusb'
libavutil 51. 30. 0 / 51. 30. 0
libavcodec 53. 40. 0 / 53. 40. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 51. 0 / 2. 51. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
[rm @ 0x806aaa0] Unsupported stream type 0000010a
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 30.00 (30/1)
Input #0, rm, from 'hotel.rmvb':
Metadata:
title :
author :
copyright :
comment :
Duration: 00:00:30.18, start: 0.000000, bitrate: 1240 kb/s
Stream #0:0: Video: rv40 (RV40 / 0x30345652), yuv420p, 640x480, 1054 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: cook (cook / 0x6B6F6F63), 44100 Hz, 5.1, flt, 183 kb/s
Stream #0:2: Data: none
At least one output file must be specified
And what previous ffmpeg-0.8.7 read about this input video is:
Code:
[09:39:02] 13707-25 sylye@silverphoenix:~/test/ffmpeg$ ffmpeg -i hotel.rmvb
ffmpeg version 0.8.7, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 4 2011 22:38:12 with gcc 4.5.2
configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/man --enable-libmp3lame --enable-libfaac --enable-libvo-aacenc --enable-nonfree --enable-libxvid --enable-libopenjpeg --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-libdc1394 --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-amrwbenc --enable-libvpx --enable-libx264 --enable-runtime-cpudetect --enable-vaapi --disable-vdpau --enable-memalign-hack --enable-pthreads --enable-x11grab --enable-bzlib --enable-zlib --enable-shared --enable-static --disable-debug --extra-cflags='-I/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/include -DRUNTIME_CPUDETECT' --extra-ldflags='-L/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/lib -lssl -lcrypto -lz -lusb'
libavutil 51. 9. 1 / 51. 9. 1
libavcodec 53. 8. 0 / 53. 8. 0
libavformat 53. 5. 0 / 53. 5. 0
libavdevice 53. 1. 1 / 53. 1. 1
libavfilter 2. 23. 0 / 2. 23. 0
libswscale 2. 0. 0 / 2. 0. 0
libpostproc 51. 2. 0 / 51. 2. 0
[NULL @ 0x80799a0] Unsupported video codec
[rm @ 0x80693a0] max_analyze_duration 5000000 reached at 5063000
Input #0, rm, from 'hotel.rmvb':
Metadata:
title :
author :
copyright :
comment :
Duration: 00:00:30.18, start: 0.000000, bitrate: 1240 kb/s
Stream #0.0: Video: rv40, yuv420p, 640x480, 1054 kb/s, 12.05 fps, 12 tbr, 1k tbn, 12 tbc
Stream #0.1: Audio: cook, 44100 Hz, 5.1, s16, 183 kb/s
Stream #0.2: Data: [0][0][0][0] / 0x0000
At least one output file must be specified
So that's the problem. The snapshot ffmpeg is able to detect the input as having 30 fps, while the previous one only got a pity 12 fps. Hence no matter what '-r' I put previously, the output wouldn't be good as the input is always assumed as 12 fps by ffmpeg. Now when ffmpeg able to detect it's in fact having 30 fps, story is different and it's showtime
Now by using the snapshot ffmpeg:
Code:
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample34.avi
frame= 899 fps= 57 q=31.0 Lsize= 2460kB time=00:00:30.00 bitrate= 671.9kbits/s
video:1928kB audio:471kB global headers:0kB muxing overhead 2.527859%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 23 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample35.avi
frame= 691 fps= 46 q=31.0 Lsize= 2184kB time=00:00:30.04 bitrate= 595.6kbits/s dup=0 drop=208
video:1657kB audio:471kB global headers:0kB muxing overhead 2.614796%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 25 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample36.avi
frame= 751 fps= 50 q=31.0 Lsize= 2263kB time=00:00:30.04 bitrate= 617.2kbits/s dup=0 drop=148
video:1735kB audio:471kB global headers:0kB muxing overhead 2.587632%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 30 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample37.avi
frame= 899 fps= 57 q=31.0 Lsize= 2460kB time=00:00:30.00 bitrate= 671.9kbits/s
video:1928kB audio:471kB global headers:0kB muxing overhead 2.527859%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 32 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample38.avi
frame= 899 fps= 55 q=31.0 Lsize= 2459kB time=00:00:30.00 bitrate= 671.4kbits/s
video:1925kB audio:471kB global headers:0kB muxing overhead 2.590123%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 35 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 sample39.avi
frame= 899 fps= 57 q=31.0 Lsize= 2459kB time=00:00:30.00 bitrate= 671.6kbits/s
video:1924kB audio:471kB global headers:0kB muxing overhead 2.679417%
After output given as -r 30 or higher,
no more frame dropped ! And the result is good and no more choppy! So this happen only when the input fps is read correctly by ffmpeg. When the 'muxing overhead' is lesser, I found out the video quality is better. Hence the quality is best while giving '-r 30'. So the morale of the story here is, try getting the fps of the input, and give it in the output. If you don't put, ffmpeg could also detect and convert it smoothly.
Now it's time to fine tune the output. I found out my above attempt, the output video bitrate is 671.9kb/s at best sample37.avi, while the input is shown 1054 kb/s when I tested it. So I tried again:
Code:
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 30 -qmin 2 -qmax 8 -b:v 1054k -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample41
frame= 899 fps= 53 q=5.4 Lsize= 4570kB time=00:00:30.00 bitrate=1247.8kbits/s
video:4038kB audio:471kB global headers:0kB muxing overhead 1.345587%
ffmpeg -i hotel.rmvb -vcodec msmpeg4 -r 30 -qmin 2 -qmax 8 -b:v 2M -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample42.avi
frame= 899 fps= 50 q=2.0 Lsize= 7249kB time=00:00:30.00 bitrate=1979.4kbits/s
video:6717kB audio:471kB global headers:0kB muxing overhead 0.844197%
So this seems like, giving the output as same with the original video bitrate, it gives better result. But giving more bitrate (2M), it's even better ? Since this hotel.rmvb video clip is hard to sense the different, I tried with the later sample
Sample.Made.of.honor.2008.Sub.R5.rmvb :
Code:
ffmpeg -i honor.rmvb -vcodec msmpeg4 -qmin 2 -qmax 8 -b:v 568k -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample44.avi
frame= 1344 fps= 58 q=8.2 Lsize= 5261kB time=00:01:00.00 bitrate= 718.3kbits/s dup=0 drop=115
video:4201kB audio:958kB global headers:0kB muxing overhead 1.987596%
ffmpeg -i honor.rmvb -vcodec msmpeg4 -qmin 2 -qmax 8 -b:v 2M -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample45.avi
frame= 1344 fps= 57 q=2.0 Lsize= 12496kB time=00:01:00.00 bitrate=1706.1kbits/s dup=0 drop=115
video:11435kB audio:958kB global headers:0kB muxing overhead 0.827509%
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -qmin 2 -qmax 8 -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample47.avi
frame= 1344 fps= 62 q=31.0 Lsize= 4824kB time=00:01:00.00 bitrate= 658.6kbits/s dup=0 drop=115
video:3763kB audio:958kB global headers:0kB muxing overhead 2.172125%
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -qmin 2 -qmax 8 -b:v 568k -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample46.avi
frame= 1344 fps= 64 q=8.2 Lsize= 5261kB time=00:01:00.00 bitrate= 718.3kbits/s dup=0 drop=115
video:4201kB audio:958kB global headers:0kB muxing overhead 1.987596%
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -qmin 2 -qmax 8 -b:v 2M -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample43.avi
frame= 1344 fps= 57 q=2.0 Lsize= 12496kB time=00:01:00.00 bitrate=1706.1kbits/s dup=0 drop=115
video:11435kB audio:958kB global headers:0kB muxing overhead 0.827509%
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -qmin 2 -qmax 8 -b:v 3M -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample48.avi
frame= 1344 fps= 57 q=2.0 Lsize= 12496kB time=00:01:00.00 bitrate=1706.1kbits/s dup=0 drop=115
video:11435kB audio:958kB global headers:0kB muxing overhead 0.827442%
I have watched all the output video, and
every time the lesser the muxing overhead, the better quality it is. When no bitrate specified, the default result is so bad, I can see lots of 'square box' image in the video. When give the output bitrate same as original, the result is not perfect too. When the out bitrate is 2M, I can see a very nice awesome output. And when I increase it to 3M, it doesn't give much different, as the highest it could go is 1706.1kbit/s.
So now what if I only use -b:v to control the output and not rely on qscale, qmin and qmax ?
Code:
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -b:v 3M -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample49.avi
frame= 1344 fps= 57 q=2.0 Lsize= 12496kB time=00:01:00.00 bitrate=1706.1kbits/s dup=0 drop=115
video:11435kB audio:958kB global headers:0kB muxing overhead 0.827442%
Result is awesome too, as long as you have the great video bitrate (-b:v) specified. But what if you don't provide even -b:v ?
Code:
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample50.avi
frame= 1344 fps= 66 q=31.0 Lsize= 2825kB time=00:01:00.00 bitrate= 385.7kbits/s dup=0 drop=115
video:1765kB audio:958kB global headers:0kB muxing overhead 3.766524%
The result is the most awful! Video image having very big square box and totally can't watch at all.
Finally, is -qscale or -qmax,-qmin better ?
Code:
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -qmin 2 -qmax 8 -b:v 2M -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample51.avi
frame= 1344 fps= 54 q=2.0 Lsize= 12496kB time=00:01:00.00 bitrate=1706.1kbits/s dup=0 drop=115
video:11435kB audio:958kB global headers:0kB muxing overhead 0.827509%
ffmpeg -i honor.rmvb -vcodec msmpeg4 -r 23 -qscale 5 -b:v 2M -acodec libmp3lame -ar 48000 -b:a 128k -ac 2 sample52.avi
frame= 1344 fps= 64 q=5.0 Lsize= 6527kB time=00:01:00.00 bitrate= 891.2kbits/s dup=0 drop=115
video:5510kB audio:914kB global headers:0kB muxing overhead 1.595882%
qmin and qmax is better. And by having smaller quantizer is better, so we may set -qscale 2. But sometime ffmpeg will have problem converting if -qscale is too small, so it's good just to use -qmin,-qmax
As a wrap up, in my case, to get a nice RMVB conversion to msmpeg4:
- use git snapshot ffmpeg to solve the fps not read correctly issue
- use higher video bitrate (-b:v 2M)
- use same framerate (fps) as the original
- use qmax and qmin to give room for ffmpeg to do it's job
However this is only a very simple test on a very few RMVB video clip, your meter may vary. You are welcome to post your finding if it's far difference than yours