Share Pastebin
Guest
Public paste!

extract.c

By: a guest | Mar 22nd, 2010 | Syntax: C | Size: 1.42 KB | Hits: 100 | Expires: Never
Copy text to clipboard
  1. #include <stdio.h>
  2. #include <ffms.h>
  3.  
  4. int main () {
  5.        
  6.         FFMS_Init(0);
  7.  
  8.         char errmsg[1024];
  9.         FFMS_ErrorInfo errinfo;
  10.         errinfo.Buffer      = errmsg;
  11.         errinfo.BufferSize  = sizeof(errmsg);
  12.         errinfo.ErrorType   = FFMS_ERROR_SUCCESS;
  13.         errinfo.SubType     = FFMS_ERROR_SUCCESS;
  14.  
  15.         /* some source file */
  16.         const char *sourcefile = "trl.ogg";
  17.  
  18.         FFMS_Indexer *indexer = FFMS_CreateIndexer(sourcefile, &errinfo);
  19.         if (indexer == NULL) {
  20.                 fprintf(stderr, "indexer creation failed\n");
  21.         }
  22.  
  23.         int numtracks = FFMS_GetNumTracksI(indexer);
  24.  
  25.         FFMS_Index *index = FFMS_DoIndexing(indexer, 0, 0, NULL, NULL, FFMS_IEH_ABORT, NULL, NULL, &errinfo);
  26.  
  27.         if (index == NULL) {
  28.                 fprintf( stderr, "indexing failed\n" );                              
  29.         }
  30.  
  31.         int trackno = FFMS_GetFirstTrackOfType(index, FFMS_TYPE_AUDIO, &errinfo);
  32.         if (trackno <0) {
  33.                 fprintf(stderr, "getting track number failed\n");                                
  34.         }
  35.  
  36.  
  37.         FFMS_AudioSource *audiosource = FFMS_CreateAudioSource(sourcefile, trackno, index, &errinfo);
  38.         if (audiosource == NULL) {
  39.                 fprintf(stderr, "audio source creation failed\n");
  40.         }
  41.  
  42.         FFMS_DestroyIndex(index);
  43.  
  44.         FFMS_DestroyAudioSource(audiosource);
  45.         return 0;
  46. }