summaryrefslogtreecommitdiffhomepage
path: root/contrib/vorbis/doc/vorbisenc/examples.html
blob: 1fcc7e08d0f4816c5f29bd4e63c09d4cdf793110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<html>

<head>
<title>libvorbisenc - Documentation</title>
<link rel=stylesheet href="style.css" type="text/css">
</head>

<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
<table border=0 width=100%>
<tr>
<td><p class=tiny>libvorbisenc documentation</p></td>
<td align=right><p class=tiny>libvorbisenc version 1.3.2 - 20101101</p></td>
</tr>
</table>

<h1>Libvorbisenc Setup Examples</h1>

VBR is always the recommended mode for Vorbis encoding when
there's no need to impose bitrate constraints.  True VBR encoding will
always produce the most consistent quality output as well as the
highest quality for a the bits used. 

<p>The following code examples prepare a
<a href="../libvorbis/vorbis_info.html">vorbis_info</a> structure for encoding
use with libvorbis.<p>

<h2>Example: encoding using a VBR quality mode</h2>

<table border=0 width=100% color=black cellspacing=0 cellpadding=7>
<tr bgcolor=#cccccc><td><pre><b> 
   vorbis_info_init(&vi);

  /*********************************************************************
   Encoding using a VBR quality mode.  The usable range is -.1
   (lowest quality, smallest file) to 1.0 (highest quality, largest file).
   Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR 
   *********************************************************************/
  
   ret = vorbis_encode_init_vbr(&vi,2,44100,.4);

  /*********************************************************************
   do not continue if setup failed; this can happen if we ask for a
   mode that libVorbis does not support (eg, too low a quality mode, etc,
   will return 'OV_EIMPL')
   *********************************************************************/

   if(ret) exit(1);
</b></pre></td></tr></table>

<h2>Example: encoding using average bitrate (ABR)</h2>

<table border=0 width=100% color=black cellspacing=0 cellpadding=7>
<tr bgcolor=#cccccc><td><pre><b> 
   vorbis_info_init(&vi);

  /*********************************************************************
   Encoding using an average bitrate mode (ABR).
   example: 44kHz stereo coupled, average 128kbps ABR 
   *********************************************************************/
  
   ret = vorbis_encode_init(&vi,2,44100,-1,128000,-1);

  /*********************************************************************
   do not continue if setup failed; this can happen if we ask for a
   mode that libVorbis does not support (eg, too low a bitrate, etc,
   will return 'OV_EIMPL')
   *********************************************************************/

   if(ret) exit(1);
</b></pre></td></tr></table>

<h2>Example: encoding using constant bitrate (CBR)</h2>

<table border=0 width=100% color=black cellspacing=0 cellpadding=7>
<tr bgcolor=#cccccc><td><pre><b> 
   vorbis_info_init(&vi);

  /*********************************************************************
   Encoding using a constant bitrate mode (CBR).
   example: 44kHz stereo coupled, average 128kbps CBR 
   *********************************************************************/
  
   ret = vorbis_encode_init(&vi,2,44100,128000,128000,128000);

  /*********************************************************************
   do not continue if setup failed; this can happen if we ask for a
   mode that libVorbis does not support (eg, too low a bitrate, etc,
   will return 'OV_EIMPL')
   *********************************************************************/

   if(ret) exit(1);
</b></pre></td></tr></table>

<h2>Example: encoding using VBR selected by approximate bitrate</h2>

<table border=0 width=100% color=black cellspacing=0 cellpadding=7>
<tr bgcolor=#cccccc><td><pre><b> 
   vorbis_info_init(&vi);

  /*********************************************************************
   Encode using a quality mode, but select that quality mode by asking for
   an approximate bitrate.  This is not ABR, it is true VBR, but selected
   using the bitrate interface, and then turning bitrate management off:
   *********************************************************************/

   ret = ( vorbis_encode_setup_managed(&vi,2,44100,-1,128000,-1) ||
           vorbis_encode_ctl(&vi,OV_ECTL_RATEMANAGE2_SET,NULL) ||
           vorbis_encode_setup_init(&vi));

  /*********************************************************************
   do not continue if setup failed; this can happen if we ask for a
   mode that libVorbis does not support (eg, too low a bitrate, etc,
   will return 'OV_EIMPL')
   *********************************************************************/

   if(ret) exit(1);
</b></pre></td></tr></table>

<br><br>
<hr noshade>
<table border=0 width=100%>
<tr valign=top>
<td><p class=tiny>copyright &copy; 2000-2010 Xiph.Org</p></td>
<td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
</tr><tr>
<td><p class=tiny>libvorbisenc documentation</p></td>
<td align=right><p class=tiny>libvorbisenc version 1.3.2 - 20101101</p></td>
</tr>
</table>

</body>

</html>