Loading...
Searching...
No Matches
openshot::ChunkWriter Class Reference

This class takes any reader and generates a special type of video file, built with chunks of small video and audio data. More...

`#include <ChunkWriter.h>`

Inheritance diagram for openshot::ChunkWriter:

## Public Member Functions

| ChunkWriter (std::string path, openshot::ReaderBase *reader)
| Constructor for ChunkWriter. Throws one of the following exceptions.
void | Close ()
| Close the writer.
int64_t | GetChunkSize ()
| Get the chunk size (number of frames to write in each chunk)
bool | IsOpen ()
| Determine if writer is open or closed.
void | Open ()
| Open writer.
void | SetChunkSize (int64_t new_size)
| Set the chunk size (number of frames to write in each chunk)
void | WriteFrame (int64_t start, int64_t length)
| Write a block of frames from a reader.
void | WriteFrame (openshot::ReaderBase *reader, int64_t start, int64_t length)
| Write a block of frames from a reader.
void | WriteFrame (std::shared_ptr< openshot::Frame > frame)
| Add a frame to the stack waiting to be encoded.
Public Member Functions inherited from openshot::WriterBase
void | CopyReaderInfo (openshot::ReaderBase *reader)
| This method copy's the info struct of a reader, and sets the writer with the same info.
void | DisplayInfo (std::ostream *out=&std::cout)
| Display file information in the standard output stream (stdout)
std::string | Json () const
| Generate JSON string of this object.
Json::Value | JsonValue () const
| Generate Json::Value for this object.
void | SetJson (const std::string value)
| Load JSON string into this object.
void | SetJsonValue (const Json::Value root)
| Load Json::Value into this object.
| WriterBase ()
| Constructor for WriterBase class, many things are initialized here.
virtual | ~WriterBase ()=default

## Additional Inherited Members

Public Attributes inherited from openshot::WriterBase
WriterInfo | info
| Information about the current media file.

## Detailed Description

This class takes any reader and generates a special type of video file, built with chunks of small video and audio data.

These chunks can easily be passed around in a distributed computing environment, without needing to share the entire video file. They also allow a chunk to be frame accurate, since seeking inaccuracies are removed.

// This example demonstrates how to feed a reader into a ChunkWriter
FFmpegReader *r = new FFmpegReader("MyAwesomeVideo.mp4"); // Get a reader
r.Open(); // Open the reader
// Create a ChunkWriter (and a folder location on your computer)
ChunkWriter w("/folder_path_to_hold_chunks/", r);
// Open the writer
w.Open();
// Write a block of frames to the ChunkWriter (from frame 1 to the end)
w.WriteFrame(r, 1, r->info.video_length);
// Close the reader & writer
w.Close();
r.Close();
openshot::ChunkWriter
This class takes any reader and generates a special type of video file, built with chunks of small vi...
Definition ChunkWriter.h:63
openshot::FFmpegReader
This class uses the FFmpeg libraries, to open video files and audio files, and return openshot::Frame...
Definition FFmpegReader.h:101
openshot::FFmpegReader::Open
void Open() override
Open File - which is called by the constructor automatically.
Definition FFmpegReader.cpp:207
openshot::FFmpegReader::Close
void Close() override
Close File.
Definition FFmpegReader.cpp:586
openshot::ReaderBase::info
openshot::ReaderInfo info
Information about the current media file.
Definition ReaderBase.h:88
openshot::ReaderInfo::video_length
int64_t video_length
The number of frames in the video stream.
Definition ReaderBase.h:53

Definition at line 62 of file ChunkWriter.h.

## Constructor & Destructor Documentation

## ChunkWriter()

ChunkWriter::ChunkWriter | ( | std::string | path,
|  | openshot::ReaderBase * | reader
| ) |  |

Constructor for ChunkWriter. Throws one of the following exceptions.

Parameters

  path | The folder path of the chunk file to be created
  reader | The initial reader to base this chunk file's meta data on (such as fps, height, width, etc...)

Definition at line 19 of file ChunkWriter.cpp.

## Member Function Documentation

## Close()

void ChunkWriter::Close | ( |  | ) |

Close the writer.

Definition at line 209 of file ChunkWriter.cpp.

## GetChunkSize()

int64_t openshot::ChunkWriter::GetChunkSize | ( |  | ) |

inline

Get the chunk size (number of frames to write in each chunk)

Definition at line 104 of file ChunkWriter.h.

## IsOpen()

bool openshot::ChunkWriter::IsOpen | ( |  | ) |

inline virtual

Determine if writer is open or closed.

Implements openshot::WriterBase.

Definition at line 107 of file ChunkWriter.h.

## Open()

void ChunkWriter::Open | ( |  | ) |

virtual

Open writer.

Implements openshot::WriterBase.

Definition at line 280 of file ChunkWriter.cpp.

## SetChunkSize()

void openshot::ChunkWriter::SetChunkSize | ( | int64_t | new_size | ) |

inline

Set the chunk size (number of frames to write in each chunk)

Parameters

  new_size | The number of frames to write in this chunk file

Definition at line 114 of file ChunkWriter.h.

## WriteFrame() [1/3]

void ChunkWriter::WriteFrame | ( | int64_t | start,
|  | int64_t | length
| ) |  |

Write a block of frames from a reader.

Parameters

  start | The starting frame number to write (of the reader passed into the constructor)
  length | The number of frames to write (of the reader passed into the constructor)

Definition at line 195 of file ChunkWriter.cpp.

## WriteFrame() [2/3]

void ChunkWriter::WriteFrame | ( | openshot::ReaderBase * | reader,
|  | int64_t | start,
|  | int64_t | length
| ) |  |

virtual

Write a block of frames from a reader.

Parameters

  reader | The reader containing the frames you need
  start | The starting frame number to write
  length | The number of frames to write

Implements openshot::WriterBase.

Definition at line 181 of file ChunkWriter.cpp.

## WriteFrame() [3/3]

void ChunkWriter::WriteFrame | ( | std::shared_ptr< openshot::Frame > | frame | ) |

virtual

Add a frame to the stack waiting to be encoded.

Parameters

  frame | The openshot::Frame object that needs to be written to this chunk file.

Implements openshot::WriterBase.

Definition at line 64 of file ChunkWriter.cpp.

Referenced by WriteFrame(), and WriteFrame().

The documentation for this class was generated from the following files:

- ChunkWriter.h
- ChunkWriter.cpp