Last Shout - Posted by: MIOW - Wednesday, 23 June 2010 02:51
Yo! Join our IRC channel #6R-Clan @ QuakeNet and we can talk w/ you there. Yea, possible that we're too many already to take you, but myself I can't say for sure.
 
It is currently 07 Sep 2010, 01:41

All times are UTC [ DST ]





Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Video recording and encoding
PostPosted: 16 Jul 2009, 12:01 
Offline
Lieutenant
User avatar
 E-mail  Profile

Joined: 31 Aug 2008, 23:49
Posts: 67
Well, I've been experimenting with this for quite some time and I remember dash once asked me that when I get close to good options, I should share them.

Ok. First, here is video.cfg:
Code:
set r_customwidth 1280
set r_customheight 720
set r_fullscreen 0

// set r_ext_max_anisotropy 8
set r_ext_max_anisotropy 16
set r_ext_texture_filter_anisotropic 1
// set r_flares 1
set r_picmip 0
set r_stencilbits 16
set r_texturebits 32
set r_textureMode GL_LINEAR_MIPMAP_LINEAR
set r_gamma 1.8

vid_restart

set cg_drawgun 1
set cg_lagometer 0
set cg_drawspeed 0
set cg_drawfps 0
set cg_drawAttacker 0
set cg_simpleItems 1
set cl_aviFrameRate 50
set cl_aviMotionJpeg 0
set cg_shadows 0
set cg_simpleitems 0
set s_volume 0.7
set cg_brasstime 5000
set com_blood 1
set cg_gibs 1 // for LOTS of gibs hehe

bind F11 "cg_drawtimer 0 ; video"
bind F12 "stopvideo ; cg_drawtimer 1"

// [v] feidi's timescale binds [v]

bind UPARROW "timescale 0.01"
bind DOWNARROW "timescale 1; set faster "vstr s125"; set slower "vstr s75""
bind LEFTARROW "vstr slower"
bind RIGHTARROW "vstr faster"

bind KP_SLASH "timescale 0.25"
bind KP_STAR "timescale 0.5"
bind KP_MINUS "timescale 0.75"

set s5 "timescale 0.5; set faster vstr s75; set slower vstr s5"
set s75 "timescale 0.75; set faster vstr s125; set slower vstr s5"
set s125 "timescale 1.25; set faster vstr s200; set slower vstr s75"
set s200 "timescale 2; set faster vstr s500; set slower vstr s125"
set s500 "timescale 5; set faster vstr s1000; set slower vstr s200"
set s1000 "timescale 10; set faster vstr s2000; set slower vstr s500"
set s2000 "timescale 20; set faster vstr s4000; set slower vstr s1000"
set s4000 "timescale 40; set faster vstr s4000; set slower vstr s2000"

set faster "vstr s125"
set slower "vstr s75"

// [^] feidi's timescale binds [^]
"set cl_aviMotionJpeg 1" produced dark videos and dash complained to me about it.

Here is the quote that I wrote to davidd about video encoding. It should explain everything that I came to so far.
Quote:
The config produces lots of big (2Gb) avi (raw_vid/pcm) files of 720p quality so you better prepare a lot of space for them. "set cl_aviMotionJpeg 1" has a problem with brightness: the movies are very dark. So I use 0, but it results in kinda big avi files.
Okay, let's say you've recorded the vid, this means that now u have a few video00xx.avi files in your "fs_game/video/" directory. First you need to concatenate them, this is done with a command:
$ mencoder -oac copy -ovc copy -vf-pre harddup -o big_file.avi video0000.avi video0000.avi_ video0000.avi__ video0000.avi___
this will create a big single big_file.avi with all movie. You can delete all video00xx.avi_ files now.
Now let's encode it into x264/mp3 (not aac because I've not fully tested aac encoding yet and my technique is creating broken audio streams atm).
You will encode video and audio separately and then mux them together into one container. Video first: for good x264 encoding you should run mencoder a few times: first few for analyzing the vid, and the last one for encoding using analysis results. The first command is:
$ mencoder -nosound -ovc x264 -x264encopts partitions=all:8x8dct:me=umh:subq=9:frameref=6:bframes=4:b_pyramid:weight_b:qcomp=0.7:bitrate=6000:turbo=1:pass=1 -of rawvideo -ofps 24000/1001 -vf-pre harddup -o /dev/null big_file.avi
Notice the "pass=1" switch and "turbo=1" (for faster first step). This command will create a "divx2pass.log" file with the results of the first analysis in the directory. These are not bad, but we are going to make them better.
$ mencoder -nosound -ovc x264 -x264encopts partitions=all:8x8dct:me=umh:subq=9:frameref=6:bframes=4:b_pyramid:weight_b:qcomp=0.7:bitrate=6000:pass=3 -of rawvideo -ofps 24000/1001 -vf-pre harddup -o /dev/null big_file.avi
Notice that I removed the "turbo=1" option to get more accurate results and I changed pass=1 to pass=3. The "pass=1" means "create the analysis file", "pass=3" means "take the created file and make it more precise". You better make a backup of "divx2pass.log" after each step because with every run, the mencoder overwrites it and you can lose all your results at once if it (for some external reason) stops on the half-way. Run this command 2-3 times, and be ready: it will take much more time that the first one.
Now you should have an accurate and precise "divx2pass.log" file. Time to encode the video:
$ mencoder -nosound -ovc x264 -x264encopts partitions=all:8x8dct:me=umh:subq=9:frameref=6:bframes=4:b_pyramid:weight_b:qcomp=0.7:bitrate=6000:pass=2 -of rawvideo -ofps 24000/1001 -vf-pre harddup -o video.h264 big_file.avi
"pass=2" means "take the info from the analysis file and encode the video" so, you will have the "video.h264" file in your directory.
Let's go for an audio now.
$ mencoder -oac mp3lame -lameopts vbr=4:q=2:aq=2 -ovc copy -of rawaudio -ofps 24000/1001 -vf-pre harddup -o audio.mp3 big_file.avi
This will be much faster than encoding the video stream and will result in the "audio.mp3" file.
Okay, now you should have video.h264 and audio.mp3, time to mux them together.
$ mkvmerge -o final_video.mkv --default-duration 0:23.976fps video.h264 audio.mp3
This will create the "final_video.mkv" file, you can check out the result now. It is ready to be uploaded to youtube or hosted somewhere on the web.

Notice that:
1) all parameters that I pass to encoder are set very high (I prioritized movie quality above everything else). And I was criticized because of it. You can, probably, lower x264 bitrate from 6k to 4k or even 3k (it won't make the bitrate in the resulting file constant, it will just lock the encoder into this, maximum br)
2) some commands here I wrote by hand and there could be a writing mistakes. I hope you can correct them easily if there are any.
3) notice the -vf-pre harddup switch everywhere. Probably it's not needed in every command, but this thing saves the video/audio syncronization after compression and so it's a "must have" filter.
4) for x264, you should have mencoder compiled with x264 support. For mp3: with mp3lame support. "mkvmerge" is from mkvtoolnix package
5) you will run the mencoder 4-5 times for video encoding. Four is good, five if you have a free time to do it (the difference between 4 and 5 is tiny, but anyway the 5-pass vid encoding is considered on the doom9 forums).
This is how the result looks like: http://www.youtube.com/watch?v=gbgRoHm9EdI (youtube) and http://www.mediafire.com/file/km2wkm1tmdv/final3.mkv (not reencoded by youtube, from file hosting).

It's not the final parameters as I see I can do some testing with these and change them a little, but now it's close to final for producing good videos. Moreover I haven't fully tested youtube reencoding as it produces artifacts after "processing" the uploaded vid, I'll work on it later.

_________________
In Soviet Russia OpenArena plays you!


Last edited by Ivan on 18 Jul 2009, 01:05, edited 1 time in total.

Top
 

 Post subject: Re: Video recording and encoding
PostPosted: 17 Jul 2009, 10:29 
Offline
Major
 E-mail  Profile

Joined: 05 Feb 2009, 03:58
Posts: 83
Very nice tutorial. Btw, I prefer to use con_notifytime "-1" so that you don't get those small texts which are unreadable @ YouTube, for example.


Top
 

 Post subject: Re: Video recording and encoding
PostPosted: 18 Jul 2009, 09:29 
Offline
Lieutenant
User avatar
 E-mail  Profile

Joined: 31 Aug 2008, 23:49
Posts: 67
http://www.mediafire.com/file/4m4nzyidgdz/final4.mkv

The same vid, but with ofps=30:bitrate=4000 and I did 5 "pass=3" (just run the script on the notebook for half of the night). It resulted in 42.8mb file instead of 63.6 and I don't see any difference. Can someone with a big monitor (dash, probably) test how it looks like?


Top
 

 Post subject: Re: Video recording and encoding
PostPosted: 18 Jul 2009, 13:11 
Offline
Sergeant
 E-mail  Profile

Joined: 27 Sep 2008, 04:53
Posts: 26
Ivan wrote:
http://www.mediafire.com/file/4m4nzyidgdz/final4.mkv

The same vid, but with ofps=30:bitrate=4000 and I did 5 "pass=3" (just run the script on the notebook for half of the night). It resulted in 42.8mb file instead of 63.6 and I don't see any difference. Can someone with a big monitor (dash, probably) test how it looks like?

I don't see any difference.
I think the sound and video are a little desynchronized, first you hear the sound and then you see the frag.
It's (too) big, for less than 2 minutes..


Top
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]



Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group  
Design By Poker Bandits  

 

MKPortal ©2003-2008 mkportal.it
Page generated in 0.03105 seconds with 14 queries