This file is indexed.

/usr/share/doc/libffms2-dev/ffms2-api.html is in libffms2-dev 2.22-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
<h1 id="ffmpegsource2-api-documentation">FFmpegSource2 API Documentation</h1>
<p>FFmpegSource2 (FFMS2) is a wrapper library around Libav/FFmpeg, plus some additional components to deal with file formats libavformat has (or used to have) problems with.
It gives you a convenient way to say "open and decompress this media file for me, I don't care how you do it", without having to bother with the sometimes less than straightforward and less than perfectly documented Libav/FFmpeg internals.
May be frame and/or sample accurate on good days.
The library is written in C++, but the public API is C-friendly and it is possible to simply include and link directly with a pure C application.</p>
<p>The source is MIT licensed and can be obtained from GitHub; see https://github.com/FFMS/ffms2.</p>
<h2 id="limitations">Limitations</h2>
<p>FFMS2 does not mux or encode anything.
FFMS2 does not give you fine control over codec internals.
FFMS2 does not let you demux raw compressed data, you get it decompressed or not at all.
FFMS2 does not provide you with a good solution for realtime playback, since it needs to index the input file before you can retreive frames or audio samples.
FFMS2 does not currently handle things like subtitles, file attachments or chapters.
FFMS2's video frame and audio sample retrieval functions are not threadsafe; you may only have one request going at a time.</p>
<h2 id="compilation">Compilation</h2>
<p>FFMS2 has the following dependencies:</p>
<ul>
<li><strong><a href="http://www.libav.org">Libav</a></strong> or <strong><a href="http://www.ffmpeg.org">FFmpeg</a></strong> (mpv has <a href="https://github.com/mpv-player/mpv/wiki/FFmpeg-versus-Libav">a decent overview of the differences</a> if you have no idea which one to pick).<ul>
<li>At least 0.8 for libav and 0.9 for FFmpeg.</li>
<li>Further recommended configuration options: <code>--disable-debug --disable-muxers --disable-encoders --disable-filters --disable-hwaccels --disable-network --disable-devices --enable-runtime-cpudetect</code> (runtime cpudetect in particular is a good idea if you are planning on distributing the library; not disabling debug results in a gigantic dll).</li>
</ul>
</li>
<li><strong><a href="http://www.zlib.net">zlib</a></strong></li>
</ul>
<p>Compiling the library on non-Windows is trivial; the usual <code>./configure &amp;&amp; make &amp;&amp; make install</code> will suffice if FFmpeg and zlib are installed to the default locations.</p>
<h3 id="windows-specific-compilation-notes">Windows-specific compilation notes</h3>
<p>You have several options on how to build FFMS2 on Windows.
You can build both FFmpeg and FFMS2 with MinGW, FFmpeg with MinGW and FFMS2 with VC++, or both with VC++.
The standard Avisynth 2.5 plugin requires building FFMS2 with VC++, while the Avisynth C plugin (which supports Avisynth 2.6) requires building with MinGW (and using the <code>c_plugin</code> branch).</p>
<p>These days building everything with MinGW works without doing anything unusual.
Building FFmpeg with MinGW and FFMS2 with VC++ requires building FFmpeg with <code>--extra-cflags="-D_SYSCRT"</code>, and you'll probably want to build static libraries, not shared libraries.
You'll have to manually add the location which you installed the headers and libraries to to VC++'s search paths (and if you're building both 32-bit and 64-bit, be sure to add the correct ones).</p>
<p>To build everything with VC++, run <code>build-win-deps.sh</code> from a msys shell to build all of the dependencies, then open the solution and hit build.
If you're using a pre-2013 version of Visual Studio, you'll need <a href="http://download.videolan.org/pub/contrib/c99-to-c89/">c99-to-c89</a> on your msys path to be able to compile FFmpeg.</p>
<h2 id="quickstart-guide-for-impatient-people">Quickstart guide for impatient people</h2>
<p>If you don't want to know anything about anything and just want to open some video with FFMS2 in the absolutely simplest possible manner, without selective indexing, progress reporting, saved index files, keyframe or timecode reading or anything like that, here's how to do it with the absolutely bare minimum of code.</p>
<pre><code class="c++">#include &lt;ffms.h&gt;

int main (...) {
  /* Initialize the library. */
  FFMS_Init(0, 0);

  /* Index the source file. Note that this example does not index any audio tracks. */
  char errmsg[1024];
  FFMS_ErrorInfo errinfo;
  errinfo.Buffer      = errmsg;
  errinfo.BufferSize  = sizeof(errmsg);
  errinfo.ErrorType   = FFMS_ERROR_SUCCESS;
  errinfo.SubType     = FFMS_ERROR_SUCCESS;
  const char *sourcefile = &quot;somefilename&quot;;

  FFMS_Indexer *indexer = FFMS_CreateIndexer(sourcefile, &amp;errinfo);
  if (indexer == NULL) {
    /* handle error (print errinfo.Buffer somewhere) */
  }

  FFMS_Index *index = FFMS_DoIndexing2(indexer, FFMS_IEH_ABORT, &amp;errinfo);
  if (index == NULL) {
    /* handle error (you should know what to do by now) */
  } 

  /* Retrieve the track number of the first video track */
  int trackno = FFMS_GetFirstTrackOfType(index, FFMS_TYPE_VIDEO, &amp;errinfo);
  if (trackno &lt; 0) {
    /* no video tracks found in the file, this is bad and you should handle it */
    /* (print the errmsg somewhere) */
  }

  /* We now have enough information to create the video source object */
  FFMS_VideoSource *videosource = FFMS_CreateVideoSource(sourcefile, trackno, index, 1, FFMS_SEEK_NORMAL, &amp;errinfo);
  if (videosource == NULL) {
    /* handle error */
  }

  /* Since the index is copied into the video source object upon its creation,
  we can and should now destroy the index object. */
  FFMS_DestroyIndex(index);

  /* Retrieve video properties so we know what we're getting.
  As the lack of the errmsg parameter indicates, this function cannot fail. */
  const FFMS_VideoProperties *videoprops = FFMS_GetVideoProperties(videosource);

  /* Now you may want to do something with the info, like check how many frames the video has */
  int num_frames = videoprops-&gt;NumFrames;

  /* Get the first frame for examination so we know what we're getting. This is required
  because resolution and colorspace is a per frame property and NOT global for the video. */
  const FFMS_Frame *propframe = FFMS_GetFrame(videosource, 0, &amp;errinfo);

  /* Now you may want to do something with the info; particularly interesting values are:
  propframe-&gt;EncodedWidth; (frame width in pixels)
  propframe-&gt;EncodedHeight; (frame height in pixels)
  propframe-&gt;EncodedPixelFormat; (actual frame colorspace)
  */

  /* If you want to change the output colorspace or resize the output frame size,
  now is the time to do it. IMPORTANT: This step is also required to prevent
  resolution and colorspace changes midstream. You can you can always tell a frame's
  original properties by examining the Encoded* properties in FFMS_Frame. */
  /* See libavutil/pixfmt.h for the list of pixel formats/colorspaces.
  To get the name of a given pixel format, strip the leading PIX_FMT_
  and convert to lowercase. For example, PIX_FMT_YUV420P becomes &quot;yuv420p&quot;. */

  /* A -1 terminated list of the acceptable output formats. */
  int pixfmts[2];
  pixfmts[0] = FFMS_GetPixFmt(&quot;bgra&quot;);
  pixfmts[1] = -1;

  if (FFMS_SetOutputFormatV2(videosource, pixfmts, propframe-&gt;EncodedWidth, propframe-&gt;EncodedHeight,
                             FFMS_RESIZER_BICUBIC, &amp;errinfo)) {
    /* handle error */
  }

  /* now we're ready to actually retrieve the video frames */
  int framenumber = 0; /* valid until next call to FFMS_GetFrame* on the same video object */
  const FFMS_Frame *curframe = FFMS_GetFrame(videosource, framenumber, &amp;errinfo);
  if (curframe == NULL) {
    /* handle error */
  }
  /* do something with curframe */
  /* continue doing this until you're bored, or something */

  /* now it's time to clean up */
  FFMS_DestroyVideoSource(videosource);

  return 0;
}
</code></pre>

<p>And that's pretty much it. Easy, ain't it?</p>
<h2 id="indexing-and-you">Indexing and You</h2>
<p>Before opening a media file with FFMS2, you <strong>must</strong> index it.
This is to ensure that keyframe positions, timecode data and other interesting things are known so that frame-accurate seeking is easily possible.</p>
<p>First, you create an indexer object using <a href="#ffms_createindexer-creates-an-indexer-object-for-the-given-file">FFMS_CreateIndexer</a> and the source filename.
The indexer can be queried for information about the file using <a href="#ffms_getnumtracksi-gets-the-number-of-tracks-in-a-given-indexer">FFMS_GetNumTracksI</a>, <a href="#ffms_gettracktypei-gets-the-track-type-of-a-given-track">FFMS_GetTrackTypeI</a> and <a href="#ffms_getcodecnamei-gets-the-name-of-the-codec-used-for-a-given-track">FFMS_GetCodecNameI</a> to determine how many tracks there are and what their respective types are.
You can configure things like what tracks to index using <a href="#ffms_trackindexsettings-enable-or-disable-indexing-of-a-track">FFMS_TrackIndexSettings</a>, <a href="#ffms_tracktypeindexsettings-enable-or-disable-indexing-of-a-tracks-of-a-given-type">FFMS_TrackTypeIndexSettings</a>, <a href="#ffms_setaudionamecallback-choose-the-filename-for-audio-track-dumping">FFMS_SetAudioNameCallback</a> and <a href="#ffms_setprogresscallback-set-callback-function-for-indexing-progress-updates">FFMS_SetProgressCallback</a>.
When you have done so, you call <a href="#ffms_doindexing2-indexes-the-file-represented-by-an-indexer-object">FFMS_DoIndexing2</a> to perform the actual indexing.
If you change your mind and decide there are no tracks interesting to you in the file, call <a href="#ffms_cancelindexing-destroys-the-given-indexer-object">FFMS_CancelIndexing</a>.
Both <a href="#ffms_doindexing2-indexes-the-file-represented-by-an-indexer-object">FFMS_DoIndexing2</a> and <a href="#ffms_cancelindexing-destroys-the-given-indexer-object">FFMS_CancelIndexing</a> destroys the indexer object and frees its memory.</p>
<p>When you have indexed the file you can write the index object to a disk file using <a href="#ffms_writeindex-writes-an-index-object-to-disk">FFMS_WriteIndex</a>, which is useful if you expect to open the same file more than once, since it saves you from reindexing it every time.
It can be particularly time-saving with very large files or files with a lot of audio tracks, since both of those can take quite some time to index.</p>
<p>To create an index object from a saved disk file, use <a href="#ffms_readindex-reads-an-index-file-from-disk">FFMS_ReadIndex</a>.
Note that index files can only be read by the exact same version of FFMS2 as they were written with.
Attempting to open an index written with a different version will give you an index mismatch error.
If you want to verify that a given index file actually is an index of the source file you think it is, use <a href="#ffms_indexbelongstofile-check-if-a-given-index-belongs-to-a-given-file">FFMS_IndexBelongsToFile</a>.</p>
<h2 id="function-reference">Function Reference</h2>
<p>Most functions that can fail in one way or another (as well as some that should be able to but currently don't) support error reporting using the <code>ErrorInfo</code> parameter.
Example:</p>
<pre><code class="c++">char errmsg[1024];
FFMS_ErrorInfo errinfo;
errinfo.Buffer      = errmsg;
errinfo.BufferSize  = sizeof(errmsg);
errinfo.ErrorType   = FFMS_ERROR_SUCCESS;
errinfo.SubType     = FFMS_ERROR_SUCCESS;

const FFMS_Frame *frame = FFMS_GetFrame(vb, frameno, &amp;errinfo);
/* failure? */
if (frame == NULL) {
  printf(&quot;failed to get frame number %d, error message: %s&quot;, frameno, errinfo.Buffer);
  /* etc... */
}
</code></pre>

<p>How many characters you want to allocate to the error message is up to you; if you allocate too few the messages will get truncated.
1024 should be enough for anyone.</p>
<h3 id="ffms_init-initializes-the-library">FFMS_Init - initializes the library</h3>
<pre><code class="c++">void FFMS_Init(int Unused, int UseUTF8Paths);
</code></pre>

<p>Initializes the FFMS2 library.
This function must be called once at the start of your program, before doing any other FFMS2 function calls.</p>
<h4 id="arguments">Arguments</h4>
<h5 id="int-unused"><code>int Unused</code></h5>
<p>This argument is no longer used and is left only for API/ABI compatibility. Pass 0.</p>
<h5 id="int-useutf8paths"><code>int UseUTF8Paths</code></h5>
<p>Controls filename handling on Windows; on all other operating systems this parameter does nothing and should be ignored.</p>
<p>On Windows, setting this parameter to a true value will make FFMS assume that all filename strings passed to it are UTF-8 encoded; setting it to false will make it assume filenames are in the system default codepage for non-Unicode programs.
Setting this to true is one of two known ways to make FFMS2 open files with filenames containing characters that are not expressible in said codepage; the other is using the short (DOS 8.3 notation) filename.
You can use the Win32 API function <code>WideCharToMultiByte()</code> to convert your <code>wchar_t*</code> Unicode strings to UTF-8 in <code>char*</code>, if necessary.</p>
<p>Prior to API version 2.14.0.0 this functionality was a compile-time option and was controlled via <code>FFMS_USE_UTF8_PATHS</code>.</p>
<h3 id="ffms_getloglevel-gets-ffmpeg-message-level">FFMS_GetLogLevel - gets FFmpeg message level</h3>
<pre><code class="c++">int FFMS_GetLogLevel();
</code></pre>

<p>Retrieves FFmpeg's current logging/message level (i.e. how much diagnostic noise it prints to <code>STDERR</code>).
If you want to make any sense of the returned value you'd better <code>#include &lt;libavutil/log.h&gt;</code> from the FFmpeg source tree to get the relevant constant definitions.
Alternatively, just copy the relevant constant definitions into your own code and hope the FFmpeg devs doesn't change them randomly for no particular reason like they do with everything else.</p>
<h3 id="ffms_setloglevel-sets-ffmpeg-message-level">FFMS_SetLogLevel - sets FFmpeg message level</h3>
<pre><code class="c++">void FFMS_SetLogLevel(int Level);
</code></pre>

<p>Sets FFmpeg's logging/message level; see <a href="#ffms_getloglevel-gets-ffmpeg-message-level">FFMS_GetLogLevel</a> for details.</p>
<h3 id="ffms_createvideosource-creates-a-video-source-object">FFMS_CreateVideoSource - creates a video source object</h3>
<pre><code class="c++">FFMS_VideoSource *FFMS_CreateVideoSource(const char *SourceFile, int Track, FFMS_Index *Index,
    int Threads, int SeekMode, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Creates a <code>FFMS_VideoSource</code> object with the given properties.
The <code>FFMS_VideoSource</code> object represents a video stream, and can be passed to other functions to retreive frames and metadata from said stream.
The video stream in question must be indexed first (see the indexing functions).
Note that the index object is copied into the <code>FFMS_VideoSource</code> object upon its creation, so once you've created the video source you can generally destroy the index object immediately, since all info you can retrieve from it is also retrievable from the <code>FFMS_VideoSource</code> object.</p>
<h4 id="arguments_1">Arguments</h4>
<h5 id="const-char-sourcefile"><code>const char *SourceFile</code></h5>
<p>The source file to open. Can be an absolute or relative path.</p>
<h5 id="int-track"><code>int Track</code></h5>
<p>The track number of the video track to open, as seen by the relevant demuxer.
See <a href="#ffms_getnumtracks-gets-the-number-of-tracks-in-a-given-index">FFMS_GetNumTracks</a>, <a href="#ffms_gettracktype-gets-the-track-type-of-a-given-track">FFMS_GetTrackType</a>, <a href="#ffms_getfirsttrackoftype-gets-the-track-number-of-the-first-track-of-a-given-type">FFMS_GetFirstTrackOfType</a> and their variants for further information on how to determine this.</p>
<h5 id="ffms_index-index"><code>FFMS_Index *Index</code></h5>
<p>A pointer to a FFMS_Index object containing indexing information for the track you want to open.</p>
<h5 id="int-threads"><code>int Threads</code></h5>
<p>The number of decoding threads to use.
Anything less than 1 will use threads equal to the number of CPU cores.
Values &gt;1 have no effect if FFmpeg was not compiled with threading support.</p>
<h5 id="int-seekmode"><code>int SeekMode</code></h5>
<p>For a list of valid values, see <a href="#ffms_seekmode">FFMS_SeekMode</a>.
Controls how seeking (random access) is handled and hence affects frame accuracy.
You will almost always want to use <code>FFMS_SEEK_NORMAL</code>.</p>
<h5 id="ffms_errorinfo-errorinfo"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values">Return values</h4>
<p>Returns a pointer to the created <code>FFMS_VideoSource</code> object on success.
Returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_createaudiosource-creates-an-audio-source-object">FFMS_CreateAudioSource - creates an audio source object</h3>
<pre><code class="c++">FFMS_AudioSource *FFMS_CreateAudioSource(const char *SourceFile, int Track, FFMS_Index *Index, int DelayMode,
    FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Does exactly the same thing as <a href="#ffms_createvideosource-creates-a-video-source-object">FFMS_CreateVideoSource</a>, but for audio tracks.
Except for DelayMode, arguments and return values are identical.</p>
<h4 id="arguments_2">Arguments</h4>
<h5 id="int-delaymode"><code>int DelayMode</code></h5>
<p>Controls how audio with a non-zero first PTS is handled; in other words what FFMS does about audio delay.
Possible arguments are:</p>
<ul>
<li><strong>FFMS_DELAY_NO_SHIFT</strong>: No adjustment is made; the first decodable audio sample becomes the first sample in the output.
   May lead to audio/video desync.</li>
<li><strong>FFMS_DELAY_TIME_ZERO</strong>: Samples are created (with silence) or discarded so that sample 0 in the decoded audio starts at time zero.</li>
<li><strong>FFMS_DELAY_FIRST_VIDEO_TRACK</strong>: Samples are created (with silence) or discarded so that sample 0 in the decoded audio starts at the same time as frame 0 of the first video track.
   This is what most users want and is a sane default.</li>
<li><strong>Any integer &gt;= 0</strong>: Identical to <code>FFMS_DELAY_FIRST_VIDEO_TRACK</code>, but interprets the argument as a track number and adjusts the audio relative to the video track with that number (if the given track number isn't a video track, audio source creation will fail).</li>
</ul>
<h3 id="ffms_destroyvideosource-ffms_destroyaudiosource-deallocates-a-video-or-audio-source-object">FFMS_DestroyVideoSource, FFMS_DestroyAudioSource - deallocates a video or audio source object</h3>
<pre><code class="c++">void FFMS_DestroyVideoSource(FFMS_VideoSource *V);
void FFMS_DestroyAudioSource(FFMS_AudioSource *A);
</code></pre>

<p>Deallocates the given <code>FFMS_VideoSource</code> or <code>FFMS_AudioSource</code> object and frees the memory allocated by <a href="#ffms_createvideosource-creates-a-video-source-object">FFMS_CreateVideoSource</a> or <a href="#ffms_createaudiosource-creates-an-audio-source-object">FFMS_CreateAudioSource</a>, respectively.</p>
<h3 id="ffms_getvideoproperties-retrieves-video-properties">FFMS_GetVideoProperties - retrieves video properties</h3>
<pre><code class="c++">const FFMS_VideoProperties *FFMS_GetVideoProperties(FFMS_VideoSource *V);
</code></pre>

<p>Retreives the video properties from the given <code>FFMS_VideoSource</code> object and stores them in a <a href="#ffms_videoproperties">FFMS_VideoProperties</a> struct.
Returns a pointer to said struct.</p>
<h3 id="ffms_getaudioproperties-retrieves-audio-properties">FFMS_GetAudioProperties - retrieves audio properties</h3>
<pre><code class="c++">const FFMS_AudioProperties *FFMS_GetAudioProperties(FFMS_AudioSource *A);
</code></pre>

<p>Does the exact same thing as <a href="#ffms_getvideoproperties-retrieves-video-properties">FFMS_GetVideoProperties</a>, but for an <code>FFMS_AudioSource</code> object.
See <a href="#ffms_audioproperties">FFMS_AudioProperties</a>.</p>
<h3 id="ffms_getframe-retrieves-a-given-video-frame">FFMS_GetFrame - retrieves a given video frame</h3>
<pre><code class="c++">const FFMS_Frame *FFMS_GetFrame(FFMS_VideoSource *V, int n, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Gets and decodes a video frame from the video stream represented by the given <code>FFMS_VideoSource</code> object and stores it in a <a href="#ffms_frame">FFMS_Frame</a> struct.
The colorspace and resolution of the frame can be changed by calling <a href="#ffms_setoutputformatv2-sets-the-output-format-for-video-frames">FFMS_SetOutputFormatV2</a> with the appropriate parameters before calling this function.
Note that this function is not thread-safe (you can only request one frame at a time from a given <code>FFMS_VideoSource</code> object) and that the returned pointer to the <code>FFMS_Frame</code> is a <code>const</code> pointer.</p>
<h4 id="arguments_3">Arguments</h4>
<h5 id="ffms_videosource-v"><code>FFMS_VideoSource *V</code></h5>
<p>A pointer to the <code>FFMS_VideoSource</code> object that represents the video stream you want to retrieve a frame from.</p>
<h5 id="int-n"><code>int n</code></h5>
<p>The frame number to get. Frame numbering starts from zero, and hence the first frame is number 0 (not 1) and the last frame is number <code>FFMS_VideoProperties-&gt;NumFrames</code> minus 1.
Requesting a frame number beyond the stream end or before the stream start (i.e. negative) may cause undefined behavior.</p>
<h5 id="ffms_errorinfo-errorinfo_1"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_1">Return values</h4>
<p>Returns a pointer to the <code>FFMS_Frame</code> on success. Returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<p>The returned frame is owned by the given <code>FFMS_VideoSource</code>, and remains valid until the video source is destroyed, a different frame is requested from the video source, or the video source's input or output format is changed.
Note that while <code>FFMS_GetFrame</code> tends to return the same pointer with each call, it is not safe to rely on this as the output frame will sometimes be reallocated.</p>
<h3 id="ffms_getframebytime-retrieves-a-video-frame-at-a-given-timestamp">FFMS_GetFrameByTime - retrieves a video frame at a given timestamp</h3>
<pre><code class="c++">const FFMS_Frame *FFMS_GetFrameByTime(FFMS_VideoSource *V, double Time, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Does the exact same thing as <a href="#ffms_getframe-retrieves-a-given-video-frame">FFMS_GetFrame</a> except instead of giving it a frame number you give it a timestamp in seconds, and it will retrieve the frame that starts closest to that timestamp.
This function exists for the people who are too lazy to build and traverse a mapping between frame numbers and timestamps themselves.</p>
<h3 id="ffms_getaudio-decodes-a-number-of-audio-samples">FFMS_GetAudio - decodes a number of audio samples</h3>
<pre><code class="c++">int FFMS_GetAudio(FFMS_AudioSource *A, void *Buf, int64_t Start, int64_t Count, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Decodes the requested audio samples from the audio stream represented by the given <code>FFMS_AudioSource</code> object and stores them in the given buffer.
Note that this function is not thread-safe; you can only request one decoding operation at a time from a given <code>FFMS_AudioSource</code> object.</p>
<h4 id="arguments_4">Arguments</h4>
<h5 id="ffms_audiosource-a"><code>FFMS_AudioSource *A</code></h5>
<p>A pointer to the <code>FFMS_AudioSource</code> object that represents the audio stream you want to get samples from.</p>
<h5 id="void-buf"><code>void *Buf</code></h5>
<p>A pointer to the buffer where the decoded samples will end up.
You are responsible for allocating and freeing this buffer yourself, so you better check the <a href="#ffms_getaudioproperties-retrieves-audio-properties">FFMS_AudioProperties</a> for the sample format, number of channels, channel layout etc first, so you know how much memory you need to allocate.
The formula to calculate the required size of the buffer is (obviously) <code>num_bytes = bytes_per_sample * num_channels * num_samples</code>.</p>
<h5 id="int64_t-start-int64_t-count"><code>int64_t Start, int64_t Count</code></h5>
<p>The range of samples you want decoded.
The output is <code>Count</code> samples long, starting from <code>Start</code> (inclusive).
Like video frame numbers, sample numbers start from zero and hence the last sample in the stream is number <code>FFMS_AudioProperties-&gt;NumSamples</code> minus 1.
Requesting samples beyond the stream end or before the stream start may result in undefined behavior.</p>
<h5 id="ffms_errorinfo-errorinfo_2"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_2">Return values</h4>
<p>Returns 0 on success.
Returns non-0 and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_setoutputformatv2-sets-the-output-format-for-video-frames">FFMS_SetOutputFormatV2 - sets the output format for video frames</h3>
<pre><code class="c++">int FFMS_SetOutputFormatV2(FFMS_VideoSource *V, int *TargetFormats, int Width, int Height, int Resizer,
    FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Sets the colorspace and frame dimensions to be used for output of frames from the given <code>FFMS_VideoSource</code> by all further calls to <a href="#ffms_getframe-retrieves-a-given-video-frame">FFMS_GetFrame</a> and <a href="#ffms_getframebytime-retrieves-a-video-frame-at-a-given-timestamp">FFMS_GetFrameByTime</a>, until next time you call <code>FFMS_SetOutputFormatV2</code> or <a href="#ffms_resetoutputformatv-resets-the-video-output-format">FFMS_ResetOutputFormatV</a>.
You can change the output format at any time without having to reinitialize the <code>FFMS_VideoSource</code> object or anything else.
Can be used to convert the video to grayscale or monochrome if you are so inclined.
If you provided a list of more than one colorspace/pixelformat, you should probably check the <a href="#ffms_frame">FFMS_Frame</a> properties afterwards to see which one got selected.
And remember to do so for EVERY frame or you may get a nasty surprise.
Added in version 2.16.3.0 and replaces <code>FFMS_SetOutputFormatV</code>.</p>
<h4 id="arguments_5">Arguments</h4>
<h5 id="ffms_videosource-v_1"><code>FFMS_VideoSource *V</code></h5>
<p>A pointer to the <code>FFMS_VideoSource</code> object that represents the video stream you want to change the output format for.</p>
<h5 id="int-targetformats"><code>int *TargetFormats</code></h5>
<p>The desired output colorspace(s).
It is a -1 terminated list of acceptable output colorspace to choose from.
The destination that gives the least lossy conversion from the source colorspace will automatically be selected, <strong>on a frame basis</strong>.
To get the integer constant representing a given colorspace, see <a href="#ffms_getpixfmt-gets-a-colorspace-identifier-from-a-colorspace-name">FFMS_GetPixFmt</a>.</p>
<p>Example:</p>
<pre><code class="c++">int targetformats[3];
targetformats[0] = pixfmt1;
targetformats[1] = pixfmt2;
targetformats[2] = -1;
</code></pre>

<h5 id="int-width-int-height"><code>int Width, int Height</code></h5>
<p>The desired image dimensions, in pixels.
If you do not want to resize just pass the input dimensions.
Passing invalid dimensions (like 0 or negative) has undefined behavior.</p>
<h5 id="int-resizer"><code>int Resizer</code></h5>
<p>The desired image resizing algorithm, represented by an integer as enumerated in <a href="#ffms_resizers">FFMS_Resizers</a>.
You must choose one even if you're not actually rescaling the image, because the video may change resolution mid-stream and then you will be using a resizer whether you want it or not (you will only know that the resolution changed after you actually decoded a frame with a new resolution), and it may also get used for rescaling subsampled chroma planes.</p>
<h5 id="ffms_errorinfo-errorinfo_3"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_3">Return values</h4>
<p>Returns 0 on success.
Returns non-0 and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_resetoutputformatv-resets-the-video-output-format">FFMS_ResetOutputFormatV - resets the video output format</h3>
<pre><code class="c++">void FFMS_ResetOutputFormatV(FFMS_VideoSource *V);
</code></pre>

<p>Resets the output format for the given <code>FFMS_VideoSource</code> object so that no conversion takes place.
Note that the results of this function may vary wildly, particularly if the video changes resolution mid-stream.
If you call it, you'd better call <a href="#ffms_getframe-retrieves-a-given-video-frame">FFMS_GetFrame</a> afterwards and examine the properties to see what you actually ended up with.</p>
<h3 id="ffms_setinputformatv-override-the-source-format-for-video-frames">FFMS_SetInputFormatV - override the source format for video frames</h3>
<pre><code class="c++">int FFMS_SetInputFormatV(FFMS_VideoSource *V, int ColorSpace, int ColorRange, int PixelFormat,
    FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Override the source colorspace passed to SWScale for conversions and resizing for all further calls to <a href="#ffms_getframe-retrieves-a-given-video-frame">FFMS_GetFrame</a> and <a href="#ffms_getframebytime-retrieves-a-video-frame-at-a-given-timestamp">FFMS_GetFrameByTime</a>, until next time you call <code>FFMS_SetInputFormatV</code> or <a href="#ffms_resetinputformatv-resets-the-video-input-format">FFMS_ResetInputFormatV</a>.
You can change the input format at any time without having to reinitialize the <code>FFMS_VideoSource</code> object or anything else.
This is intended primarily for compatibility with programs which use the wrong YUV colorspace when converting to or from RGB, but can also be useful for files which have incorrect colorspace flags.
Values passed are not checked for sanity; if you wish you may tell FFMS2 to pretend that a RGB files is actually YUV using this function, but doing so is unlikely to have useful results.
This function only has an effect if the output format is also set with [FFMS_SetOutputFormatV2][SetOutpurFormatV2].
Added in version 2.17.1.0.</p>
<h4 id="arguments_6">Arguments</h4>
<h5 id="ffms_videosource-v_2"><code>FFMS_VideoSource *V</code></h5>
<p>A pointer to the <code>FFMS_VideoSource</code> object that represents the video stream you want to change the input format for.</p>
<h5 id="int-colorspace"><code>int ColorSpace</code></h5>
<p>The desired input colorspace, or FFMS_CS_UNSPECIFIED to leave it unchanged.
See <a href="#ffms_colorspaces">FFMS_ColorSpaces</a>.</p>
<h5 id="int-colorrange"><code>int ColorRange</code></h5>
<p>The desired input colorrange, or FFMS_CR_UNSPECIFIED to leave it unchanged.
See <a href="#ffms_colorranges">FFMS_ColorRanges</a>.</p>
<h5 id="int-pixelformat"><code>int PixelFormat</code></h5>
<p>The desired input pixel format; see <a href="#ffms_getpixfmt-gets-a-colorspace-identifier-from-a-colorspace-name">FFMS_GetPixFmt</a>. <code>FFMS_GetPixFmt("")</code> will leave the pixel format unchanged.</p>
<h5 id="ffms_errorinfo-errorinfo_4"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_4">Return values</h4>
<p>Returns 0 on success.
Returns non-0 and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_resetinputformatv-resets-the-video-input-format">FFMS_ResetInputFormatV - resets the video input format</h3>
<pre><code class="c++">void FFMS_ResetInputFormatV(FFMS_VideoSource *V);
</code></pre>

<p>Resets the input format for the given <code>FFMS_VideoSource</code> object to the values specified in the source file.</p>
<h3 id="ffms_destroyindex-deallocates-an-index-object">FFMS_DestroyIndex - deallocates an index object</h3>
<pre><code class="c++">void FFMS_DestroyFFMS_Index(FFMS_Index *Index);
</code></pre>

<p>Deallocates the given <code>FFMS_Index</code> object and frees the memory that was allocated when it was created.</p>
<h3 id="ffms_getsourcetype-gets-which-source-module-was-used-to-open-the-given-index">FFMS_GetSourceType - gets which source module was used to open the given index</h3>
<pre><code class="c++">int FFMS_GetSourceType(FFMS_Index *Index);
</code></pre>

<p>Returns <code>FFMS_SOURCE_LAVF</code>.</p>
<h3 id="ffms_getsourcetypei-gets-which-source-module-was-used-to-open-the-given-indexer">FFMS_GetSourceTypeI - gets which source module was used to open the given indexer</h3>
<pre><code class="c++">int FFMS_GetSourceTypeI(FFMS_Index *Indexer);
</code></pre>

<p>Does the same thing as <a href="#ffms_getsourcetype-gets-which-source-module-was-used-to-open-the-given-index">FFMS_GetSourceType</a>, but takes an indexer instead of an index.</p>
<h3 id="ffms_geterrorhandling-gets-which-error-handling-mode-was-used-when-creating-the-given-index">FFMS_GetErrorHandling - gets which error handling mode was used when creating the given index</h3>
<pre><code class="c++">int FFMS_GetErrorHandling(FFMS_Index *Index);
</code></pre>

<p>Returns the value of the ErrorHandling parameter which was passed to <a href="#ffms_doindexing2-indexes-the-file-represented-by-an-indexer-object">FFMS_DoIndexing2</a>.</p>
<h3 id="ffms_getfirsttrackoftype-gets-the-track-number-of-the-first-track-of-a-given-type">FFMS_GetFirstTrackOfType - gets the track number of the first track of a given type</h3>
<pre><code class="c++">int FFMS_GetFirstTrackOfType(FFMS_Index *Index, int TrackType, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Finds the first track of the given <a href="#ffms_tracktype">FFMS_TrackType</a> in the given <code>FFMS_Index</code> and returns its track number, suitable for use as an argument to <a href="#ffms_createvideosource-creates-a-video-source-object">FFMS_CreateVideoSource</a> or <a href="#ffms_createaudiosource-creates-an-audio-source-object">FFMS_CreateAudioSource</a>, as well as to some other functions.</p>
<h4 id="arguments_7">Arguments</h4>
<h5 id="ffms_index-index_1"><code>FFMS_Index *Index</code></h5>
<p>A pointer to the <code>FFMS_Index</code> object that represents the media file you want to look for tracks in.</p>
<h5 id="int-tracktype"><code>int TrackType</code></h5>
<p>The track type to look for.
See <a href="#ffms_tracktype">FFMS_TrackType</a>.</p>
<h5 id="ffms_errorinfo-errorinfo_5"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_5">Return values</h4>
<p>Returns the track number (an integer greater than or equal to 0) on success.
Returns a negative integer and sets ErrorMsg on failure (i.e. if no track of the given type was found).</p>
<h3 id="ffms_getfirstindexedtrackoftype-gets-the-track-number-of-the-first-track-of-a-given-type">FFMS_GetFirstIndexedTrackOfType - gets the track number of the first track of a given type</h3>
<pre><code class="c++">int FFMS_GetFirstIndexedTrackOfType(FFMS_Index *Index, int TrackType, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Does the exact same thing as <a href="#ffms_getfirsttrackoftype-gets-the-track-number-of-the-first-track-of-a-given-type">FFMS_GetFirstTrackOfType</a> but ignores tracks that have not been indexed.</p>
<h3 id="ffms_getnumtracks-gets-the-number-of-tracks-in-a-given-index">FFMS_GetNumTracks - gets the number of tracks in a given index</h3>
<pre><code class="c++">int FFMS_GetNumTracks(FFMS_Index *Index);
</code></pre>

<p>Returns the total number of tracks in the media file represented by the given <code>FFMS_Index</code>.</p>
<h3 id="ffms_getnumtracksi-gets-the-number-of-tracks-in-a-given-indexer">FFMS_GetNumTracksI - gets the number of tracks in a given indexer</h3>
<pre><code class="c++">int FFMS_GetNumTracksI(FFMS_Indexer *Indexer);
</code></pre>

<p>Returns the total number of tracks in the media file represented by the given <code>FFMS_Indexer</code>.
In other words, does the same thing as <a href="#ffms_getnumtracks-gets-the-number-of-tracks-in-a-given-index">FFMS_GetNumTracks</a> but does not require indexing the entire file first.</p>
<h3 id="ffms_gettracktype-gets-the-track-type-of-a-given-track">FFMS_GetTrackType - gets the track type of a given track</h3>
<pre><code class="c++">int FFMS_GetTrackType(FFMS_Track *T);
</code></pre>

<p>Returns an integer representing the <a href="#ffms_tracktype">FFMS_TrackType</a> of the track represented by the given <code>FFMS_Track</code> object.</p>
<h3 id="ffms_gettracktypei-gets-the-track-type-of-a-given-track">FFMS_GetTrackTypeI - gets the track type of a given track</h3>
<pre><code class="c++">int FFMS_GetTrackTypeI(FFMS_Indexer *Indexer, int Track);
</code></pre>

<p>Returns an integer representing the <a href="#ffms_tracktype">FFMS_TrackType</a> of the track number <code>Track</code> in the media file represented by the given <code>FFMS_Indexer</code>.
In other words, does the same thing as <a href="#ffms_gettracktype-gets-the-track-type-of-a-given-track">FFMS_GetTrackType</a>, but does not require having indexed the file first.
If you have indexed the file, use <a href="#ffms_gettracktype-gets-the-track-type-of-a-given-track">FFMS_GetTrackType</a> instead since the <code>FFMS_Indexer</code> object is destructed when the index is created.
Note that specifying an invalid track number may lead to undefined behavior.</p>
<h3 id="ffms_getcodecnamei-gets-the-name-of-the-codec-used-for-a-given-track">FFMS_GetCodecNameI - gets the name of the codec used for a given track</h3>
<pre><code class="c++">const char *FFMS_GetCodecNameI(FFMS_Indexer *Indexer, int Track);
</code></pre>

<p>Returns the human-readable name ("long name" in FFmpeg terms) of the codec used in the given track number in the media file represented by the given <code>FFMS_Indexer</code> object.
Useful if you want to, say, pop up a menu asking the user which tracks he or she wishes to index.
Note that specifying an invalid track number may lead to undefined behavior.</p>
<h3 id="ffms_getformatnamei-gets-the-name-of-the-container-format-used-in-the-given-indexer">FFMS_GetFormatNameI - gets the name of the container format used in the given indexer</h3>
<pre><code class="c++">const char *FFMS_GetFormatNameI(FFMS_Indexer *Indexer);
</code></pre>

<p>Returns the human-readable name ("long name" in FFmpeg terms) of the container format used by the file represented by the given <code>FFMS_Indexer</code>.</p>
<h3 id="ffms_getnumframes-gets-the-number-of-frames-in-a-given-track">FFMS_GetNumFrames - gets the number of frames in a given track</h3>
<pre><code class="c++">int FFMS_GetNumFrames(FFMS_Track *T);
</code></pre>

<p>Returns the number of frames in the track represented by the given <code>FFMS_Track</code>.
For a video track this is the number of video frames, which can be useful; for an audio track it's the number of packets, which is almost never useful, since nothing in the API exposes those.
A return value of 0 indicates the track has not been indexed.</p>
<h3 id="ffms_getframeinfo-gets-information-about-a-given-frame">FFMS_GetFrameInfo - gets information about a given frame</h3>
<pre><code class="c++">const FFMS_FrameInfo *FFMS_GetFrameInfo(FFMS_Track *T, int Frame);
</code></pre>

<p>Gets information about the given frame (identified by its frame number) from the indexing information in the given <code>FFMS_Track</code> and stores it in a <a href="#ffms_frameinfo">FFMS_FrameInfo</a> struct.
Using this function on a <code>FFMS_Track</code> representing a non-video track has undefined behavior.</p>
<h4 id="arguments_8">Arguments</h4>
<h5 id="ffms_track-t"><code>FFMS_Track *T</code></h5>
<p>A pointer to the <code>FFMS_Track</code> object that represents the video track containing the frame you want to get information about.</p>
<h5 id="int-frame"><code>int Frame</code></h5>
<p>The frame number to get information about.
See <a href="#ffms_getframe-retrieves-a-given-video-frame">FFMS_GetFrame</a> for information about frame numbers.
Requesting information about a frame before the start or after the end of the video track may result in undefined behavior, so don't do that.</p>
<h5 id="ffms_errorinfo-errorinfo_6"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_6">Return values</h4>
<p>Returns a pointer to the <a href="#ffms_frameinfo">FFMS_FrameInfo</a> struct on success.
Returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_gettrackfromindex-retrieves-track-info-from-an-index">FFMS_GetTrackFromIndex - retrieves track info from an index</h3>
<pre><code class="c+++">FFMS_Track *FFMS_GetTrackFromIndex(FFMS_Index *Index, int Track);
</code></pre>

<p>Gets track data for the given track number from the given <code>FFMS_Index</code> object, stores it in a <code>FFMS_Track</code> object and returns a pointer to it.
Use this function if you don't want to (or cannot) open the track with <a href="#ffms_createvideosource-creates-a-video-source-object">FFMS_CreateVideoSource</a> or <a href="#ffms_createaudiosource-creates-an-audio-source-object">FFMS_CreateAudioSource</a> first.
If you already have a <code>FFMS_VideoSource</code> or <code>FFMS_AudioSource</code> object it's safer to use <a href="#ffms_gettrackfromvideo-ffms_gettrackfromaudio-retrieves-track-info-from-audio-or-video-source">FFMS_GetTrackFromVideo</a> or <a href="#ffms_gettrackfromvideo-ffms_gettrackfromaudio-retrieves-track-info-from-audio-or-video-source">FFMS_GetTrackFromAudio</a> instead.
Note that specifying a nonexistent or invalid track number leads to undefined behavior (usually an access violation).
Also note that the returned <code>FFMS_Track</code> object is only valid until its parent <code>FFMS_Index</code> object is destroyed.</p>
<h4 id="arguments_9">Arguments</h4>
<h5 id="ffms_index-index_2"><code>FFMS_Index *Index</code></h5>
<p>A pointer to the <code>FFMS_Index</code> object that represents the media file containing the track whose index information you want to get.</p>
<h5 id="int-track_1"><code>int Track</code></h5>
<p>The track number, as seen by the relevant demuxer (see <a href="#ffms_getnumtracks-gets-the-number-of-tracks-in-a-given-index">FFMS_GetNumTracks</a>, <a href="#ffms_gettracktype-gets-the-track-type-of-a-given-track">FFMS_GetTrackType</a>, <a href="#ffms_getfirsttrackoftype-gets-the-track-number-of-the-first-track-of-a-given-type">FFMS_GetFirstTrackOfType</a> and their variants).</p>
<h5 id="ffms_errorinfo-errorinfo_7"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_7">Return values</h4>
<p>Returns the <code>FFMS_Track</code> on success.
Note that requesting indexing information for a track that has not been indexed will not cause an error, it will just return an empty <code>FFMS_Track</code> (check for &gt;0 frames using <a href="#ffms_getnumframes-gets-the-number-of-frames-in-a-given-track">FFMS_GetNumFrames</a> to see if the returned object actually contains indexing information).</p>
<h3 id="ffms_gettrackfromvideo-ffms_gettrackfromaudio-retrieves-track-info-from-audio-or-video-source">FFMS_GetTrackFromVideo, FFMS_GetTrackFromAudio - retrieves track info from audio or video source</h3>
<pre><code class="c++">FFMS_Track *FFMS_GetTrackFromVideo(FFMS_VideoSource *V);
FFMS_Track *FFMS_GetTrackFromAudio(FFMS_AudioSource *A);
</code></pre>

<p>Gets information about the track represented by the given <code>FFMS_VideoSource</code> or <code>FFMS_AudioSource</code> object and returns a pointer to a <code>FFMS_Track</code> object containing said information.
It's generally safer to use these functions instead of <a href="#ffms_gettrackfromindex-retrieves-track-info-from-an-index">FFMS_GetTrackFromIndex</a>, since unlike that function they cannot cause access violations if you specified an nonexistent tracknumber, return a <code>FFMS_Track</code> that doesn't actually contain any indexing information, or return an object that ceases to be valid when the index is destroyed.
Note that the returned <code>FFMS_Track</code> object is only valid until its parent <code>FFMS_VideoSource</code> or <code>FFMS_AudioSource</code> object is destroyed.</p>
<h3 id="ffms_gettimebase-retrieves-the-time-base-for-the-given-track">FFMS_GetTimeBase - retrieves the time base for the given track</h3>
<pre><code class="c++">const FFMS_TrackTimeBase *FFMS_GetTimeBase(FFMS_Track *T);
</code></pre>

<p>Finds the basic time unit for the track represented by the given <code>FFMS_Track</code>, stores it in a <a href="#ffms_tracktimebase">FFMS_TrackTimeBase</a> struct and returns a pointer to said struct.
Note that it is only meaningful for video tracks.</p>
<h3 id="ffms_writetimecodes-writes-timecodes-for-the-given-track-to-disk">FFMS_WriteTimecodes - writes timecodes for the given track to disk</h3>
<pre><code class="c++">int FFMS_WriteTimecodes(FFMS_Track *T, const char *TimecodeFile, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Writes Matroska v2 timecodes for the track represented by the given <code>FFMS_Track</code> to the given file.
Only meaningful for video tracks.</p>
<h4 id="arguments_10">Arguments</h4>
<h5 id="ffms_track-t_1"><code>FFMS_Track *T</code></h5>
<p>A pointer to the <code>FFMS_Track</code> object that represents the video track you want to write timecodes for.</p>
<h5 id="const-char-timecodefile"><code>const char *TimecodeFile</code></h5>
<p>The filename to write to.
Can be a relative or absolute path.
The file will be truncated and overwritten if it already exists.</p>
<h5 id="ffms_errorinfo-errorinfo_8"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_8">Return values</h4>
<p>Returns 0 on success.
Returns non-0 and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_defaultaudiofilename-default-callback-for-audio-filename-generation">FFMS_DefaultAudioFilename - default callback for audio filename generation</h3>
<p>This function generates a default audio filename for use when dumping audio tracks to disk as Wave64 files during indexing.
Its only use in the public API is as a default callback for <code>FFMS_MakeIndex</code> and <code>FFMS_DoIndexing</code>; you should never call it directly.
See <code>FFMS_MakeIndex</code> for a description of its arguments.</p>
<h3 id="ffms_createindexer-creates-an-indexer-object-for-the-given-file">FFMS_CreateIndexer - creates an indexer object for the given file</h3>
<pre><code class="c++">FFMS_Indexer *FFMS_CreateIndexer(const char *SourceFile, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Creates a <code>FFMS_Indexer</code> object for the given <code>SourceFile</code> and returns a pointer to it.
See <a href="#indexing-and-you">Indexing and You</a> for details on how to use the indexer.
Is basically a shorthand for <code>FFMS_CreateIndexerWithDemuxer(SourceFile, FFMS_SOURCE_DEFAULT, ErrorInfo)</code>.</p>
<h4 id="return-values_9">Return values</h4>
<p>Returns a pointer to the <code>FFMS_Indexer</code> on success.
Returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_createindexerwithdemuxer-creates-an-indexer-object-for-the-given-file-using-the-given-source-module">FFMS_CreateIndexerWithDemuxer - creates an indexer object for the given file, using the given source module</h3>
<pre><code class="c++">FFMS_Indexer *FFMS_CreateIndexerWithDemuxer(const char *SourceFile, int Demuxer, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Creates a <code>FFMS_Indexer</code> object for the given <code>SourceFile</code> using the given <code>Demuxer</code> (as enumerated in <a href="#ffms_sources">FFMS_Sources</a>) and returns a pointer to it.
See <a href="#indexing-and-you">Indexing and You</a> for details on how to use the indexer.</p>
<p>The chosen demuxer gets used for both indexing and decoding later on.
Only force one if you know what you're doing.
Picking a demuxer that doesn't work on your file will not cause automatic fallback on lavf or automatic probing; it'll just cause indexer creation to fail.</p>
<h4 id="return-values_10">Return values</h4>
<p>Returns a pointer to the <code>FFMS_Indexer</code> on success.
Returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_doindexing2-indexes-the-file-represented-by-an-indexer-object">FFMS_DoIndexing2 - indexes the file represented by an indexer object</h3>
<pre><code class="c++">FFMS_Index *FFMS_DoIndexing2(FFMS_Indexer *Indexer, int ErrorHandling, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Runs the passed indexer and returns a <code>FFMS_Index</code> object representing the file in question.
See the Indexing and You section for more details about indexing.
Note that calling this function destroys the <code>FFMS_Indexer</code> object and frees the memory allocated by <a href="#ffms_createindexer-creates-an-indexer-object-for-the-given-file">FFMS_CreateIndexer</a> (even if indexing fails for any reason).</p>
<h4 id="arguments_11">Arguments</h4>
<h5 id="ffms_indexer-indexer"><code>FFMS_Indexer *Indexer</code></h5>
<p>The Indexer to run.
Created with <a href="#ffms_createindexer-creates-an-indexer-object-for-the-given-file">FFMS_CreateIndexer</a> and configured with <a href="#ffms_trackindexsettings-enable-or-disable-indexing-of-a-track">FFMS_TrackIndexSettings</a>, <a href="#ffms_tracktypeindexsettings-enable-or-disable-indexing-of-a-tracks-of-a-given-type">FFMS_TrackTypeIndexSettings</a>, <a href="#ffms_setaudionamecallback-choose-the-filename-for-audio-track-dumping">FFMS_SetAudioNameCallback</a> and <a href="#ffms_setprogresscallback-set-callback-function-for-indexing-progress-updates">FFMS_SetProgressCallback</a>.</p>
<h5 id="int-errorhandling"><code>int ErrorHandling</code></h5>
<p>Depending on the setting audio decoding errors will have different results.
See <a href="#ffms_indexerrorhandling">FFMS_IndexErrorHandling</a> for valid values.
FFMS_IEH_STOP_TRACK should be the best default to just make it work.
Has no effect for tracks which have dumping enabled, which will always cause indexing to fail on audio decoding errors.</p>
<h5 id="ffms_errorinfo-errorinfo_9"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="return-values_11">Return values</h4>
<p>Returns a pointer to the created <code>FFMS_Index</code> on success.
Returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_trackindexsettings-enable-or-disable-indexing-of-a-track">FFMS_TrackIndexSettings - enable or disable indexing of a track</h3>
<pre><code class="c++">void FFMS_TrackIndexSettings(FFMS_Indexer *Indexer, int Track, int Index, int Dump);
</code></pre>

<p>Enable or disable indexing of a track, and for audio tracks, enable or disable dumping the decoded audio during indexing.</p>
<h4 id="arguments_12">Arguments</h4>
<h5 id="ffms_indexer-indexer_1"><code>FFMS_Indexer *Indexer</code></h5>
<p>The indexer to configure.</p>
<h5 id="int-track_2"><code>int Track</code></h5>
<p>The track index to configure.</p>
<h5 id="int-index"><code>int Index</code></h5>
<p>Enable indexing the given track if non-zero, and disable if zero.
By default, all video tracks are indexed and all audio tracks are not.</p>
<h5 id="int-dump"><code>int Dump</code></h5>
<p>If non-zero, the audio decoded during indexing the given track will be dumped to a file.
Use <a href="#ffms_setaudionamecallback-choose-the-filename-for-audio-track-dumping">FFMS_SetAudioNameCallback</a> to choose what file it will be written to.
Does not have any effect if the track is not an audio track or if the track is not being indexed.</p>
<p>By default, no tracks are dumped.</p>
<h3 id="ffms_tracktypeindexsettings-enable-or-disable-indexing-of-a-tracks-of-a-given-type">FFMS_TrackTypeIndexSettings - enable or disable indexing of a tracks of a given type</h3>
<pre><code class="c++">void FFMS_TrackTypeIndexSettings(FFMS_Indexer *Indexer, int TrackType, int Index, int Dump);
</code></pre>

<p>Like <a href="#ffms_trackindexsettings-enable-or-disable-indexing-of-a-track">FFMS_TrackIndexSettings</a>, but configures all tracks of the given <a href="#ffms_tracktype">FFMS_TrackType</a> at once.</p>
<h3 id="ffms_setaudionamecallback-choose-the-filename-for-audio-track-dumping">FFMS_SetAudioNameCallback - choose the filename for audio track dumping</h3>
<pre><code class="c++">void FFMS_SetAudioNameCallback(FFMS_Indexer *Indexer, TAudioNameCallback ANC, void *ANCPrivate);
</code></pre>

<p>When you ask for an audio track to be dumped with <a href="#ffms_trackindexsettings-enable-or-disable-indexing-of-a-track">FFMS_TrackIndexSettings</a> or <a href="#ffms_tracktypeindexsettings-enable-or-disable-indexing-of-a-tracks-of-a-given-type">FFMS_TrackTypeIndexSettings</a>, FFMS2 calls the function set by this for each track to find out what filename it should write to.
To get the default filename(s), pass <code>&amp;FFMS_DefaultAudioFilename</code>.
If you are not dumping any audio tracks, you do not need to call this function.</p>
<p>The callback function should have the following signature:</p>
<pre><code class="c++">int FFMS_CC FunctionName(const char *SourceFile, int Track, const FFMS_AudioProperties *AP,
  char *FileName, int FNSize, void *Private);
</code></pre>

<p>The callback function is called twice for each audio file generated.
The first time <code>FileName</code> is <code>NULL</code>, and you should return the number of characters your generated filename will use plus one, and do nothing else.
The second time <code>FileName</code> is a pointer to a pre-allocated array of char; you should write your generated filename to that and return the number of characters actually written plus one.
Generally the easiest way to do this in both cases is to use <code>snprintf</code>.
See the implementation of <code>GenAudioFilename</code> in ffmsindex.cpp for an example on how to do it.</p>
<p>The callback function's arguments are as follows:
 - <code>const char *SourceFile</code> - The name of the source media file.
 - <code>int Track</code> - The track number of the audio track being dumped.
 - <code>const FFMS_AudioProperties *AP</code> - A pointer to the <a href="#ffms_audioproperties">FFMS_AudioProperties</a> struct containing information about the audio track being dumped.
   Note that the <code>LastTime</code> field is not defined since the last timestamp has not yet been encountered during indexing.
 - <code>char *FileName</code> - A pointer to the string to which the callback function should write the generated filename (see above).
 - <code>int FNSize</code> - The length of the <code>FileName</code> string.
 - <code>void *Private</code> - The <code>ANCPrivate</code> pointer passed to <code>FFMS_SetAudioNameCallback</code>.
   Can be used to store data between calls, or to give audio tracks individual names that aren't just based on their properties.</p>
<p>Most of the parameters may seem pointless since you don't need to use them, but they are passed so that you can easily generate a filename based on the audio track's properties if you want to.</p>
<h3 id="ffms_setprogresscallback-set-callback-function-for-indexing-progress-updates">FFMS_SetProgressCallback - set callback function for indexing progress updates</h3>
<pre><code class="c++">void FFMS_SetProgressCallback(FFMS_Indexer *Indexer, TIndexCallback IC, void *ICPrivate);
</code></pre>

<p>If you supply a progress callback, FFMS2 will call it regularly during indexing to report progress and give you the chance to interrupt indexing.</p>
<p>The callback should have the following signature:</p>
<pre><code class="c++">int FFMS_CC FunctionName(int64_t Current, int64_t Total, void *ICPrivate);
</code></pre>

<p>The callback function's arguments are as follows:
 - <code>int64_t Current, int64_t Total</code> - The indexing progress (amount done/total amount).
 - <code>void *Private</code> - the same pointer as the one you passed as the <code>Private</code> argument to <code>FFMS_SetProgressCallback</code>.
   Can be used for anything you like, but one example (in a GUI program) is to use it for passing a progress ticker object that you can update with each call to the indexing function.</p>
<p>Return 0 from the callback function to continue indexing, non-0 to cancel indexing (returning non-0 will make <code>FFMS_DoIndexing2</code> fail with the reason "indexing cancelled by user").</p>
<h3 id="ffms_cancelindexing-destroys-the-given-indexer-object">FFMS_CancelIndexing - destroys the given indexer object</h3>
<pre><code class="c++">void FFMS_CancelIndexing(FFMS_Indexer *Indexer);
</code></pre>

<p>Destroys the given <code>FFMS_Indexer</code> object and frees the memory allocated by <a href="#ffms_createindexer-creates-an-indexer-object-for-the-given-file">FFMS_CreateIndexer</a>.</p>
<h3 id="ffms_readindex-reads-an-index-file-from-disk">FFMS_ReadIndex - reads an index file from disk</h3>
<pre><code class="c++">FFMS_Index *FFMS_ReadIndex(const char *IndexFile, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Attempts to read indexing information from the given <code>IndexFile</code>, which can be an absolute or relative path.
Returns the <code>FFMS_Index</code> on success; returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_indexbelongstofile-check-if-a-given-index-belongs-to-a-given-file">FFMS_IndexBelongsToFile - check if a given index belongs to a given file</h3>
<pre><code class="c++">int FFMS_IndexBelongsToFile(FFMS_Index *Index, const char *SourceFile, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Makes a heuristic (but very reliable) guess about whether the given <code>FFMS_Index</code> is an index of the given <code>SourceFile</code> or not.
Useful to determine if the index object you just read with <a href="#ffms_readindex-reads-an-index-file-from-disk">FFMS_ReadIndex</a> is actually relevant to your interests, since the only two ways to pair up index files with source files are a) trust the user blindly, or b) comparing the filenames; neither is very reliable.</p>
<h4 id="arguments_13">Arguments</h4>
<h5 id="ffms_index-index_3"><code>FFMS_Index *Index</code></h5>
<p>The index object to check.</p>
<h5 id="const-char-sourcefile_1"><code>const char *SourceFile</code></h5>
<p>The source file to verify the index against.</p>
<h4 id="return-values_12">Return values</h4>
<p>Returns 0 if the given index is determined to belong to the given file.
Returns non-0 and sets <code>ErrorMsg</code> otherwise.</p>
<h3 id="ffms_writeindex-writes-an-index-object-to-disk">FFMS_WriteIndex - writes an index object to disk</h3>
<pre><code class="c++">int FFMS_WriteIndex(const char *IndexFile, FFMS_Index *TrackIndices, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Writes the indexing information from the given <code>FFMS_Index</code> to the given <code>IndexFile</code> (which can be an absolute or relative path; it will be truncated and overwritten if it already exists).
Returns 0 on success; returns non-0 and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_getpixfmt-gets-a-colorspace-identifier-from-a-colorspace-name">FFMS_GetPixFmt - gets a colorspace identifier from a colorspace name</h3>
<pre><code class="c++">int FFMS_GetPixFmt(const char *Name);
</code></pre>

<p>Translates a given colorspace/pixel format <code>Name</code> to an integer constant representing it, suitable for passing to <a href="#ffms_setoutputformatv2-sets-the-output-format-for-video-frames">FFMS_SetOutputFormatV2</a> (after some manipulation, see that function for details).
This function exists so that you don't have to include a FFmpeg header file in every single program you ever write.
For a list of colorspaces and their names, see <code>libavutil/pixfmt.h</code>.
To get the name of a colorspace, strip the leading <code>PIX_FMT_</code> and convert the remainder to lowercase.
For example, the name of <code>PIX_FMT_YUV420P</code> is <code>yuv420p</code>.
It is strongly recommended to use this function instead of including pixfmt.h directly, since this function guarantees that you will always get the constant definitions from the version of FFmpeg that FFMS2 was linked against.</p>
<h4 id="arguments_14">Arguments</h4>
<h5 id="const-char-name"><code>const char *Name</code></h5>
<p>The name of the desired colorspace/pixel format, as a nul-terminated ASCII string.</p>
<h4 id="return-values_13">Return values</h4>
<p>Returns the integer constant representing the given colorspace/pixel format on success.
Returns the integer constant representing <code>PIX_FMT_NONE</code> (that is, -1) on failure (i.e. if no matching colorspace was found), but note that you can call <code>FFMS_GetPixFmt("none")</code> and get the same return value without it being a failed call, strictly speaking.</p>
<h3 id="ffms_getpresentsources-checks-what-source-modules-the-library-was-compiled-with">FFMS_GetPresentSources - checks what source modules the library was compiled with</h3>
<pre><code class="c++">int FFMS_GetPresentSources();
</code></pre>

<p>Checks which source modules the library was compiled with and returns an integer by binary OR'ing the relevant constants from <a href="#ffms_sources">FFMS_Sources</a> together.</p>
<h3 id="ffms_getenabledsources-checks-what-source-modules-are-actually-available-for-use">FFMS_GetEnabledSources - checks what source modules are actually available for use</h3>
<pre><code class="c++">int FFMS_GetEnabledSources();
</code></pre>

<p>Does the same thing as <a href="#ffms_getpresentsources-checks-what-source-modules-the-library-was-compiled-with">FFMS_GetPresentSources</a> but checks what source modules are actually available for use instead of which ones are compiled in.</p>
<h3 id="ffms_getversion-returns-ffms_version-constant">FFMS_GetVersion - returns FFMS_VERSION constant</h3>
<pre><code class="c++">int FFMS_GetVersion();
</code></pre>

<p>Returns the FFMS_VERSION constant as defined in ffms.h as an integer.</p>
<h3 id="ffms_makeindex-indexes-a-given-source-file-deprecated">FFMS_MakeIndex - indexes a given source file [DEPRECATED]</h3>
<pre><code class="c++">FFMS_Index *FFMS_MakeIndex(const char *SourceFile, int IndexMask, int DumpMask,
    TAudioNameCallback ANC, void *ANCPrivate, int ErrorHandling,
    TIndexCallback IC, void *ICPrivate, FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Indexes all video tracks and the given audio tracks in the given media file and returns a <code>FFMS_Index</code> object representing the file in question.
Can also decode and write audio tracks to Wave64 files on disk while indexing.</p>
<p>This function is deprecated and does not support configuring all indexing options.
New code should instead use <a href="#ffms_createindexer-creates-an-indexer-object-for-the-given-file">FFMS_CreateIndexer</a> and <a href="#ffms_doindexing2-indexes-the-file-represented-by-an-indexer-object">FFMS_DoIndexing2</a>.</p>
<h4 id="arguments_15">Arguments</h4>
<h5 id="const-char-sourcefile_2"><code>const char *SourceFile</code></h5>
<p>The filename of the media file to index.
Can be a relative or absolute path.</p>
<h5 id="int-indexmask-int-dumpmask"><code>int IndexMask, int DumpMask</code></h5>
<p>Binary masks of the track numbers of the audio tracks to index and decode to disk, respectively.
Pass 0 to index/decode no audio tracks, or -1 to index/decode all.
Decoding a track means it will automatically be indexed regardless of what the <code>IndexMask</code> says, but indexing a track does not automatically mean that it will be decoded.</p>
<h5 id="taudionamecallback-anc"><code>TAudioNameCallback ANC</code></h5>
<p>A function pointer to a callback function that will generate the filename(s) for the dumped audio tracks.
To get the default filename(s), pass <code>&amp;FFMS_DefaultAudioFilename</code>.
See <a href="#MakeIndex_Callbacks">Callbacks</a> below for details if you want to write your own function.
If the <code>DumpMask</code> is 0, you may pass <code>NULL</code> here.</p>
<h5 id="void-ancprivate"><code>void *ANCPrivate</code></h5>
<p>A pointer of your choice that will be passed as an argument to the audio filename generation callback function.
See <a href="#MakeIndex_Callbacks">Callbacks</a> below for details.
If <code>DumpMask</code> is 0, you may pass <code>NULL</code> here.
If you are using <code>FFMS_DefaultAudioFilename</code>, you must pass a format string here.
See the <a href="#audio-filename-format-strings">Audio Filename Format Strings section</a> for details.</p>
<h5 id="int-errorhandling_1"><code>int ErrorHandling</code></h5>
<p>Depending on the setting audio decoding errors will have different results.
See <a href="#ffms_indexerrorhandling">FFMS_IndexErrorHandling</a> for valid values.
FFMS_IEH_STOP_TRACK should be the best default to just make it work.
Has no effect if the <code>DumpMask</code> is non-zero, in which case audio decoding errors will always cause the indexing to fail.</p>
<h5 id="tindexcallback-ic"><code>TIndexCallback IC</code></h5>
<p>A function pointer to a callback function that can be used to update progress.
See <em>Callbacks</em> below for details.</p>
<h5 id="void-icprivate"><code>void *ICPrivate</code></h5>
<p>A pointer of your choice that will be passed as an argument to the progress reporting callback function.
See <em>Callbacks</em> below for details.</p>
<h5 id="ffms_errorinfo-errorinfo_10"><code>FFMS_ErrorInfo *ErrorInfo</code></h5>
<p>See <a href="#function-reference">Error handling</a>.</p>
<h4 id="callbacks">Callbacks</h4>
<p><a id="MakeIndex_Callbacks"/></p>
<p>This function has two potential callbacks.
One can, if you so desire, call your code back intermittently so you can see how the indexing is progressing.
This is accomplished using a function pointer to a function with the following signature:</p>
<pre><code class="c++">int FFMS_CC FunctionName(int64_t Current, int64_t Total, void *ICPrivate);
</code></pre>

<p>The callback function's arguments are as follows:
 - <code>int64_t Current, int64_t Total</code> - The indexing progress (amount done/total amount).
 - <code>void *Private</code> - the same pointer as the one you passed as the <code>Private</code> argument to <code>FFMS_MakeIndex</code>.
   Can be used for anything you like, but one example (in a GUI program) is to use it for passing a progress ticker object that you can update with each call to the indexing function.</p>
<p>Return 0 from the callback function to continue indexing, non-0 to cancel indexing (returning non-0 will make <code>FFMS_MakeIndex</code> fail with the reason "indexing cancelled by user").</p>
<p>The other callback is used to generate the filename(s) of the audio file(s) written if <code>DumpMask</code> is non-zero.
It has the following signature:</p>
<pre><code class="c++">int FFMS_CC FunctionName(const char *SourceFile, int Track, const FFMS_AudioProperties *AP,
  char *FileName, int FNSize, void *Private);
</code></pre>

<p>The callback function is called twice for each audio file generated.
The first time <code>FileName</code> is <code>NULL</code>, and you should return the number of characters your generated filename will use plus one, and do nothing else.
The second time <code>FileName</code> is a pointer to a pre-allocated array of char; you should write your generated filename to that and return the number of characters actually written plus one.
Generally the easiest way to do this in both cases is to use <code>snprintf</code>.
See the implementation of <code>GenAudioFilename</code> in ffmsindex.cpp for an example on how to do it.</p>
<p>The callback function's arguments are as follows:
 - <code>const char *SourceFile</code> - The name of the source media file.
 - <code>int Track</code> - The track number of the audio track being dumped.
 - <code>const FFMS_AudioProperties *AP</code> - A pointer to the <a href="#ffms_audioproperties">FFMS_AudioProperties</a> struct containing information about the audio track being dumped.
   Note that the <code>LastTime</code> field is not defined since the last timestamp has not yet been encountered during indexing.
 - <code>char *FileName</code> - A pointer to the string to which the callback function should write the generated filename (see above).
 - <code>int FNSize</code> - The length of the <code>FileName</code> string.
 - <code>void *Private</code> - The <code>ANCPrivate</code> pointer passed to <code>FFMS_MakeIndex</code>.
   Can be used to store data between calls, or to give audio tracks individual names that aren't just based on their properties.</p>
<p>Most of the parameters may seem pointless since you don't need to use them, but they are passed so that you can easily generate a filename based on the audio track's properties if you want to.</p>
<h4 id="return-values_14">Return values</h4>
<p>Returns a pointer to the created <code>FFMS_Index</code> on success.
Returns <code>NULL</code> and sets <code>ErrorMsg</code> on failure.</p>
<h3 id="ffms_doindexing-indexes-the-file-represented-by-an-indexer-object-deprecated">FFMS_DoIndexing - indexes the file represented by an indexer object [DEPRECATED]</h3>
<pre><code class="c++">FFMS_Index *FFMS_DoIndexing(FFMS_Indexer *Indexer, int IndexMask, int DumpMask,
  TAudioNameCallback ANC, void *ANCPrivate, int ErrorHandling, TIndexCallback IC, void *ICPrivate,
  FFMS_ErrorInfo *ErrorInfo);
</code></pre>

<p>Does the exact same thing as <a href="#ffms_makeindex-indexes-a-given-source-file">FFMS_MakeIndex</a>, but takes an indexer object instead of a source filename.
Return values and arguments are identical to <a href="#ffms_makeindex-indexes-a-given-source-file">FFMS_MakeIndex</a>; see that function for details.
See the Indexing and You section for more details about indexing.
Note that calling this function destroys the <code>FFMS_Indexer</code> object and frees the memory allocated by <a href="#ffms_createindexer-creates-an-indexer-object-for-the-given-file">FFMS_CreateIndexer</a> (even if indexing fails for any reason).</p>
<p>This function is deprecated; new code should use <a href="#ffms_doindexing2-indexes-the-file-represented-by-an-indexer-object">FFMS_DoIndexing2</a>.</p>
<h2 id="data-structures">Data Structures</h2>
<p>The following public data structures may be of interest.</p>
<h3 id="ffms_frame">FFMS_Frame</h3>
<pre><code class="c++">typedef struct {
  uint8_t *Data[4];
  int Linesize[4];
  int EncodedWidth;
  int EncodedHeight;
  int EncodedPixelFormat;
  int ScaledWidth;
  int ScaledHeight;
  int ConvertedPixelFormat;
  int KeyFrame;
  int RepeatPict;
  int InterlacedFrame;
  int TopFieldFirst;
  char PictType;
  int ColorSpace;
  int ColorRange;
} FFMS_Frame;
</code></pre>

<p>A struct representing a video frame.
The fields are:
 - <code>uint8_t *Data[4]</code> - An array of pointers to the picture planes (fields containing actual pixel data).
   Planar formats use more than one plane, for example YV12 uses one plane each for the Y, U and V data.
   Packed formats (such as the various RGB32 flavors) use only the first plane.
   If you want to determine if plane <code>i</code> contains data or not, check for <code>FFMS_Frame-&gt;Linesize[i] != 0</code>.
 - <code>int Linesize[4]</code> - An array of integers representing the length of each scan line in each of the four picture planes, in bytes.
   In alternative terminology, this is the "pitch" of the plane.
   Usually, the total size in bytes of picture plane <code>i</code> is <code>FFMS_Frame-&gt;Linesize[i] * FFMS_VideoProperties-&gt;Height</code>, but do note that some pixel formats (most notably YV12) has vertical chroma subsampling, and then the U/V planes may be of a different height than the primary plane.
   This may be negative; if so the image is stored inverted in memory and <code>Data</code> actually points of the last row of the data.
   You usually do not need to worry about this, as it mostly works correctly by default if you're processing the image correctly.
 - <code>int EncodedWidth; int EncodedHeight</code> - The original resolution of the frame (in pixels), as encoded in the compressed file, before any scaling was applied.
   Note that must not necessarily be the same for all frames in a stream.
 - <code>int EncodedPixelFormat</code> - The original pixel format of the frame, as encoded in the compressed file.
 - <code>int ScaledWidth; int ScaledHeight;</code> - The output resolution of the frame (in pixels), i.e. the resolution of what is actually stored in the <code>Data</code> field.
   Same as <code>FFMS_VideoProperties-&gt;Width/Height</code>, but unlike that struct, this one gets updated automatically when you call <a href="#ffms_getframe-retrieves-a-given-video-frame">FFMS_GetFrame</a>, so you don't have to call <a href="#ffms_getvideoproperties-retrieves-video-properties">FFMS_GetVideoProperties</a> all the time to see if someone changed the output format while you weren't looking.
 - <code>int ConvertedPixelFormat</code> - The output pixel format of the frame, i.e. the pixel format of what is actually stored in the <code>Data</code> field.
 - <code>int KeyFrame</code> - Nonzero if the frame is a keyframe, 0 otherwise.
 - <code>int RepeatPict</code> - An integer repesenting the RFF flag for this frame; i.e. the frame shall be displayed for <code>1+RepeatPict</code> time units, where the time units are expressed in the special RFF timebase available in <code>FFMS_VideoProperties-&gt;RFFDenominator</code> and <code>FFMS_VideoProperties-&gt;RFFNumerator</code>.
   Note that if you actually end up using this, you need to ignore the usual timestamps (calculated via the <code>FFMS_TrackTimeBase</code> and the frame PTS) since they are fundamentally incompatible with RFF flags.
 - <code>int InterlacedFrame</code> - Nonzero if the frame was coded as interlaced, zero otherwise.
 - <code>int TopFieldFirst</code> - Nonzero if the frame has the top field first, zero if it has the bottom field first.
   Only relevant if <code>InterlacedFrame</code> is nonzero.
 - <code>char PictType</code> - A single character denoting coding type (I/B/P etc) of the compressed frame.
   See the Constants and Preprocessor Definitions section for more information about what the different letters mean.
 - <code>int ColorSpace</code> - Identifies the YUV color coefficients used in the frame.
   Same as in the MPEG-2 specs; see the <a href="#ffms_colorspaces">FFMS_ColorSpaces</a> enum.
 - <code>int ColorRange</code> - Identifies the luma range of the frame.
   See the <a href="#ffms_colorranges">FFMS_ColorRanges</a> enum.</p>
<h3 id="ffms_tracktimebase">FFMS_TrackTimeBase</h3>
<pre><code class="c++">typedef struct {
  int64_t Num;
  int64_t Den;
} FFMS_TrackTimeBase;
</code></pre>

<p>A struct representing the basic time unit of a track, as a rational number where <code>Num</code> is the numerator and <code>Den</code> is the denominator.
Note that while this rational number may occasionally turn out to be equal to 1/framerate for some CFR video tracks, it really has no relation whatsoever with the video framerate and you should definitely not assume anything framerate-related based on it.</p>
<h3 id="ffms_frameinfo">FFMS_FrameInfo</h3>
<pre><code class="c++">typedef struct {
    int64_t PTS;
    int RepeatPict;
    int KeyFrame;
} FFMS_FrameInfo;
</code></pre>

<p>A struct representing basic metadata about a given video frame.
The fields are:
 - <code>int64_t PTS</code> - The decoding timestamp of the frame.
   To convert this to a timestamp in wallclock milliseconds, use the relation <code>int64_t timestamp = (int64_t)((FFMS_FrameInfo-&gt;PTS * FFMS_TrackTimeBase-&gt;Num) / (double)FFMS_TrackTimeBase-&gt;Den)</code>.
 - <code>int RepeatPict</code> - RFF flag for the frame; same as in <code>FFMS_Frame</code>, see that structure for an explanation.
 - <code>int KeyFrame</code> - Non-zero if the frame is a keyframe, zero otherwise.</p>
<h3 id="ffms_videoproperties">FFMS_VideoProperties</h3>
<pre><code class="c++">typedef struct {
  int FPSDenominator;
  int FPSNumerator;
  int RFFDenominator;
  int RFFNumerator;
  int NumFrames;
  int SARNum;
  int SARDen;
  int CropTop;
  int CropBottom;
  int CropLeft;
  int CropRight;
  int TopFieldFirst;
  int ColorSpace; // [DEPRECATED]
  int ColorRange; // [DEPRECATED]
  double FirstTime;
  double LastTime;
} FFMS_VideoProperties;
</code></pre>

<p>A struct containing metadata about a video track.
The fields are:
 - <code>int FPSDenominator; int FPSNumerator;</code> - The nominal framerate of the track, as a rational number.
   For Matroska files, this number is based on the average frame duration of all frames, while for everything else it's based on the duration of the first frame.
   While it might seem tempting to use these values to extrapolate wallclock timestamps for each frame, you really shouldn't do that since it makes your code unable to handle variable framerate properly.
   The ugly reality is that these values are pretty much only useful for informational purposes; they are only somewhat reliable for antiquated containers like AVI.
   Normally they should never be used for practical purposes; generate individual frame timestamps from <code>FFMS_FrameInfo-&gt;PTS</code> instead.
 - <code>int RFFDenominator; int RFFNumerator;</code> - The special RFF timebase, as a rational number.
   See <code>RepeatPict</code> in the <code>FFMS_Frame</code> documentation for more information.
 - <code>int NumFrames;</code> - The number of frames in the video track.
 - <code>int SARNum; int SARDen;</code> - The sample aspect ratio of the video frames, as a rational number where <code>SARNum</code> is the numerator and <code>SARDen</code> is the denominator.
   Note that this is a metadata setting that you are free to ignore, but if you want the proper display aspect ratio with anamorphic material, you should honor it.
   On the other hand, there are situations (like when encoding) where you should probably ignore it because the user expects it to be ignored.
 - <code>int CropTop; int CropBottom; int CropLeft; int CropRight;</code> - The number of pixels in each direction you should crop the frame before displaying it.
   Note that like the SAR, this is a metadata setting and you are free to ignore it, but if you want things to display 100% correctly you should honor it.
 - <code>int TopFieldFirst</code> - Nonzero if the stream has the top field first, zero if it has the bottom field first.
 - <code>int ColorSpace</code> - Identifies the YUV color coefficients used in the stream.
   Same as in the MPEG-2 specs; see the <a href="#ffms_colorspaces">FFMS_ColorSpaces</a> enum.
   The ColorSpace property in FFMS_Frame should be instead of this, as this can vary between frames unless you've asked for everything to be converted to a single value with <code>FFMS_SetOutputFormatV2</code>.
 - <code>int ColorRange</code> - Identifies the luma range of the stream.
   See the <a href="#ffms_colorranges">FFMS_ColorRanges</a> enum.
   The ColorRange property in FFMS_Frame should be instead of this, as this can vary between frames unless you've asked for everything to be converted to a single value with <code>FFMS_SetOutputFormatV2</code>.
 - <code>double FirstTime; double LastTime;</code> - The first and last timestamp of the stream respectively, in seconds.
   Useful if you want to know if the stream has a delay, or for quickly determining its length in seconds.</p>
<h3 id="ffms_audioproperties">FFMS_AudioProperties</h3>
<pre><code class="c++">typedef struct {
  int SampleFormat;
  int SampleRate;
  int BitsPerSample;
  int Channels;
  int64_t ChannelLayout;
  int64_t NumSamples;
  double FirstTime;
  double LastTime;
} FFMS_AudioProperties;
</code></pre>

<p>A struct containing metadata about an audio track.
The fields are:
 - <code>int SampleFormat</code> - An integer that represents the audio sample format.
    See <a href="#ffms_sampleformat">FFMS_SampleFormat</a>.
 - <code>int SampleRate</code> - The audio samplerate, in samples per second.
 - <code>int BitsPerSample</code> - The number of bits per audio sample.
   Note that this signifies the number of bits actually used to <em>code</em> each sample, not the number of bits used to <em>store</em> each sample, and may hence be different from what the <code>SampleFormat</code> would imply.
   Figuring out which bytes are significant and which aren't is left as an exercise for the reader.
 - <code>int Channels</code> - The number of audio channels.
 - <code>int64_t ChannelLayout</code> - The channel layout of the audio stream.
   Constructed by binary OR'ing the relevant integers from <code>FFMS_AudioChannel</code> together, which means that if the audio has the channel <code>FFMS_CH_EXAMPLE</code>, the operation <code>(ChannelOrder &amp; FFMS_CH_EXAMPLE)</code> will evaluate to true.
   The samples are interleaved in the order the channels are listed in the <a href="#ffms_audiochannel">FFMS_AudioChannel</a> enum.
 - <code>int64_t NumSamples</code> - The number of samples in the audio track.
 - <code>double FirstTime; double LastTime;</code> - The first and last timestamp of the stream respectively, in milliseconds.
   Useful if you want to know if the stream has a delay, or for quickly determining its length in seconds.</p>
<h2 id="constants-and-preprocessor-definitions">Constants and Preprocessor Definitions</h2>
<p>The following constants and preprocessor definititions defined in ffms.h are suitable for public usage.</p>
<h3 id="ffms_errors">FFMS_Errors</h3>
<pre><code class="c++">enum FFMS_Errors {
  // No error
  FFMS_ERROR_SUCCESS = 0,

  // Main types - where the error occurred
  FFMS_ERROR_INDEX = 1,           // index file handling
  FFMS_ERROR_INDEXING,            // indexing
  FFMS_ERROR_POSTPROCESSING,      // video postprocessing (libpostproc)
  FFMS_ERROR_SCALING,             // image scaling (libswscale)
  FFMS_ERROR_DECODING,            // audio/video decoding
  FFMS_ERROR_SEEKING,             // seeking
  FFMS_ERROR_PARSER,              // file parsing
  FFMS_ERROR_TRACK,               // track handling
  FFMS_ERROR_WAVE_WRITER,         // WAVE64 file writer
  FFMS_ERROR_CANCELLED,           // operation aborted

  // Subtypes - what caused the error
  FFMS_ERROR_UNKNOWN = 20,        // unknown error
  FFMS_ERROR_UNSUPPORTED,         // format or operation is not supported with this binary
  FFMS_ERROR_FILE_READ,           // cannot read from file
  FFMS_ERROR_FILE_WRITE,          // cannot write to file
  FFMS_ERROR_NO_FILE,             // no such file or directory
  FFMS_ERROR_VERSION,             // wrong version
  FFMS_ERROR_ALLOCATION_FAILED,   // out of memory
  FFMS_ERROR_INVALID_ARGUMENT,    // invalid or nonsensical argument
  FFMS_ERROR_CODEC,               // decoder error
  FFMS_ERROR_NOT_AVAILABLE,       // requested mode or operation unavailable in this binary
  FFMS_ERROR_FILE_MISMATCH,       // provided index does not match the file
  FFMS_ERROR_USER                 // problem exists between keyboard and chair
};
</code></pre>

<p>Used to identify errors. Should be self-explanatory.</p>
<h3 id="ffms_sources">FFMS_Sources</h3>
<pre><code class="c++">enum FFMS_Sources {
  FFMS_SOURCE_DEFAULT     = 0x00,
  FFMS_SOURCE_LAVF        = 0x01,
  FFMS_SOURCE_MATROSKA    = 0x02,
  FFMS_SOURCE_HAALIMPEG   = 0x04,
  FFMS_SOURCE_HAALIOGG    = 0x08
};
</code></pre>

<p>No longer used for anything interesting.
Pass <code>FFMS_SOURCE_DEFAULT</code> to functions which want a <code>FFMS_Sources</code> parameter.
This enumeration will go away at some point in the future.</p>
<h3 id="ffms_cpufeatures">FFMS_CPUFeatures</h3>
<pre><code class="c++">enum FFMS_CPUFeatures {
  FFMS_CPU_CAPS_MMX       = 0x01,
  FFMS_CPU_CAPS_MMX2      = 0x02,
  FFMS_CPU_CAPS_3DNOW     = 0x04,
  FFMS_CPU_CAPS_ALTIVEC   = 0x08,
  FFMS_CPU_CAPS_BFIN      = 0x10,
  FFMS_CPU_CAPS_SSE2      = 0x20
};
</code></pre>

<p>No longer used by anything in FFMS2.
This enumeration will go away at some point in the future.</p>
<h3 id="ffms_seekmode">FFMS_SeekMode</h3>
<pre><code class="c++">enum FFMS_SeekMode {
  FFMS_SEEK_LINEAR_NO_RW  = -1,
  FFMS_SEEK_LINEAR        = 0,
  FFMS_SEEK_NORMAL        = 1,
  FFMS_SEEK_UNSAFE        = 2,
  FFMS_SEEK_AGGRESSIVE    = 3
};
</code></pre>

<p>Used in <a href="#ffms_createvideosource-creates-a-video-source-object">FFMS_CreateVideoSource</a> to control the way seeking is handled.
Explanation of the values:
 - <code>FFMS_SEEK_LINEAR_NO_RW</code> - Linear access without rewind; i.e. will throw an error if each successive requested frame number isn't bigger than the last one.
   Only intended for opening images but might work on well with some obscure video format.
 - <code>FFMS_SEEK_LINEAR</code> - Linear access (i.e. if you request frame <code>n</code> without having requested frames 0 to <code>n-1</code> in order first, all frames from 0 to <code>n</code> will have to be decoded before <code>n</code> can be delivered).
   The definition of slow, but should make some formats "usable".
 - <code>FFMS_SEEK_NORMAL</code> - Safe normal.
   Bases seeking decisions on the keyframe positions reported by libavformat.
 - <code>FFMS_SEEK_UNSAFE</code> - Unsafe normal.
   Same as <code>FFMS_SEEK_NORMAL</code> but no error will be thrown if the exact destination has to be guessed.
 - <code>FFMS_SEEK_AGGRESSIVE</code> - Aggressive.
   Seeks in the forward direction even if no closer keyframe is known to exist.
   Only useful for testing and containers where libavformat doesn't report keyframes properly.</p>
<h3 id="ffms_indexerrorhandling">FFMS_IndexErrorHandling</h3>
<pre><code class="c++">enum FFMS_IndexErrorHandling {
  FFMS_IEH_ABORT = 0,
  FFMS_IEH_CLEAR_TRACK = 1,
  FFMS_IEH_STOP_TRACK = 2,
  FFMS_IEH_IGNORE = 3
};
</code></pre>

<p>Used by the indexing functions to control behavior when a decoding error is encountered.
 - <code>FFMS_IEH_ABORT</code> - abort indexing and raise an error
 - <code>FFMS_IEH_CLEAR_TRACK</code> - clear all indexing entries for the track (i.e. return a blank track)
 - <code>FFMS_IEH_STOP_TRACK</code> - stop indexing but keep previous indexing entries (i.e. return a track that stops where the error occurred)
 - <code>FFMS_IEH_IGNORE</code> - ignore the error and pretend it's raining</p>
<h3 id="ffms_tracktype">FFMS_TrackType</h3>
<pre><code class="c++">enum FFMS_TrackType {
  FFMS_TYPE_UNKNOWN = -1,
  FFMS_TYPE_VIDEO,
  FFMS_TYPE_AUDIO,
  FFMS_TYPE_DATA,
  FFMS_TYPE_SUBTITLE,
  FFMS_TYPE_ATTACHMENT
};
</code></pre>

<p>Used for determining the type of a given track. Note that there are currently no functions to handle any type of track other than <code>FFMS_TYPE_VIDEO</code> and <code>FFMS_TYPE_AUDIO</code>.
See <a href="#ffms_gettracktype-gets-the-track-type-of-a-given-track">FFMS_GetTrackType</a>, <a href="#ffms_getfirsttrackoftype-gets-the-track-number-of-the-first-track-of-a-given-type">FFMS_GetFirstTrackOfType</a> and their variants.</p>
<h3 id="ffms_sampleformat">FFMS_SampleFormat</h3>
<pre><code class="c++">enum FFMS_SampleFormat {
  FFMS_FMT_U8 = 0,
  FFMS_FMT_S16,
  FFMS_FMT_S32,
  FFMS_FMT_FLT,
  FFMS_FMT_DBL
};
</code></pre>

<p>Identifies various audio sample formats.</p>
<ul>
<li><code>FFMS_FMT_U8</code> - One 8-bit unsigned integer (<code>uint8_t</code>) per sample.</li>
<li><code>FFMS_FMT_S16</code> - One 16-bit signed integer (<code>int16_t</code>) per sample.</li>
<li><code>FFMS_FMT_S32</code> - One 32-bit signed integer (<code>int32_t</code>) per sample.</li>
<li><code>FFMS_FMT_FLT</code> - One 32-bit (single precision) floating point value (<code>float_t</code>) per sample.</li>
<li><code>FFMS_FMT_DBL</code> - One 64-bit (double precision) floating point value (<code>double_t</code>) per sample.</li>
</ul>
<h3 id="ffms_audiochannel">FFMS_AudioChannel</h3>
<pre><code class="c++">enum FFMS_AudioChannel {
  FFMS_CH_FRONT_LEFT              = 0x00000001,
  FFMS_CH_FRONT_RIGHT             = 0x00000002,
  FFMS_CH_FRONT_CENTER            = 0x00000004,
  FFMS_CH_LOW_FREQUENCY           = 0x00000008,
  FFMS_CH_BACK_LEFT               = 0x00000010,
  FFMS_CH_BACK_RIGHT              = 0x00000020,
  FFMS_CH_FRONT_LEFT_OF_CENTER    = 0x00000040,
  FFMS_CH_FRONT_RIGHT_OF_CENTER   = 0x00000080,
  FFMS_CH_BACK_CENTER             = 0x00000100,
  FFMS_CH_SIDE_LEFT               = 0x00000200,
  FFMS_CH_SIDE_RIGHT              = 0x00000400,
  FFMS_CH_TOP_CENTER              = 0x00000800,
  FFMS_CH_TOP_FRONT_LEFT          = 0x00001000,
  FFMS_CH_TOP_FRONT_CENTER        = 0x00002000,
  FFMS_CH_TOP_FRONT_RIGHT         = 0x00004000,
  FFMS_CH_TOP_BACK_LEFT           = 0x00008000,
  FFMS_CH_TOP_BACK_CENTER         = 0x00010000,
  FFMS_CH_TOP_BACK_RIGHT          = 0x00020000,
  FFMS_CH_STEREO_LEFT             = 0x20000000,
  FFMS_CH_STEREO_RIGHT            = 0x40000000
};
</code></pre>

<p>Describes the audio channel layout of an audio stream.
The names should be self-explanatory.</p>
<p>As you might have noticed, these constants are the same as the ones used for the <code>dwChannelMask</code> property of Microsoft's <code>WAVEFORMATEXTENSIBLE</code> struct; see <a href="http://msdn.microsoft.com/en-us/library/dd757714%28v=vs.85%29.aspx">its MSDN documentation page</a> for more information.
The exceptions to this convenient compatibility are <code>FFMS_CH_STEREO_LEFT</code> and <code>FFMS_CH_STEREO_RIGHT</code>, which are FFmpeg extensions.</p>
<h3 id="ffms_resizers">FFMS_Resizers</h3>
<pre><code class="c++">enum FFMS_Resizers {
  FFMS_RESIZER_FAST_BILINEAR  = 0x01,
  FFMS_RESIZER_BILINEAR       = 0x02,
  FFMS_RESIZER_BICUBIC        = 0x04,
  FFMS_RESIZER_X              = 0x08,
  FFMS_RESIZER_POINT          = 0x10,
  FFMS_RESIZER_AREA           = 0x20,
  FFMS_RESIZER_BICUBLIN       = 0x40,
  FFMS_RESIZER_GAUSS          = 0x80,
  FFMS_RESIZER_SINC           = 0x100,
  FFMS_RESIZER_LANCZOS        = 0x200,
  FFMS_RESIZER_SPLINE         = 0x400
};
</code></pre>

<p>Describes various image resizing algorithms, as used in the arguments to <a href="#ffms_setoutputformatv2-sets-the-output-format-for-video-frames">FFMS_SetOutputFormatV2</a>.
The names should be self-explanatory.</p>
<h3 id="ffms_audiodelaymodes">FFMS_AudioDelayModes</h3>
<pre><code class="c++">enum FFMS_AudioDelayModes {
  FFMS_DELAY_NO_SHIFT           = -3,
  FFMS_DELAY_TIME_ZERO          = -2,
  FFMS_DELAY_FIRST_VIDEO_TRACK  = -1
};
</code></pre>

<p>Describes the different audio delay handling modes.
See <a href="#ffms_createaudiosource-creates-an-audio-source-object">FFMS_CreateAudioSource</a> for a detailed explanation.</p>
<h3 id="ffms_colorspaces">FFMS_ColorSpaces</h3>
<pre><code class="c++">enum FFMS_ColorSpaces {
  FFMS_CS_RGB         = 0,
  FFMS_CS_BT709       = 1,
  FFMS_CS_UNSPECIFIED = 2,
  FFMS_CS_FCC         = 4,
  FFMS_CS_BT470BG     = 5,
  FFMS_CS_SMPTE170M   = 6,
  FFMS_CS_SMPTE240M   = 7,
  FFMS_CS_YCOCG       = 8,
  FFMS_CS_BT2020_NCL  = 9,
  FFMS_CS_BT2020_NC   = 10
};
</code></pre>

<p>Identifies the color coefficients used for a YUV stream.
The numerical constants are the same as in the MPEG-2 specification.</p>
<p>Some of these are specified or aliased in a number of places. Most importantly:</p>
<p>"BT709" (ITU-T Rec. 709) is equivalent to ITU-R BT1361, IEC 61966-2-4 xvYCC709 and SMPTE RP177 Annex B;</p>
<p>"BT470BG" (ITU-R BT. 470, also known as ITU-T Rec. 601) is equivalent to ITU-R BT601-6 625, ITU-R BT1358 625, ITU-R BT1700 625 PAL &amp; SECAM and IEC 61966-2-4 xvYCC601;</p>
<p>"SMPTE170M" (SMPTE standard 170 M) is functionally the same as BT470BG, and is furthermore equivalent to ITU-R BT601-6 525, ITU-R BT1358 525, and ITU-R BT1700 NTSC.</p>
<h3 id="ffms_colorranges">FFMS_ColorRanges</h3>
<pre><code class="c++">enum FFMS_ColorRanges {
  FFMS_CR_UNSPECIFIED = 0,
  FFMS_CR_MPEG        = 1,
  FFMS_CR_JPEG        = 2,
};
</code></pre>

<p>Identifies the valid range of luma values in a YUV stream.
<code>FFMS_CR_MPEG</code> is the standard "TV range" with head- and footroom.
That is, valid luma values range from 16 to 235 with 8-bit color.
<code>FFMS_CR_JPEG</code> is "full range"; all representable luma values are valid.</p>
<h3 id="ffms_cc">FFMS_CC</h3>
<pre><code class="c++">#ifdef _WIN32
#   define FFMS_CC __stdcall
#else
#   define FFMS_CC
#endif
</code></pre>

<p>The calling convention used by FFMS2 API functions and callbacks.
Defined to <code>__stdcall</code> if <code>_WIN32</code> is defined. Otherwise defined, but not used.</p>
<h3 id="picture-types">Picture types</h3>
<p>As stored in <code>FFMS_Frame-&gt;PictType</code>:</p>
<pre><code>I: Intra
P: Predicted
B: Bi-dir predicted
S: S(GMC)-VOP MPEG4
i: Switching Intra
p: Switching Predicted
b: FF_BI_TYPE (no good explanation available)
?: Unknown
</code></pre>

<h2 id="audio-filename-format-strings">Audio Filename Format Strings</h2>
<p>The following variables can be used:</p>
<ul>
<li><code>%sourcefile%</code> - same as the source file name, i.e. the file the audio is decoded from</li>
<li><code>%trackn%</code> - the track number</li>
<li><code>%trackzn%</code> - the track number zero padded to 2 digits</li>
<li><code>%samplerate%</code> - the audio sample rate</li>
<li><code>%channels%</code> - number of audio channels</li>
<li><code>%bps%</code> - bits per sample</li>
<li><code>%delay%</code> - delay, or more exactly the first timestamp encountered in the audio stream</li>
</ul>
<p>Example string: <code>%sourcefile%_track%trackzn%.w64</code></p>