View Full Version : convert any video format to flv successfully
CTYves
4th August 2008, 13:13
I'm pretty novice when it comes to mencoder and ffmpeg command lines, so I need some help or suggestions. At the moment my video sharing site is using the command line below to convert many video formats (3gp, 3gpp, mpg, mpeg, mpeg4, mp4, avi, wmv, flv, mov, asf, qt, dat) to flv files. So far I noticed it converts to flv file successfully when the input video is flv, 3pg, mov or mp4. Other formats are not tested yet. What I do know for certain is that wmv files are never successfully converted. The audio is converted propperly, but the video frames aren't. It's like there are 20 frames in total and you see them one after the other in a timespan of 20 seconds.
The bottom line is the code below isn't good enough to convert any video format to an flv successfully. What command line you think would?
I'm also open to use ffmpeg instead of mencoder. I just don't know what command line would be the optimal one to use. All help and suggestions are greatly appreciated.
/usr/local/bin/mencoder video.wmv -o video.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=320:240 -srate 22050
Red9
4th August 2008, 18:24
Why aren't you using Adobe Flash Encoder? It's very simple and knows a lot of video formats...
Dark Shikari
4th August 2008, 18:34
You'd probably be better off using H.264, given how much better quality you'll get. FLV1/Sorenson Spark H.263 is a really old and crappy format.
CTYves
5th August 2008, 10:55
Why aren't you using Adobe Flash Encoder? It's very simple and knows a lot of video formats...
First time I hear about it. Can it run on a linux server? Where can I get more info about it?
You'd probably be better off using H.264, given how much better quality you'll get. FLV1/Sorenson Spark H.263 is a really old and crappy format.
What should I do then? I have the latest mencoder and ffmpeg installed. How can I make my script work on H.263?
You see I'm a bit novice to it all. But I'm surely prepared to read up where I have to to get it done.
dat720
5th August 2008, 11:21
As far as i can see there is no Adobe Flash Encoder available for linux, i would stick with mencoder and tweak what you have.
Try adding harddup in the filters section....
-vf harddup,scale=320:240
Sometimes wmv files have strange framerate's, i have seen wmv's with 100fps rates, that could explain why mencoder is having a spat!
CTYves
5th August 2008, 11:59
I remember trying -vf scale=320:240,harddup but that didn't do it. You suggestions -vf harddup,scale=320:240 did. Great! You recon all video formats will now convert successfully because of the hardup parameter?
Also, I am intriged by what Dark Shikari said. "You'd probably be better off using H.264, given how much better quality you'll get."
How can I take advantage of that?
EDIT: It didn't do it perfectly. It seems the audio is faster or the video is slower (too many frames). Either one of these.
dat720
5th August 2008, 22:42
About the only other thing you could do is force a frame rate.
-ofps 23.976
Look at your failed videos and see what frame rate they are, this should give some idea as to what is going on....
PS mencoder did it's job perfectly, but the results are not what you want!
Dark Shikari
5th August 2008, 22:51
H.264-in-flash example (http://norp.ath.cx/h264.html) (280kbps video, 32kbps audio). Another one (http://mirror05.x264.nl/Dark/Flash/mof.html) (1.5 megabit video, 128kbps audio)
For help encoding with x264 through ffmpeg, check out this page (http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/) and this page (http://ffmpeg.x264.googlepages.com/mapping).
Blue_MiSfit
6th August 2008, 01:24
....................................... :D
Dude.
That game makes my brain short-circuit. I've seen your Touhou samples before, but that's seriously, seriously impressive. 60p, and at 1.5mbps the only problem is a slight blurring / noise in the background. The massive numbers of bullets are perfectly preserved with no blocking anywhere.
~MiSfit
CTYves
7th August 2008, 15:22
As much as I would like to use H.264, I don't know how. The pages you showed are a bit complicated to me. And the videos you showed are, well..., impressive!
Can you help me get a command line that would be perfect in your eyes? I can uses mencoder or ffmpeg. Both are installed. Or can you setup a commandline that uses H.264 for me?
Dark Shikari
7th August 2008, 15:53
As much as I would like to use H.264, I don't know how. The pages you showed are a bit complicated to me. And the videos you showed are, well..., impressive!
Can you help me get a command line that would be perfect in your eyes? I can uses mencoder or ffmpeg. Both are installed. Or can you setup a commandline that uses H.264 for me?If you're on Windows, you can just use MeGUI and output to an mp4 file. If you're on Linux, this page (http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/) might be useful, though as a general note using ffmpeg to encode H.264 is a bit of a nightmare, and further more you need to remux with mp4box or use qt-faststart after encoding to make the video ready for Flash (you can also mux to FLV instead to avoid this issue).
CTYves
7th August 2008, 17:26
Again, that's really chinese to me. I appreciate you helping me though. :)
What I would like if for someone to fill in parameters at the end of this commandline...
/usr/local/bin/mencoder video.wmv -o video.flv
... so that when I use that command line on (almost) any video format it outputs a propper flv. Preferably medium to high quality.
Some parameters in the commandline in post 1 must be cuasing some issues with some video formats (like wmv) and I don't know which.
CTYves
9th August 2008, 12:43
anybody?
dat720
9th August 2008, 13:18
Have Patience fella!!!
Not everyone sits here watching the forums 24/7.....
Here is the contents of my youtube.bat:
@echo off
"D:\VidTools\AutoMen\mencoder.exe" %1 -o "%~dpn1.youtube.flv" -of lavf -ovc lavc -oac lavc -lavcopts vcodec=flv:vbitrate=448:autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:precmp=2:cmp=2:subcmp=2:preme=2:turbo:acodec=libmp3lame:abitrate=56 -vf scale=320:240 -srate 22050 -af lavcresample=22050 -sws 9
This spits video out at roughly 3.6mb per minute.
Here (http://www.youtube.com/watch?v=0lf9BBS7eDk) is the Transformers trailer i did but it seems youtube totally raped the video, it looks much better from the original flv....
CTYves
9th August 2008, 13:34
The same thing happens when trying to convert a wmv file. I'm testing to convert a 2 minute wmv file. When converted to flv and I play it, the video flashes by rapidly and ends after 5 seconds. The audio plays propperly for 2 minutes, but on a black background.
dat720
9th August 2008, 13:53
can you host the file somewhere so i could download it and have a look
last time i had a strange video like that i used avisynth and forced the framerate......
CTYves
9th August 2008, 14:24
82.wmv (http://www.carbtube.com/uploads/video/82.wmv)
Thanks, dat720
dat720
9th August 2008, 14:51
Use the same command i posted ealier but put -fps 30 on the end.....
CTYves
9th August 2008, 14:59
Ok. That worked. This is the results here (http://www.carbtube.com/videos/82/drunk-driving-accident-caught-on-tape.html)... The sound is a bit stuttery though. But it is better then before. Defenatly. I guess it will do. What do you think?
dat720
9th August 2008, 15:03
that could be because 30fps is not the actual frame rate of the video, media info told me 30fps so i just ran with that, and to be honest when i tested it i didn't have the volume loud enough to notice that, it's 11pm here and everyone else is in bed.
Hmm nope i was wrong, the problem is with libmp3lame, it seems to be killing the audio.
Wrong again.... i have absolutely no idea why the audio is doing that....
CTYves
9th August 2008, 15:11
Is there a command that makes it respect the fps of the input video?
dat720
9th August 2008, 15:18
if you leave the fps command out it will use the input fps, but mencoder see's that video as 100fps, which is why the video finishes playing before the audio after it's been encoded.
dat720
9th August 2008, 15:28
"D:\VidTools\AutoMen\mencoder.exe" %1 -o "%~dpn1.youtube.flv" -mc 0 -demuxer lavf -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=448:autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:precmp=2:cmp=2:subcmp=2:preme=2 -vf scale=320:240 -oac mp3lame -lameopts abr:br=56 -srate 22050
This command has better results, the demuxer is specified as lavf, which seems to have better success detecting the fps, but the audio is still choppy, even tho it is now using lame and not libmp3lame..... im stumped.
CTYves
9th August 2008, 15:36
Yes, it is. I tried it with "-srate 44100" too, but that didn't help. Same choppyness.
manono
11th August 2008, 12:04
Here (http://www.youtube.com/watch?v=0lf9BBS7eDk) is the Transformers trailer i did but it seems youtube totally raped the video, it looks much better from the original flv....
It looks better when you play the "High Quality" MP4 version:
http://www.youtube.com/watch?v=0lf9BBS7eDk&fmt=18
Not much better, but a little bit. You could get much better results by uploading a higher resolution video for them to reencode. They recommend 640x480, although I make mine 512x384 usually (or some widescreen equivalent like 640x272 or whatever). And they say they prefer XviD/DivX AVIs. Their reencoded "High Quality" MP4s have a 480 width, so you'd best upload something with at least that width.
dat720
11th August 2008, 12:39
I was under the assumption that if you uploaded a compliant mp4 it left it alone rather than recoding.....
manono
11th August 2008, 13:05
Nah, they reencode everything these days. Didn't your nasty looking trailer tell you as much? I'm sure what you uploaded didn't look like that.
Of course, that trailer was pretty difficult to compress, but it would still look quite a bit better (the High Quality version, anyway, and not the Standard Version), if you uploaded a higher resolution source for them to ruin.
Their Standard Quality is 320x240 FLV, so not much point in uploading a 320x240 MP4. Their High Quality is 480x360 MP4. One of them is. Their other High Quality version is 480x360 FLV, but they may be phasing them out. I uploaded 4 videos today and none had the High Quality FLV made available, only High Quality MP4.
dat720
11th August 2008, 13:39
Well yeah it did, but in the past i've uploaded content which looked just as good as the original......
I might reencode that 1080p trailer and see how it looks after a upload at 640x480 or something.
That is after this x264 encode finishes, it's only got 2000 minutes to go :/ i'm so buying a quad with my next pay check
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.