Feature: set params of start_time/duration

pull/221/head
xufuji456 3 years ago
parent 0d6855b746
commit 98bfa11973
  1. 7
      app/src/main/cpp/cut_video.cpp
  2. 6
      app/src/main/cpp/cut_video.h

@ -53,6 +53,11 @@ int CutVideo::open_output_file(AVFormatContext *ifmt_ctx, const char *filename)
return 0; return 0;
} }
void CutVideo:: setParam(int64_t start_time, int64_t duration) {
m_startTime = start_time;
m_duration = duration;
}
AVPacket* CutVideo::copy_packet(AVFormatContext *ifmt_ctx, AVPacket *packet) { AVPacket* CutVideo::copy_packet(AVFormatContext *ifmt_ctx, AVPacket *packet) {
AVStream* in_stream; AVStream* in_stream;
AVStream* out_stream; AVStream* out_stream;
@ -95,7 +100,7 @@ int CutVideo::write_internal(AVFormatContext *ifmt_ctx, AVPacket *packet)
void CutVideo::write_output_file(AVFormatContext *ifmt_ctx, AVPacket *packet) { void CutVideo::write_output_file(AVFormatContext *ifmt_ctx, AVPacket *packet) {
int64_t timestamp = packet->pts * av_q2d(ifmt_ctx->streams[packet->stream_index]->time_base); int64_t timestamp = packet->pts * av_q2d(ifmt_ctx->streams[packet->stream_index]->time_base);
if (timestamp >= start_time && timestamp < start_time + duration) { if (timestamp >= m_startTime && timestamp < m_startTime + m_duration) {
// if (start_pts == 0 && start_dts == 0) { // if (start_pts == 0 && start_dts == 0) {
// start_pts = packet->pts; // start_pts = packet->pts;
// start_dts = packet->dts; // start_dts = packet->dts;

@ -16,8 +16,8 @@ extern "C" {
class CutVideo { class CutVideo {
private: private:
int64_t start_time = 15; int64_t m_startTime = 15;
int64_t duration = 10; int64_t m_duration = 10;
int64_t start_dts = 0; int64_t start_dts = 0;
int64_t start_pts = 0; int64_t start_pts = 0;
@ -31,6 +31,8 @@ public:
int open_output_file(AVFormatContext *ifmt_ctx, const char *filename); int open_output_file(AVFormatContext *ifmt_ctx, const char *filename);
void setParam(int64_t start_time, int64_t duration);
void write_output_file(AVFormatContext *ifmt_ctx, AVPacket *packet); void write_output_file(AVFormatContext *ifmt_ctx, AVPacket *packet);
void close_output_file(); void close_output_file();

Loading…
Cancel
Save