AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Transcoder.cpp
Go to the documentation of this file.
1 #include "Transcoder.hpp"
2 
6 
7 #include <limits>
8 #include <algorithm>
9 
10 namespace avtranscoder
11 {
12 
14  : _outputFile(outputFile)
15  , _inputFiles()
16  , _streamTranscoders()
17  , _streamTranscodersAllocated()
18  , _profileLoader(true)
19  , _eProcessMethod(eProcessMethodLongest)
20  , _mainStreamIndex(0)
21  , _outputDuration(0)
22 {
23 }
24 
26 {
27  for(std::vector<InputFile*>::iterator it = _inputFiles.begin(); it != _inputFiles.end(); ++it)
28  {
29  delete(*it);
30  }
31  for(std::vector<StreamTranscoder*>::iterator it = _streamTranscodersAllocated.begin();
32  it != _streamTranscodersAllocated.end(); ++it)
33  {
34  delete(*it);
35  }
36 }
37 
38 void Transcoder::add(const std::string& filename)
39 {
40  const int streamIndex = -1;
41  const float offset = 0;
42  const InputFile* referenceFile = addInputFile(filename, streamIndex, offset);
43  const std::vector<avtranscoder::StreamProperties*>& inputStreams = referenceFile->getProperties().getStreamProperties();
44  for(size_t index = 0; index < inputStreams.size(); ++index)
45  {
46  const AVMediaType streamType = referenceFile->getProperties().getStreamPropertiesWithIndex(index).getStreamType();
47  // skip the stream if it is not video nor audio
48  if(streamType == AVMEDIA_TYPE_VIDEO || streamType == AVMEDIA_TYPE_AUDIO)
49  addRewrapStream(filename, index, offset);
50  }
51 }
52 
53 void Transcoder::add(const std::string& filename, const size_t streamIndex, const std::string& profileName,
54  const float offset)
55 {
56  // Re-wrap
57  if(profileName.length() == 0)
58  {
59  // Check filename
60  if(filename.length() == 0)
61  throw std::runtime_error("Can't re-wrap a stream without filename indicated");
62 
63  addRewrapStream(filename, streamIndex, offset);
64  }
65  // Transcode
66  else
67  {
68  const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile(profileName);
69  add(filename, streamIndex, transcodeProfile, offset);
70  }
71 }
72 
73 void Transcoder::add(const std::string& filename, const size_t streamIndex, const std::string& profileName, ICodec& codec,
74  const float offset)
75 {
76  // Re-wrap
77  if(profileName.length() == 0)
78  {
79  // Check filename
80  if(filename.length() == 0)
81  throw std::runtime_error("Can't re-wrap a stream without filename indicated");
82 
83  addRewrapStream(filename, streamIndex, offset);
84  }
85  // Transcode
86  else
87  {
88  const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile(profileName);
89  add(filename, streamIndex, transcodeProfile, codec, offset);
90  }
91 }
92 
93 void Transcoder::add(const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile,
94  const float offset)
95 {
96  // Check filename
97  if(!filename.length())
98  throw std::runtime_error("Can't transcode a stream without filename indicated");
99 
100  addTranscodeStream(filename, streamIndex, -1, profile, offset);
101 }
102 
103 void Transcoder::add(const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile,
104  ICodec& codec, const float offset)
105 {
106  // Generator
107  if(!filename.length())
108  {
109  addDummyStream(profile, codec);
110  }
111  // Transcode
112  else
113  {
114  addTranscodeStream(filename, streamIndex, -1, profile, offset);
115  }
116 }
117 
118 void Transcoder::add(const std::string& filename, const size_t streamIndex, const int subStreamIndex,
119  const std::string& profileName, const float offset)
120 {
121  // No subStream selected
122  if(subStreamIndex < 0)
123  {
124  add(filename, streamIndex, profileName, offset);
125  return;
126  }
127 
128  if(profileName.length() == 0)
129  {
130  // Re-wrap
131  if(subStreamIndex < 0)
132  {
133  addRewrapStream(filename, streamIndex, offset);
134  }
135  // Transcode (transparent for the user)
136  else
137  {
138  addTranscodeStream(filename, streamIndex, subStreamIndex, offset);
139  }
140  }
141  // Transcode
142  else
143  {
144  const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile(profileName);
145  add(filename, streamIndex, subStreamIndex, transcodeProfile, offset);
146  }
147 }
148 
149 void Transcoder::add(const std::string& filename, const size_t streamIndex, const int subStreamIndex,
150  const std::string& profileName, ICodec& codec, const float offset)
151 {
152  // No subStream selected
153  if(subStreamIndex < 0)
154  {
155  add(filename, streamIndex, profileName, codec);
156  return;
157  }
158 
159  // Re-wrap
160  if(profileName.length() == 0)
161  {
162  // Re-wrap
163  if(subStreamIndex < 0)
164  {
165  addRewrapStream(filename, streamIndex, offset);
166  }
167  // Transcode (transparent for the user)
168  else
169  {
170  addTranscodeStream(filename, streamIndex, subStreamIndex, offset);
171  }
172  }
173  // Transcode
174  else
175  {
176  const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile(profileName);
177  add(filename, streamIndex, subStreamIndex, transcodeProfile, codec, offset);
178  }
179 }
180 
181 void Transcoder::add(const std::string& filename, const size_t streamIndex, const int subStreamIndex,
182  const ProfileLoader::Profile& profile, const float offset)
183 {
184  // No subStream selected
185  if(subStreamIndex < 0)
186  {
187  add(filename, streamIndex, profile, offset);
188  return;
189  }
190 
191  // Check filename
192  if(!filename.length())
193  throw std::runtime_error("Can't transcode a stream without filename indicated");
194 
195  addTranscodeStream(filename, streamIndex, subStreamIndex, profile, offset);
196 }
197 
198 void Transcoder::add(const std::string& filename, const size_t streamIndex, const int subStreamIndex,
199  const ProfileLoader::Profile& profile, ICodec& codec, const float offset)
200 {
201  // No subStream selected
202  if(subStreamIndex < 0)
203  {
204  add(filename, streamIndex, profile);
205  return;
206  }
207 
208  // Generator
209  if(!filename.length())
210  {
211  addDummyStream(profile, codec);
212  return;
213  }
214 
215  addTranscodeStream(filename, streamIndex, subStreamIndex, profile, offset);
216 }
217 
219 {
220  _streamTranscoders.push_back(&stream);
221 }
222 
224 {
225  for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex)
226  {
227  LOG_DEBUG("Init stream " << streamIndex)
228  _streamTranscoders.at(streamIndex)->preProcessCodecLatency();
229  }
230 }
231 
233 {
234  if(_streamTranscoders.size() == 0)
235  return false;
236 
237  // For each stream, process a frame
238  size_t nbStreamProcessStatusFailed = 0;
239  for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex)
240  {
241  LOG_DEBUG("Process stream " << streamIndex << "/" << (_streamTranscoders.size() - 1))
242  if(!_streamTranscoders.at(streamIndex)->processFrame())
243  {
244  LOG_WARN("Failed to process stream " << streamIndex)
245  ++nbStreamProcessStatusFailed;
246  }
247  }
248 
249  // Get the number of streams without the generators (they always succeed)
250  size_t nbStreamsWithoutGenerator = _streamTranscoders.size();
251  for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex)
252  {
253  if(_streamTranscoders.at(streamIndex)->getProcessCase() == StreamTranscoder::eProcessCaseGenerator)
254  --nbStreamsWithoutGenerator;
255  }
256 
257  // If all streams failed to process a new frame
258  if(nbStreamsWithoutGenerator != 0 && nbStreamsWithoutGenerator == nbStreamProcessStatusFailed)
259  {
260  LOG_INFO("End of process because all streams (except generators) failed to process a new frame.")
261  return false;
262  }
263  return true;
264 }
265 
267 {
268  NoDisplayProgress progress;
269  return process(progress);
270 }
271 
273 {
274  if(_streamTranscoders.size() == 0)
275  throw std::runtime_error("Missing input streams in transcoder");
276 
278 
279  LOG_INFO("Start process")
280 
282 
284 
285  const float expectedOutputDuration = getExpectedOutputDuration();
286  LOG_INFO("The expected output duration of the program will be " << expectedOutputDuration << "s.")
287 
288  size_t frame = 0;
289  bool frameProcessed = true;
290  while(frameProcessed)
291  {
292  LOG_DEBUG("Process frame " << frame)
293  frameProcessed = processFrame();
294  ++frame;
295 
296  const float progressDuration = getCurrentOutputDuration();
297 
298  // check if JobStatusCancel
299  if(progress.progress((progressDuration > expectedOutputDuration) ? expectedOutputDuration : progressDuration,
300  expectedOutputDuration) == eJobStatusCancel)
301  {
302  LOG_INFO("End of process because the job was canceled.")
303  break;
304  }
305 
306  // check progressDuration
307  if(progressDuration >= expectedOutputDuration)
308  {
309  LOG_INFO("End of process because the output program duration ("
310  << progressDuration << "s) is equal or upper than " << expectedOutputDuration << "s.")
311  break;
312  }
313  }
314 
316 
317  LOG_INFO("End of process: " << frame << " frames processed")
318 
319  LOG_INFO("Get process statistics")
320  ProcessStat processStat;
321  fillProcessStat(processStat);
322 
323  return processStat;
324 }
325 
326 void Transcoder::setProcessMethod(const EProcessMethod eProcessMethod, const size_t indexBasedStream,
327  const double outputDuration)
328 {
329  _eProcessMethod = eProcessMethod;
330  _mainStreamIndex = indexBasedStream;
331  _outputDuration = outputDuration;
332 }
333 
334 void Transcoder::addRewrapStream(const std::string& filename, const size_t streamIndex, const float offset)
335 {
336  LOG_INFO("Add rewrap stream from file '" << filename << "' / index=" << streamIndex << " / offset=" << offset << "s")
337 
338  InputFile* referenceFile = addInputFile(filename, streamIndex, offset);
339 
340  _streamTranscodersAllocated.push_back(new StreamTranscoder(referenceFile->getStream(streamIndex), _outputFile, offset));
342 }
343 
344 void Transcoder::addTranscodeStream(const std::string& filename, const size_t streamIndex, const int subStreamIndex,
345  const float offset)
346 {
347  // Get profile from input file
348  InputFile inputFile(filename);
349  ProfileLoader::Profile profile = getProfileFromFile(inputFile, streamIndex);
350 
351  // override channels parameter to manage demultiplexing
352  ProfileLoader::Profile::iterator it = profile.find(constants::avProfileChannel);
353  if(it != profile.end())
354  it->second = "1";
355 
356  addTranscodeStream(filename, streamIndex, subStreamIndex, profile, offset);
357 }
358 
359 void Transcoder::addTranscodeStream(const std::string& filename, const size_t streamIndex, const int subStreamIndex,
360  const ProfileLoader::Profile& profile, const float offset)
361 {
362  // Add profile
363  if(!_profileLoader.hasProfile(profile))
364  _profileLoader.loadProfile(profile);
365 
366  LOG_INFO("Add transcode stream from file '"
367  << filename << "' / index=" << streamIndex << " / channel=" << subStreamIndex
368  << " / encodingProfile=" << profile.at(constants::avProfileIdentificatorHuman) << " / offset=" << offset << "s")
369 
370  // Add input file
371  InputFile* referenceFile = addInputFile(filename, streamIndex, offset);
372 
373  switch(referenceFile->getStream(streamIndex).getProperties().getStreamType())
374  {
375  case AVMEDIA_TYPE_VIDEO:
376  case AVMEDIA_TYPE_AUDIO:
377  {
378  _streamTranscodersAllocated.push_back(
379  new StreamTranscoder(referenceFile->getStream(streamIndex), _outputFile, profile, subStreamIndex, offset));
381  break;
382  }
383  case AVMEDIA_TYPE_DATA:
384  case AVMEDIA_TYPE_SUBTITLE:
385  case AVMEDIA_TYPE_ATTACHMENT:
386  default:
387  {
388  throw std::runtime_error("unsupported media type in transcode setup");
389  }
390  }
391 }
392 
393 void Transcoder::addDummyStream(const ProfileLoader::Profile& profile, const ICodec& codec)
394 {
395  // Add profile
396  if(!_profileLoader.hasProfile(profile))
397  _profileLoader.loadProfile(profile);
398 
399  LOG_INFO("Add generated stream with codec '"
400  << codec.getCodecName() << "' / encodingProfile=" << profile.at(constants::avProfileIdentificatorHuman))
401 
402  _streamTranscodersAllocated.push_back(new StreamTranscoder(codec, _outputFile, profile));
404 }
405 
406 InputFile* Transcoder::addInputFile(const std::string& filename, const int streamIndex, const float offset)
407 {
408  InputFile* referenceFile = NULL;
409 
410  if(streamIndex >= 0)
411  {
412  for(std::vector<InputFile*>::iterator it = _inputFiles.begin(); it != _inputFiles.end(); ++it)
413  {
414  if(((*it)->getFilename() == filename) && !(*it)->getStream(streamIndex).isActivated())
415  {
416  referenceFile = (*it);
417  LOG_DEBUG("Get instance of InputFile from '" << filename << "'")
418  break;
419  }
420  }
421  }
422 
423  if(!referenceFile)
424  {
425  LOG_DEBUG("New instance of InputFile from '" << filename << "'")
426 
427  _inputFiles.push_back(new InputFile(filename));
428  referenceFile = _inputFiles.back();
429  }
430 
431  if(streamIndex >= 0)
432  referenceFile->activateStream(streamIndex);
433  else
434  {
435  for(size_t index = 0; index < referenceFile->getProperties().getNbStreams(); ++index)
436  referenceFile->activateStream(index);
437  }
438 
439  // If negative offset, move forward in the input stream
440  if(offset < 0)
441  referenceFile->seekAtTime(-offset);
442 
443  return referenceFile;
444 }
445 
447 {
448  const StreamProperties* streamProperties = &inputFile.getProperties().getStreamPropertiesWithIndex(streamIndex);
449  const VideoProperties* videoProperties = NULL;
450  const AudioProperties* audioProperties = NULL;
451  switch(inputFile.getStream(streamIndex).getProperties().getStreamType())
452  {
453  case AVMEDIA_TYPE_VIDEO:
454  {
455  videoProperties = dynamic_cast<const VideoProperties*>(streamProperties);
456  break;
457  }
458  case AVMEDIA_TYPE_AUDIO:
459  {
460  audioProperties = dynamic_cast<const AudioProperties*>(streamProperties);
461  break;
462  }
463  default:
464  break;
465  }
466 
467  // common fileds in profile types
468  ProfileLoader::Profile profile;
469  profile[constants::avProfileIdentificator] = "profileFromInput";
470  profile[constants::avProfileIdentificatorHuman] = "profile from input";
471 
472  // video
473  if(videoProperties != NULL)
474  {
476  profile[constants::avProfileCodec] = videoProperties->getCodecName();
478  std::stringstream ss;
479  ss << videoProperties->getFps();
480  profile[constants::avProfileFrameRate] = ss.str();
481  profile[constants::avProfileWidth] = videoProperties->getWidth();
482  profile[constants::avProfileHeight] = videoProperties->getHeight();
483  }
484  // audio
485  else if(audioProperties != NULL)
486  {
488  profile[constants::avProfileCodec] = audioProperties->getCodecName();
489  profile[constants::avProfileSampleFormat] = audioProperties->getSampleFormatName();
490  std::stringstream ss;
491  ss << audioProperties->getSampleRate();
492  profile[constants::avProfileSampleRate] = ss.str();
493  ss.str("");
494  ss << audioProperties->getNbChannels();
495  profile[constants::avProfileChannel] = ss.str();
496  }
497 
498  return profile;
499 }
500 
501 float Transcoder::getStreamDuration(size_t indexStream) const
502 {
503  return _streamTranscoders.at(indexStream)->getDuration();
504 }
505 
507 {
508  float minTotalDuration = std::numeric_limits<float>::max();
509  for(size_t i = 0; i < _streamTranscoders.size(); ++i)
510  {
511  minTotalDuration = std::min(getStreamDuration(i), minTotalDuration);
512  }
513  return minTotalDuration;
514 }
515 
517 {
518  float maxTotalDuration = 0;
519  for(size_t i = 0; i < _streamTranscoders.size(); ++i)
520  {
521  maxTotalDuration = std::max(getStreamDuration(i), maxTotalDuration);
522  }
523  return maxTotalDuration;
524 }
525 
527 {
528  switch(_eProcessMethod)
529  {
531  return getMinTotalDuration();
533  return getMaxTotalDuration();
537  return _outputDuration;
539  return std::numeric_limits<float>::max();
540  default:
541  return getMaxTotalDuration();
542  }
543 }
544 
546 {
547  float currentOutputDuration = -1;
548  for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex)
549  {
550  const float currentStreamDuration = _outputFile.getStream(streamIndex).getStreamDuration();
551  if(currentOutputDuration == -1)
552  currentOutputDuration = currentStreamDuration;
553  else if(currentStreamDuration < currentOutputDuration)
554  currentOutputDuration = currentStreamDuration;
555  }
556  return currentOutputDuration;
557 }
558 
560 {
561  for(size_t i = 0; i < _streamTranscoders.size(); ++i)
562  {
563  const float currentDuration = _streamTranscoders.at(i)->getDuration();
564  switch(_eProcessMethod)
565  {
567  if(_streamTranscoders.at(i)->getDuration() >= getMinTotalDuration())
568  _streamTranscoders.at(i)->needToSwitchToGenerator(false);
569  else
570  _streamTranscoders.at(i)->needToSwitchToGenerator();
571  break;
573  if(_streamTranscoders.at(i)->getDuration() == getMaxTotalDuration())
574  _streamTranscoders.at(i)->needToSwitchToGenerator(false);
575  else
576  _streamTranscoders.at(i)->needToSwitchToGenerator();
577  break;
579  if(i != _mainStreamIndex && currentDuration < _streamTranscoders.at(_mainStreamIndex)->getDuration())
580  _streamTranscoders.at(i)->needToSwitchToGenerator();
581  else
582  _streamTranscoders.at(i)->needToSwitchToGenerator(false);
583  break;
585  if(_streamTranscoders.at(i)->getDuration() >= _outputDuration)
586  _streamTranscoders.at(i)->needToSwitchToGenerator(false);
587  else
588  _streamTranscoders.at(i)->needToSwitchToGenerator();
589  break;
591  _streamTranscoders.at(i)->needToSwitchToGenerator();
592  break;
593  }
594  }
595 }
596 
598 {
599  for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex)
600  {
601  IOutputStream& stream = _streamTranscoders.at(streamIndex)->getOutputStream();
602  const IInputStream* inputStream = _streamTranscoders.at(streamIndex)->getInputStream();
603  if(inputStream == NULL)
604  {
605  LOG_WARN("Cannot process statistics of generated stream.")
606  continue;
607  }
608  const AVMediaType mediaType = inputStream->getProperties().getStreamType();
609  switch(mediaType)
610  {
611  case AVMEDIA_TYPE_VIDEO:
612  {
613  VideoStat videoStat(stream.getStreamDuration(), stream.getNbFrames());
614  IEncoder* encoder = _streamTranscoders.at(streamIndex)->getEncoder();
615  if(encoder)
616  {
617  const AVCodecContext& encoderContext = encoder->getCodec().getAVCodecContext();
618  if(encoderContext.coded_frame && (encoderContext.flags & CODEC_FLAG_PSNR))
619  {
620  videoStat.setQuality(encoderContext.coded_frame->quality);
621  videoStat.setPSNR(encoderContext.coded_frame->error[0] /
622  (encoderContext.width * encoderContext.height * 255.0 * 255.0));
623  }
624  }
625  processStat.addVideoStat(streamIndex, videoStat);
626  break;
627  }
628  case AVMEDIA_TYPE_AUDIO:
629  {
630  AudioStat audioStat(stream.getStreamDuration(), stream.getNbFrames());
631  processStat.addAudioStat(streamIndex, audioStat);
632  break;
633  }
634  default:
635  LOG_WARN("No process statistics for stream at index: " << streamIndex << " (AVMediaType = " << mediaType
636  << ")")
637  break;
638  }
639  }
640 }
641 }
void loadProfile(const std::string &avProfileFileName)
Load the profile defines in the given file.
Base class of Progress. Inherit this class to have your own way to manage a progress bar...
Definition: IProgress.hpp:23
ProcessStat contains statistics given after the process.
Definition: ProcessStat.hpp:17
AVMediaType getStreamType() const
const std::string avProfileFrameRate
std::vector< InputFile * > _inputFiles
The list of input files which contain added streams (has ownership)
Definition: Transcoder.hpp:234
void manageSwitchToGenerator()
Set for each StreamTranscoder if it can switch to generator at the end.
Definition: Transcoder.cpp:559
virtual EJobStatus progress(const double processedDuration, const double programDuration)=0
Manage the progress.
std::vector< StreamTranscoder * > _streamTranscodersAllocated
Streams allocated inside the Transcoder (has ownership)
Definition: Transcoder.hpp:237
virtual const StreamProperties & getProperties() const =0
IOutputfile is the interface to wrap and write medias. It can be overloaded to integrate custom wrapp...
Definition: IOutputFile.hpp:22
std::string getCodecName() const
bool seekAtTime(const double time, const int flag=AVSEEK_FLAG_ANY)
Definition: InputFile.cpp:102
bool hasProfile(const Profile &profile) const
std::string getPixelFormatName() const
virtual bool beginWrap()=0
Write the header of file (if necessary)
float getMaxTotalDuration() const
Get the duration of the longest stream, in seconds.
Definition: Transcoder.cpp:516
void addTranscodeStream(const std::string &filename, const size_t streamIndex, const int subStreamIndex, const float offset)
Definition: Transcoder.cpp:344
std::map< std::string, std::string > Profile
const std::string avProfileTypeAudio
const std::string avProfileIdentificator
const std::string avProfileIdentificatorHuman
const std::string avProfileSampleRate
float getCurrentOutputDuration() const
Get the current duration of the output program.
Definition: Transcoder.cpp:545
const Profile & getProfile(const std::string &avProfileIdentificator) const
const std::string avProfilePixelFormat
const std::vector< avtranscoder::StreamProperties * > getStreamProperties() const
const std::string avProfileTypeVideo
#define LOG_INFO(...)
Definition: log.hpp:23
const avtranscoder::StreamProperties & getStreamPropertiesWithIndex(const size_t streamIndex) const
float getExpectedOutputDuration() const
Get the expected duration of the output program.
Definition: Transcoder.cpp:526
EProcessMethod
Enum to set a policy of how we manage the process in case of several streams. eProcessMethodShortest:...
Definition: Transcoder.hpp:29
virtual bool endWrap()=0
Write the footer of file (if necessary)
void add(const std::string &filename)
Add all streams of the file with the given filename. All the streams will be rewrapped.
Definition: Transcoder.cpp:38
EProcessMethod _eProcessMethod
Processing policy.
Definition: Transcoder.hpp:241
float getMinTotalDuration() const
Get the duration of the shortest stream, in seconds.
Definition: Transcoder.cpp:506
void activateStream(const size_t streamIndex, const bool activate=true)
Activate the indicated stream.
Definition: InputFile.cpp:108
float getStreamDuration(size_t indexStream) const
Get the duration of the stream, in seconds.
Definition: Transcoder.cpp:501
std::vector< StreamTranscoder * > _streamTranscoders
All streams of the output media file after process.
Definition: Transcoder.hpp:236
const FileProperties & getProperties() const
Return media properties on the current InputFile.
Definition: InputFile.hpp:71
ProfileLoader _profileLoader
Objet to get existing profiles, and add new ones for the Transcoder.
Definition: Transcoder.hpp:239
virtual float getStreamDuration() const =0
#define LOG_WARN(...)
Definition: log.hpp:29
bool processFrame()
Process the next frame of all streams.
Definition: Transcoder.cpp:232
void preProcessCodecLatency()
Initialize all added streams, processing codec latency.
Definition: Transcoder.cpp:223
float getFps() const
Corresponds to the 'fps' returned by ffprobe. fps = the average framerate that has come from the AVSt...
const StreamProperties & getProperties() const
void fillProcessStat(ProcessStat &processStat)
Fill the given ProcessStat to summarize the process.
Definition: Transcoder.cpp:597
std::string getCodecName() const
Definition: ICodec.cpp:84
ProcessStat process()
Call process with no display of progression.
Definition: Transcoder.cpp:266
void addVideoStat(const size_t streamIndex, const VideoStat &videoStat)
Definition: ProcessStat.cpp:8
std::string getSampleFormatName() const
PixelProperties & getPixelProperties()
const std::string avProfileWidth
virtual size_t getNbFrames() const =0
Statistics related to a video stream.
Definition: VideoStat.hpp:12
Virtual based class of properties for all types of stream.
const std::string avProfileHeight
#define LOG_DEBUG(...)
Definition: log.hpp:17
ProfileLoader::Profile getProfileFromFile(InputFile &inputFile, const size_t streamIndex)
The function analyses the inputFile.
Definition: Transcoder.cpp:446
void addDummyStream(const ProfileLoader::Profile &profile, const ICodec &codec)
Definition: Transcoder.cpp:393
const std::string avProfileCodec
Transcoder(const Transcoder &transcoder)
Statistics related to an audio stream.
Definition: AudioStat.hpp:12
const std::string avProfileSampleFormat
size_t _mainStreamIndex
Index of stream used to stop the process of transcode in case of eProcessMethodBasedOnStream.
Definition: Transcoder.hpp:243
void setProcessMethod(const EProcessMethod eProcessMethod, const size_t indexBasedStream=0, const double outputDuration=0)
Set the transcoding policy.
Definition: Transcoder.cpp:326
void addAudioStat(const size_t streamIndex, const AudioStat &audioStat)
Definition: ProcessStat.cpp:13
const std::string avProfileChannel
InputStream & getStream(size_t index)
Get stream type: video, audio, subtitle, etc.
Definition: InputFile.cpp:113
const std::string avProfileType
Implementation of IProgress, to manage cases when we need an IProgress but don't care of a progress b...
IOutputFile & _outputFile
The output media file after process (has link)
Definition: Transcoder.hpp:233
void addRewrapStream(const std::string &filename, const size_t streamIndex, const float offset)
Definition: Transcoder.cpp:334
InputFile * addInputFile(const std::string &filename, const int streamIndex, const float offset)
Definition: Transcoder.cpp:406
virtual IOutputStream & getStream(const size_t streamIndex)=0
Get the output stream.