You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					38 lines
				
				1.1 KiB
			
		
		
			
		
	
	
					38 lines
				
				1.1 KiB
			| 
								 
											4 years ago
										 
									 | 
							
								#pragma once
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include <cstdio>
							 | 
						||
| 
								 | 
							
								#include <cstdlib>
							 | 
						||
| 
								 | 
							
								#include <string>
							 | 
						||
| 
								 | 
							
								#include <vector>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#include <libavcodec/avcodec.h>
							 | 
						||
| 
								 | 
							
								#include <libavformat/avformat.h>
							 | 
						||
| 
								 | 
							
								#include <libavutil/imgutils.h>
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								#include "system/loggerd/encoder/encoder.h"
							 | 
						||
| 
								 | 
							
								#include "system/loggerd/loggerd.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								class FfmpegEncoder : public VideoEncoder {
							 | 
						||
| 
								 | 
							
								 public:
							 | 
						||
| 
								 | 
							
								  FfmpegEncoder(const char* filename, CameraType type, int in_width, int in_height, int fps,
							 | 
						||
| 
								 | 
							
								                int bitrate, cereal::EncodeIndex::Type codec, int out_width, int out_height, bool write) :
							 | 
						||
| 
								 | 
							
								                VideoEncoder(filename, type, in_width, in_height, fps, bitrate, cereal::EncodeIndex::Type::BIG_BOX_LOSSLESS, out_width, out_height, write) { encoder_init(); }
							 | 
						||
| 
								 | 
							
								  ~FfmpegEncoder();
							 | 
						||
| 
								 | 
							
								  void encoder_init();
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								  int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra);
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  void encoder_open(const char* path);
							 | 
						||
| 
								 | 
							
								  void encoder_close();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								private:
							 | 
						||
| 
								 | 
							
								  int segment_num = -1;
							 | 
						||
| 
								 | 
							
								  int counter = 0;
							 | 
						||
| 
								 | 
							
								  bool is_open = false;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  AVCodecContext *codec_ctx;
							 | 
						||
| 
								 | 
							
								  AVFrame *frame = NULL;
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								  std::vector<uint8_t> convert_buf;
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  std::vector<uint8_t> downscale_buf;
							 | 
						||
| 
								 | 
							
								};
							 |