Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleVideoSink.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 /** @example ExampleVideoSink.cpp
27  @relates VideoSink
28  @ingroup g_examples
29  @ingroup g_videosink
30  @brief Example for using the videosink class to write a ffmpeg encoded video
31  @author MIP
32 */
33 
34 #include <iostream>
35 #include <vector>
36 #include <string>
37 #include <VideoSink/VideoSink.hh>
38 #include <Utils/Param.hh>
39 
40 using namespace std;
41 using namespace BIAS;
42 
43 void Usage(){
44  cout<<"\n\nUsage: ExampleVideoSink imagelist.lst\n";
45  cout<<"imagelist.lst is a list containing one filename of in image in each row.\n\n";
46 
47 }
48 
49 int main(int argc, char* argv[])
50 {
51  VideoSink vs;
52  if(argc < 2){
53  Usage();
54  return -1;
55  }
56  std::vector<string> imageList;
57  if (Param::ParseListFile(argv[1], imageList) != 0){
58  BIASERR("Could not parse list file."<<argv[1]);
59  return -1;
60  }
61 
62  for (unsigned i = 0; i < imageList.size(); i++)
63  {
64  vs.AddImage(imageList[i]);
65  }
66  vs.SetOutputVideo("out.mpg");
67  vs.SetFPS(25);
68  vs.SetBPP(10);
69 
70  cout << "Encoding...\n";
71  if (!vs.Encode())
72  cout << "Error: " << vs.GetErrMsg() << endl;
73 
74  cout << "Done!" << endl;
75 }
76 
void SetFPS(float FPS)
Set the framerate for the video.
Definition: VideoSink.cpp:74
bool Encode()
Encode the video.
Definition: VideoSink.cpp:163
VideoSink for writing FFMPEG Videos from images.
Definition: VideoSink.hh:68
std::string GetErrMsg()
Return the last produced errormessage.
Definition: VideoSink.cpp:308
void SetBPP(double BPP)
Set the bits per pixel of the output video.
Definition: VideoSink.cpp:84
void SetOutputVideo(std::string Video)
Set the file where the video will be written to.
Definition: VideoSink.cpp:70
void AddImage(std::string Image)
Append an image to the end of the list.
Definition: VideoSink.cpp:61