fftools/ffmpeg_mux: allocate sq_pkt in setup_sync_queues()
This is now possible since setup_sync_queues() can interact with Muxer.
This commit is contained in:
@ -671,14 +671,6 @@ int of_muxer_init(OutputFile *of, AVFormatContext *fc,
|
|||||||
if (strcmp(of->format->name, "rtp"))
|
if (strcmp(of->format->name, "rtp"))
|
||||||
want_sdp = 0;
|
want_sdp = 0;
|
||||||
|
|
||||||
if (of->sq_mux) {
|
|
||||||
mux->sq_pkt = av_packet_alloc();
|
|
||||||
if (!mux->sq_pkt) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write the header for files with no streams */
|
/* write the header for files with no streams */
|
||||||
if (of->format->flags & AVFMT_NOSTREAMS && fc->nb_streams == 0) {
|
if (of->format->flags & AVFMT_NOSTREAMS && fc->nb_streams == 0) {
|
||||||
ret = mux_check_init(of);
|
ret = mux_check_init(of);
|
||||||
|
@ -1040,8 +1040,9 @@ loop_end:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_sync_queues(OutputFile *of, AVFormatContext *oc, int64_t buf_size_us)
|
static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_us)
|
||||||
{
|
{
|
||||||
|
OutputFile *of = &mux->of;
|
||||||
int nb_av_enc = 0, nb_interleaved = 0;
|
int nb_av_enc = 0, nb_interleaved = 0;
|
||||||
int limit_frames = 0, limit_frames_av_enc = 0;
|
int limit_frames = 0, limit_frames_av_enc = 0;
|
||||||
|
|
||||||
@ -1103,6 +1104,10 @@ static int setup_sync_queues(OutputFile *of, AVFormatContext *oc, int64_t buf_si
|
|||||||
if (!of->sq_mux)
|
if (!of->sq_mux)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
mux->sq_pkt = av_packet_alloc();
|
||||||
|
if (!mux->sq_pkt)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
for (int i = 0; i < oc->nb_streams; i++) {
|
for (int i = 0; i < oc->nb_streams; i++) {
|
||||||
OutputStream *ost = output_streams[of->ost_index + i];
|
OutputStream *ost = output_streams[of->ost_index + i];
|
||||||
enum AVMediaType type = ost->st->codecpar->codec_type;
|
enum AVMediaType type = ost->st->codecpar->codec_type;
|
||||||
@ -1573,6 +1578,7 @@ static int set_dispositions(OutputFile *of, AVFormatContext *ctx)
|
|||||||
|
|
||||||
int of_open(OptionsContext *o, const char *filename)
|
int of_open(OptionsContext *o, const char *filename)
|
||||||
{
|
{
|
||||||
|
Muxer *mux;
|
||||||
AVFormatContext *oc;
|
AVFormatContext *oc;
|
||||||
int i, j, err;
|
int i, j, err;
|
||||||
OutputFile *of;
|
OutputFile *of;
|
||||||
@ -1594,7 +1600,8 @@ int of_open(OptionsContext *o, const char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
of = allocate_array_elem(&output_files, sizeof(Muxer), &nb_output_files);
|
mux = allocate_array_elem(&output_files, sizeof(Muxer), &nb_output_files);
|
||||||
|
of = &mux->of;
|
||||||
|
|
||||||
of->index = nb_output_files - 1;
|
of->index = nb_output_files - 1;
|
||||||
of->ost_index = nb_output_streams;
|
of->ost_index = nb_output_streams;
|
||||||
@ -1869,7 +1876,7 @@ int of_open(OptionsContext *o, const char *filename)
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = setup_sync_queues(of, oc, o->shortest_buf_duration * AV_TIME_BASE);
|
err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
av_log(NULL, AV_LOG_FATAL, "Error setting up output sync queues\n");
|
av_log(NULL, AV_LOG_FATAL, "Error setting up output sync queues\n");
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
|
Reference in New Issue
Block a user