mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-01-06 06:05:32 +01:00
fftools/ffmpeg: add loopback decoding
This allows to send an encoder's output back to decoding and feed the result into a complex filtergraph.
This commit is contained in:
@@ -49,6 +49,7 @@ struct Encoder {
|
||||
uint64_t packets_encoded;
|
||||
|
||||
int opened;
|
||||
int attach_par;
|
||||
|
||||
Scheduler *sch;
|
||||
unsigned sch_idx;
|
||||
@@ -693,6 +694,18 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame,
|
||||
return AVERROR(ENOMEM);
|
||||
fd->wallclock[LATENCY_PROBE_ENC_POST] = av_gettime_relative();
|
||||
|
||||
// attach stream parameters to first packet if requested
|
||||
avcodec_parameters_free(&fd->par_enc);
|
||||
if (e->attach_par && !e->packets_encoded) {
|
||||
fd->par_enc = avcodec_parameters_alloc();
|
||||
if (!fd->par_enc)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ret = avcodec_parameters_from_context(fd->par_enc, enc);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
ret = update_video_stats(ost, pkt, !!vstats_filename);
|
||||
if (ret < 0)
|
||||
@@ -929,3 +942,9 @@ finish:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int enc_loopback(Encoder *enc)
|
||||
{
|
||||
enc->attach_par = 1;
|
||||
return enc->sch_idx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user