Hi, just getting my FFmpeg setup on my server, hoping to use the Video module with FFmpeg using either x264 or VP8 to get the highest quality videos on my websites.
Curious if someone else has gone down this road before. So, if you're using x264 or VP8, please share your FFmpeg command lines so we can all move towards some high quality encoding together as a group.
Maybe we could get a solid documentation page going here to help ourselves and maintainers to point new users to.
If I come up with something good on my own, I'll report back with it. Still compiling.
My Linode server uses Ubuntu Karmic 9.10, and I'm following instructions here: http://ubuntuforums.org/showthread.php?t=786095
There's quite a few command line suggestions there too, so a good start for me and hopefully the community here.
PS: If this has been done before, please post relevant links in this thread to support people's research. I did a search for "VP8" in the issue queue and got 0 results, so I think it's needed! For more information: http://en.wikipedia.org/wiki/VP8
Comments
Comment #1
parasox commentedSo far as a basic command line using x264 I have:
-y -i !videofile -f flv -crf 22 -vcodec libx264 -vpre slow -threads 0 -acodec libfaac -ar 22050 -ab !audiobitrate -s !size -qscale 1 !convertfile
Comment #2
hypertext200you guys might not know, you can extend transcoder API to use any other trancoders if your using Handbreke CLI
you can use
for the vp8 you can use 2pass encoding
Pass 1
Pass2
Comment #3
virtuali1151 commentedDoes anybody have more settings to share for this..?? This would be extremely handy...
Comment #4
hypertext200@virtuali1151, yep this would be great and we can add many presets to the video module ;o).
Here is a 2 pass example encoding x264 mp4
Here is the single pass example with CRF(Contents Rate Factor)
Note: when two pass, FFMPEG should be able to replace the existing file created in pass 1
Comment #5
virtuali1151 commentedI had got this setting from bcobin.. which works great with wmv.. but not so much with flv's for some reason.. the flv's freeze about 3 seconds in.. also flowplayer doesnt seem to be to get the video time from this encoding so the scrub doesnt work... its works with the wmv... but not flv's so far.. havent tried mp4's quite yet..
'!cmd_path -i !videofile -y -vcodec libx264 -vpre slow -crf 10 -threads 0 -r 24 -ac 2 -ar 44100 -ab 128 -s !widthx!height !convertfile'
Comment #6
virtuali1151 commentedheshan.. thanks very much.. How would I edit this code to fit your examples..??
'!cmd_path -i !videofile -y -vcodec libx264 -vpre slow -crf 10 -threads 0 -r 24 -ac 2 -ar 44100 -ab 128 -s !widthx!height !convertfile'
I would like to get the best quality I can while maintaining decent streamability.. This seems to work ok with wmv.. but not with flv's for some reason..
Tks so much for your assistance as usual...:)
Comment #7
hypertext200We are working on having preset setting on admin, so next time it would not be a pain to edit the code when add new preset ;o)
Comment #8
virtuali1151 commentedOk.. but is it possible to do something with the above command line in the interim..?
Comment #9
virtuali1151 commentedOk Guys... Here is what I have found so far with my cmd line for ffmpeg and certain file formats... hopefully this will help so of you guys out there as well.. I havent perfected it yet.. and there is still a number of errors.. but maybe some of you pros can assist or gives suggestions below.
Cheers.
File formats tested - wmv, flv, mpg, avi, mp4.
Video Player: Flowplayer 3.25
Command line: '!cmd_path -i !videofile -y -acodec libfaac -ab 128k -vcodec libx264 -vpre slow -crf 10 -b 128k -threads 0 -ar 44100 -qscale 1 -r 25 -s !widthx!height !convertfile'
Server Params:
FFmpeg version SVN-r25853, Copyright (c) 2000-2010 the FFmpeg developers
built on Dec 1 2010 06:32:04 with gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3
1.) WMV - Works, except flowplayer cannot seem to pick up the proper frame starting point so the scrubber doesnt work. (Scrubber does not work either)
2.) FLV - Does not work - the conversion happens, but the video freezes about 3 seconds in. (Scrubber does not work either)
3.) MPG - Does not work - the conversion happens, but the video freezes about 3 seconds in. (Scrubber does not work either)
4.) AVI - Does not work - errors out on memory. See error below.
Video conversion failed for preset hq_flash. FFMPEG reported the following output: FFmpeg version SVN-r25853, Copyright (c) 2000-2010 the FFmpeg developers built on Dec 1 2010 06:32:04 with gcc 4.1.2 20080704 (Red Hat 4.1.2-48) configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 libavutil 50.33. 0 / 50.33. 0 libavcore 0.14. 0 / 0.14. 0 libavcodec 52.97. 2 / 52.97. 2 libavformat 52.87. 1 / 52.87. 1 libavdevice 52. 2. 2 / 52. 2. 2 libavfilter 1.65. 0 / 1.65. 0 libswscale 0.12. 0 / 0.12. 0 Input #0, avi, from 'sites/default/files/videos/original/sample.avi': Duration: 00:00:59.72, start: 0.000000, bitrate: 606 kb/s Stream #0.0: Video: mpeg4, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 25 tbr, 25 tbn, 25 tbc Stream #0.1: Audio: mp3, 48000 Hz, 2 channels, s16, 128 kb/s [buffer @ 0x1abd34e0] w:720 h:304 pixfmt:yuv420p [scale @ 0x1abd38a0] w:720 h:304 fmt:yuv420p -> w:1600 h:676 fmt:yuv420p flags:0xa0000004 [pad @ 0x1abd3bd0] w:1600 h:1200 x:0 y:262 color:0x108080FF[yuva] [libx264 @ 0x1ab9ca70] using SAR=1/1 [libx264 @ 0x1ab9ca70] using cpu capabilities: none! [libx264 @ 0x1ab9ca70] profile High, level 5.0 [libx264 @ 0x1ab9ca70] 264 - core 107 - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=10.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00 Output #0, flv, to 'sites/default/files/videos/converted/sample.flv': Metadata: encoder : Lavf52.87.1 Stream #0.0: Video: libx264, yuv420p, 1600x1200 [PAR 1:1 DAR 4:3], q=10-51, 128 kb/s, 1k tbn, 25 tbc Stream #0.1: Audio: libfaac, 44100 Hz, 2 channels, s16, 128 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 Press [q] to stop encoding x264 [error]: malloc of size 2103424 failed Video encoding failed
5.) MP4 - Works - But takes alittle while to do the conversion - might have to change the qscale to different value so doesnt take so long without compromising to much quality (Scrubber works ok too).
Comment #10
virtuali1151 commentedUpdate on this: After many hours of fooling around I had to change the audio codec to libmp3lame instead of libfaac and now the scrubber and vid conversion works :
'nice !cmd_path -i !videofile -y -acodec libmp3lame -ab 96k -vcodec libx264 -vpre ultrafast -crf 10 -threads 0 -ar 44100 -s !widthx!height -r 20 !convertfile'
This was the best combo I could get that would support flv, mpg, wmv, mp4.. avi was to much of a pain so I got rid of it... I found the above command line allows the scrubber to work and does give a good happy medium between conversion speed and quality... hopefully this helps somebody else.
Cheers.
Comment #11
vishun commentedIt definitely would make sense for the video parameters used to be available in the Transcoders area in the same way that it is for images under an Advanced Settings fieldset. In regards to #8 and how to change the command in the interim, open video/transcoders/video_ffmpeg.inc and change 'protected $command'
Thanks for contributing your suggested settings guys. Curious if something different for the default command maybe should be considered or is the current setting the most versatile?
Comment #12
broncomania commentedsubscribing to #11
Comment #13
bbcThanks for this. Seems to be exactly what I was looking for. However, I'm not seeing any changes in quality after making the suggested changes in #10 and #11 and converted files have exactly the same file size before and after. Is there another step that I'm missing?
Comment #14
bkat commentedThis is what I use for webm with ffmpeg 0.9
This works a bit different with the scaling than what most people do. I occasionally get anamorphic videos which the video module doesn't deal with very well since it uses the storage resolution not the display resolution when calculating resolution and ratio. So the scale filter above avoids upscale and resizes the video so that the physical resolution is the same as the display resolution.
If anyone knows a way to avoid upscaling the bitrate, I'd love to know how.
Comment #15
Jorrit commentedI am closing this issue to keep the issue queue clean and it has been inactive for a while. Feel free to continue sharing command lines. With Video module 5.0 it is even easier to configure command lines, as it is now done using a web form instead of editing source files. You no longer have to restore your precious command lines when updating the Video module.