YARP  2.3.70.1
Yet Another Robot Platform
FfmpegWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 RobotCub Consortium
3  * Authors: Paul Fitzpatrick
4  * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
5  *
6  */
7 
8 
9 #ifndef FfmpegWriter_INC
10 #define FfmpegWriter_INC
11 
12 #include "avpreamble.h"
13 
14 extern "C" {
15 #include <avcodec.h>
16 #include <avformat.h>
17 }
18 
19 /*
20  * Uses ffmpeg to write images to movie files.
21  *
22  */
23 
24 namespace yarp {
25  namespace dev {
26  class FfmpegWriter;
27  }
28 }
29 
31 #include <yarp/dev/DeviceDriver.h>
32 
41  public DeviceDriver,
42  public IAudioVisualStream
43 {
44 public:
45 
47  system_resource = NULL;
48  ready = false;
49  }
50 
51  virtual bool open(yarp::os::Searchable & config) override;
52 
53  virtual bool close() override;
54 
56 
58  yarp::sig::Sound& sound) override;
59 
60 
61  virtual bool hasAudio() override { return true; }
62 
63  virtual bool hasVideo() override { return true; }
64 
65 private:
67 
68  AVOutputFormat *fmt;
69  AVFormatContext *oc;
70  AVStream *audio_st, *video_st;
74  AVFrame *picture, *tmp_picture;
75  uint8_t *video_outbuf;
77  bool ready;
78  bool delayed;
79 
80  virtual bool delayedOpen(yarp::os::Searchable & config);
81 
82  bool isOk() {
83  if (delayed) {
84  delayed = false;
85  ready = delayedOpen(savedConfig);
86  if (delayed) { ready = false; }
87  }
88  return ready;
89  }
90 
91  void open_video(AVFormatContext *oc, AVStream *st);
92 
93  void write_video_frame(AVFormatContext *oc, AVStream *st,
95 
96  void close_video(AVFormatContext *oc, AVStream *st);
97 };
98 
99 
109 #endif
void write_video_frame(AVFormatContext *oc, AVStream *st, yarp::sig::ImageOf< yarp::sig::PixelRgb > &img)
AVFormatContext * oc
Definition: FfmpegWriter.h:69
virtual bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:34
virtual bool putImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Write an image to the device.
yarp::os::ConstString filename
Definition: FfmpegWriter.h:72
Write a YARP-format image and sound to a device.
virtual bool hasAudio() override
Definition: FfmpegWriter.h:61
virtual bool delayedOpen(yarp::os::Searchable &config)
delete image
Definition: IplImage.cpp:897
yarp::os::Property savedConfig
Definition: FfmpegWriter.h:73
A class for storing options and configuration information.
Definition: Property.h:32
A base class for nested structures that can be searched.
Definition: Searchable.h:56
Class for storing sounds.
Definition: Sound.h:25
The main, catch-all namespace for YARP.
A string with almost the same api as std::string.
Definition: ConstString.h:44
void open_video(AVFormatContext *oc, AVStream *st)
Uses ffmpeg to write images/sounds to movie files (AVI, MOV, ...).
Definition: FfmpegWriter.h:39
virtual bool putAudioVisual(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image, yarp::sig::Sound &sound) override
Write an image and sound.
virtual bool close() override
Close the DeviceDriver.
For streams capable of holding different kinds of content, check what they actually have...
AVOutputFormat * fmt
Definition: FfmpegWriter.h:68
void close_video(AVFormatContext *oc, AVStream *st)
Read a YARP-format image to a device.
virtual bool hasVideo() override
Definition: FfmpegWriter.h:63