View Full Version : FLV encoding using FFMPEG
BillybobBonnet
22nd March 2007, 17:27
First post in Doom9, Hello everyone:helpful:
I would like to encode flv files using FFMEG. I made a batch file, fully working, but it's the first time I use FFMPEG and I guess I made a mistake because my video quality is really bad. How can I improve it?
I can't force a codec with -vcodec because I don't know what codec to use and how to write it to be understood by FFMPEG, (it seems to give nice results with VP7 but with "-vcodec VP7" it doesn't work.
Here are some informations about the tested video.
Input: Raw video, 36 sec , 1280x800, and 1.54 Go.
Output: I don't know what codec (h263 is the default's with FFMPEG flv?), 320x240, 440 ko (!) flv player can't tell me what is the data rate (0 Kb/s written) .
A second output done by Quicktime Pro : 2.62 Mo in 1280x800, 400kb/s.
Here is what I wrote in the batch file:
"ffmpeg -i example.avi -pass 1 -s 320x240 -r 15 -acodec mp3 -b 600 -aspect 4:3 -ar 22050 test.flv "
I tried a tutorial found in this forum (http://sh0dan.blogspot.com/2006/09/command-line-flash-8-flv-encoding.html) but without success. I can't understand why I must use an avs script, what I have to do with virtuadub if I want to use FFMPEG, why the video has to be upside down:confused: ...
Could someone help me?
ps: I'm not sure my english is good so if you don't understand some details, I can give more of it.
:thanks:
:)
DarkZell666
22nd March 2007, 20:24
I guess ffmpeg has evolved quite a bit since the tutorial was written. Why not simply try "-vcodec flv -f flv" ?
In the "ffmpeg -formats" list, "flv" appears to be a valid codec, useable with -vcodec, and flv also appears to be a valid format (ie: -f flv), so unless I misunderstood the documentation given, you should give it a try :)
I also notice you have omitted the "-ab" switch for defining the audio bitrate.
In all cases, "ffmpeg -h" is your friend :)
smok3
22nd March 2007, 20:49
if i understand the sh0dan's procedure, then the ffmpeg is just used as an audio compressor and final muxer, everything else is vfw (but i could be wrong).
edit: yep, i just tested it, you may want to adjust the example.bat a little for some decent audio, i changed ffmpeg line to:
ffmpeg -ab 128 -ar 44100 -y -i "temp.avi" -vcodec copy -i "example.avs" "example.flv"
edit2: in case of problems, here is my vp6 (1000kbits) 2pass config for avs2avi:
http://somestuff.org/downloads/vp6_avs2avi_2pass_config/vp62.zip
anyway, the procedure is working fine.
p.s. you dont have to do anything with virtualdub really, that is just mentioned so you can test your avs before encoding (but you could use some player there as well).
DarkZell666
23rd March 2007, 07:20
if i understand the sh0dan's procedure, then the ffmpeg is just used as an audio compressor and final muxer, everything else is vfw (but i could be wrong).That's what I understood too :)
Btw, the necessity of having the picture upside down is just a limitation of VP6's YV12 support, nothing more.
To make things simpler for you, BillyBobBonnet: ffmpeg isn't actually encoding to vp6/7 in that tutorial, this is avs2avi's job. ffmpeg only muxes the video stream encoded by avs2avi into the flv container.
But hmm, I'm still asking myself what's wrong with the "-f flv -vcodec flv" switches ... I believe this would avoid a lot of messing around :rolleyes: (I'll have a go later on).
Edit: I've just had a try and this simple 1-pass cmdline works:
ffmpeg -i "whatever.avi" -s 512x384 -f flv -acodec mp3 -ab 128 -ar 44100 -vcodec flv -b 1000 -vframes 500 "whatever.flv"
BUT! => the bitrate parameter is ignored and the whole video is encoded at q=31 ... (so it's ugly like hell),
... and the 2-pass variant I'm trying to do right now won't do the 2nd pass, it says:"requested bitrate is too low".
DarkZell666
23rd March 2007, 09:36
Oooops, bitrate values are in bits/s ... clumsy me :o
-b 1000000 means 1mbps (1000kbps), and indeed it works !
So here goes for 1-pass (remove -vframes 500 for full encode):
ffmpeg -i "whatever.avi" -s 512x384 -f flv -acodec mp3 -ab 128000 -ar 44100 -vcodec flv -b 1000000 -vframes 500 "whatever.flv"
And for 2-pass:
ffmpeg -i "whatever.avi" -s 512x384 -f flv -acodec mp3 -ab 128000 -ar 44100 -vcodec flv -b 1000000 -vframes 500 -pass 1 "whatever.flv"
ffmpeg -i "whatever.avi" -s 512x384 -f flv -acodec mp3 -ab 128000 -ar 44100 -vcodec flv -b 1000000 -vframes 500 -pass 2 "whatever.flv"
And all works marvels :p
However, the 1-pass bitrate is a bit higher than what is asked for, and the second pass almost fixes the deviation (thus giving worse quality, but with lower bitrate, so nothing "abnormal" here)
smok3
23rd March 2007, 09:50
DarkZell, and what video codec is used in your example?
DarkZell666
23rd March 2007, 10:08
The source was xvid+mp3 in avi, and the destination codecs are flv+mp3.
If your question is "what does '-vcodec flv' stand for", I don't have the faintest clue what real-world codec it maps to ...
All I can say is that the generated file is playable in a generic flv player (not just with ffplay and mplayer).
smok3
23rd March 2007, 10:12
uhmm, ok, but you do understand that the shodan's idea is to use vp6?
foxyshadis
23rd March 2007, 10:51
flv codec is Spark, which is basically the same as h.263. No On2 codec is encodable with ffmpeg. I think you got the wrong idea about Sh0dan's guide; it's how to use On2 VP6 VFW encoder to encode your video (avisynth is optional) and mux the output of that into flv with ffmpeg. ffmpeg doesn't do any actual video encoding in his guide, and if you're looking for free VP6 encoding, you won't find it there. You still have to buy VP6. It looks like VP7 may be partially compatible with flash 8 and fully compatible with flash 9.
Aww, Zell, I was hoping your choice of video meant xxxHolic dvds had been released... Oh well.
DarkZell666
23rd March 2007, 11:05
smok3:
In fact, all BillyBobBonnet wanted was to encode to flv using ffmpeg, and ffmpeg is capable of doing that without using VP6. 2 suppositions:
- the guide is outdated since ffmpeg doesn't need vp6 to produce flv files anymore
- vp6 yields superior quality (though it's ratecontrol has been said to be ... rather inaccurate).
I have been searching for a command line Flash 8 (VP6) FLV video creation tool for a long time. Well, I'll suppose the former is correct ;)
public static main (String[] args) {
foxyshadis.setDisappointed(false);
} :rolleyes:
smok3
23rd March 2007, 11:27
foxyshadis, on2 vp6 vfw codec is (was) free for personal use, on2 doesnt keep it on its page anymore thought, so you have to find one by other means (google should do). The version i found is 6.4.2, but that may not be the latest.
BillybobBonnet
23rd March 2007, 23:01
:thanks: Thanks for all your answers! I guess the hideous quality was due to the bitrate, I set it on 200! :D
I found VP6 codec, and I will take a look to the version.If it's one newer I'll send the link. I can't work until monday but be sure I'll tell you how it works!
Some questions again: Can't FFMPEG encode in VP7, and isn't VP7 a good FLV codec?
Is it possible to ask FFMEG to compress all avi,mpeg and mov (or even all video formats) in the current folder?
If it isn't, I will do a small piece of VB6 soft which edit and launch a bat file to compress every video in a folder, and move all video in an output folder. Nothing extraordinary but if someone wants it, I'll share it. It could be used on a server but I'm not sure it would be better than php solution.
Anyway thanks for your help!:)
smok3
24th March 2007, 17:55
you can use a gui like total commander as your *.bat file launcher, it will basically deliver ascii list of selected files..., after that the batch is in control. (you can do one batch that runs on only one file, and another which is just a loop for the first one, at least thats what i do..)
afaik, there is no vp7 encoder in ffmpeg and flash player 8 doesnt support vp7 yet (but i could be wrong).
BillybobBonnet
26th March 2007, 17:20
Hello,
Everything is working fine thanks to your help. Your solution, smok3, can probably be suitable but I would like to include my script in a bigger software, and implement some functionalities like removing accents and special characters and controling if the last FFMPEG work is finish before to start another.
I am blocked at the moment on a strange fact, an opening file command isn't working, but it should be fixed soon:confused:
I have still a few questions:
I would like to replace a Sorenson Squeeze solution by FFMPEG and that's why I'm doing all that but I might be wrong on some points.
Does anyone have an idea of which on is the faster, FFMPEG or Sorenson. And what about codecs. I found a web page (I didn't success to find it again today) which compared the both encoders and codecs and if I remember well, FFMEG had really good results.
Concerning VP6 codec, I just noticed that I have downloaded a vp7 personnal edition version with vp6 inside. It was free, I guess it was legal, but I guess it's shareware too. I don't have anymore time to verify today, but more details tomorrow.
:thanks:
DarkZell666
26th March 2007, 22:30
Actually, I missed something important sh0dan corrected me on here: http://forum.doom9.org/showthread.php?p=975477#post975477
The thread is related to the guide you have read (which probably brought you here ;)).
Fluffbutt
6th April 2007, 07:45
That's what I understood too :)
Btw, the necessity of having the picture upside down is just a limitation of VP6's YV12 support, nothing more.
To make things simpler for you, BillyBobBonnet: ffmpeg isn't actually encoding to vp6/7 in that tutorial, this is avs2avi's job. ffmpeg only muxes the video stream encoded by avs2avi into the flv container.
But hmm, I'm still asking myself what's wrong with the "-f flv -vcodec flv" switches ... I believe this would avoid a lot of messing around :rolleyes: (I'll have a go later on).
Edit: I've just had a try and this simple 1-pass cmdline works:
ffmpeg -i "whatever.avi" -s 512x384 -f flv -acodec mp3 -ab 128 -ar 44100 -vcodec flv -b 1000 -vframes 500 "whatever.flv"
BUT! => the bitrate parameter is ignored and the whole video is encoded at q=31 ... (so it's ugly like hell),
... and the 2-pass variant I'm trying to do right now won't do the 2nd pass, it says:"requested bitrate is too low".
surely that -b 1000 should be -b 1000000 (for 1000kbps)??
DarkZell666
6th April 2007, 12:19
http://forum.doom9.org/showthread.php?p=974143#post974143
Thx for reporting anyways :)
Fluffbutt
6th April 2007, 13:09
DarkZell666 - That's what makes this board so much FUN - cross linked posts and other threads re-linked..
Hahaha - glad you fixed him though!
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.