examples.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <html>
  2. <head>
  3. <title>libvorbisenc - Documentation</title>
  4. <link rel=stylesheet href="style.css" type="text/css">
  5. </head>
  6. <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
  7. <table border=0 width=100%>
  8. <tr>
  9. <td><p class=tiny>libvorbisenc documentation</p></td>
  10. <td align=right><p class=tiny>libvorbisenc release 1.1 - 20040709</p></td>
  11. </tr>
  12. </table>
  13. <h1>Libvorbisenc Setup Examples</h1>
  14. VBR is always the recommended mode for Vorbis encoding when
  15. there's no need to impose bitrate constraints. True VBR encoding will
  16. always produce the most consistent quality output as well as the
  17. highest quality for a the bits used.
  18. <p>The following code examples prepare a
  19. <a href="vorbis_info.html">vorbis_info</a> structure for encoding
  20. use with libvorbis.<p>
  21. <h2>Example: encoding using a VBR quality mode</h2>
  22. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  23. <tr bgcolor=#cccccc><td><pre><b>
  24. vorbis_info_init(&vi);
  25. /*********************************************************************
  26. Encoding using a VBR quality mode. The usable range is -.1
  27. (lowest quality, smallest file) to 1.0 (highest quality, largest file).
  28. Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR
  29. *********************************************************************/
  30. ret = vorbis_encode_init_vbr(&vi,2,44100,.4);
  31. /*********************************************************************
  32. do not continue if setup failed; this can happen if we ask for a
  33. mode that libVorbis does not support (eg, too low a quality mode, etc,
  34. will return 'OV_EIMPL')
  35. *********************************************************************/
  36. if(ret) exit(1);
  37. </b></pre></td></tr></table>
  38. <h2>Example: encoding using average bitrate (ABR)</h2>
  39. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  40. <tr bgcolor=#cccccc><td><pre><b>
  41. vorbis_info_init(&vi);
  42. /*********************************************************************
  43. Encoding using an average bitrate mode (ABR).
  44. example: 44kHz stereo coupled, average 128kbps ABR
  45. *********************************************************************/
  46. ret = vorbis_encode_init(&vi,2,44100,-1,128000,-1);
  47. /*********************************************************************
  48. do not continue if setup failed; this can happen if we ask for a
  49. mode that libVorbis does not support (eg, too low a bitrate, etc,
  50. will return 'OV_EIMPL')
  51. *********************************************************************/
  52. if(ret) exit(1);
  53. </b></pre></td></tr></table>
  54. <h2>Example: encoding using constant bitrate (CBR)</h2>
  55. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  56. <tr bgcolor=#cccccc><td><pre><b>
  57. vorbis_info_init(&vi);
  58. /*********************************************************************
  59. Encoding using a constant bitrate mode (CBR).
  60. example: 44kHz stereo coupled, average 128kbps CBR
  61. *********************************************************************/
  62. ret = vorbis_encode_init(&vi,2,44100,128000,128000,128000);
  63. /*********************************************************************
  64. do not continue if setup failed; this can happen if we ask for a
  65. mode that libVorbis does not support (eg, too low a bitrate, etc,
  66. will return 'OV_EIMPL')
  67. *********************************************************************/
  68. if(ret) exit(1);
  69. </b></pre></td></tr></table>
  70. <h2>Example: encoding using VBR selected by approximate bitrate</h2>
  71. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  72. <tr bgcolor=#cccccc><td><pre><b>
  73. vorbis_info_init(&vi);
  74. /*********************************************************************
  75. Encode using a quality mode, but select that quality mode by asking for
  76. an approximate bitrate. This is not ABR, it is true VBR, but selected
  77. using the bitrate interface, and then turning bitrate management off:
  78. *********************************************************************/
  79. ret = ( vorbis_encode_setup_managed(&vi,2,44100,-1,128000,-1) ||
  80. vorbis_encode_ctl(&vi,OV_ECTL_RATEMANAGE2_SET,NULL) ||
  81. vorbis_encode_setup_init(&vi));
  82. /*********************************************************************
  83. do not continue if setup failed; this can happen if we ask for a
  84. mode that libVorbis does not support (eg, too low a bitrate, etc,
  85. will return 'OV_EIMPL')
  86. *********************************************************************/
  87. if(ret) exit(1);
  88. </b></pre></td></tr></table>
  89. <br><br>
  90. <hr noshade>
  91. <table border=0 width=100%>
  92. <tr valign=top>
  93. <td><p class=tiny>copyright &copy; 2000-2004 vorbis team</p></td>
  94. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a><br><a href="mailto:team@vorbis.org">team@vorbis.org</a></p></td>
  95. </tr><tr>
  96. <td><p class=tiny>libvorbisenc documentation</p></td>
  97. <td align=right><p class=tiny>libvorbisenc release 1.1 - 20040709</p></td>
  98. </tr>
  99. </table>
  100. </body>
  101. </html>