mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-13 02:20:07 +01:00
fftools/ffmpeg: rework initializing encoders with no frames
When no frames were passed from a filtergraph to an encoder, but the filtergraph is configured (i.e. has output parameters), encoder flush code will use those parameters to initialize the encoder in a last-ditch effort to produce some useful output. Rework this process so that it is triggered by the filtergraph, which now sends a dummy frame with parameters, but no data, to the encoder, rather than the encoder reaching backwards into the filter. This approach is more in line with the natural data flow from filters to encoders and will allow to reduce encoder-filter interactions in following commits. This code is tested by fate-adpcm-ima-cunning-trunc-t2-track1, which (as confirmed by Zane) is supposed to produce empty output.
This commit is contained in:
@@ -1142,26 +1142,8 @@ void enc_flush(void)
|
||||
AVCodecContext *enc = ost->enc_ctx;
|
||||
OutputFile *of = output_files[ost->file_index];
|
||||
|
||||
if (!enc)
|
||||
continue;
|
||||
|
||||
// Try to enable encoding with no input frames.
|
||||
// Maybe we should just let encoding fail instead.
|
||||
if (!e->opened) {
|
||||
FilterGraph *fg = ost->filter->graph;
|
||||
|
||||
av_log(ost, AV_LOG_WARNING,
|
||||
"Finishing stream without any data written to it.\n");
|
||||
|
||||
if (!fg->graph)
|
||||
continue;
|
||||
|
||||
ret = enc_open(ost, NULL);
|
||||
if (ret < 0)
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO)
|
||||
if (!enc || !e->opened ||
|
||||
(enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO))
|
||||
continue;
|
||||
|
||||
ret = submit_encode_frame(of, ost, NULL);
|
||||
|
||||
Reference in New Issue
Block a user