parent
2485467fa5
commit
bba2b62694
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,331 @@ |
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg. |
||||||
|
* copyright (c) 2022 Taner Sener ( tanersener gmail com ) |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of ffmpeg_mux.c file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
* |
||||||
|
* 09.2022 |
||||||
|
* -------------------------------------------------------- |
||||||
|
* - fftools_ prefix added to fftools headers |
||||||
|
* - using main_ffmpeg_return_code instead of main_return_code |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <stdio.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include "fftools_ffmpeg.h" |
||||||
|
|
||||||
|
#include "libavutil/fifo.h" |
||||||
|
#include "libavutil/intreadwrite.h" |
||||||
|
#include "libavutil/log.h" |
||||||
|
#include "libavutil/mem.h" |
||||||
|
#include "libavutil/timestamp.h" |
||||||
|
|
||||||
|
#include "libavcodec/packet.h" |
||||||
|
|
||||||
|
#include "libavformat/avformat.h" |
||||||
|
#include "libavformat/avio.h" |
||||||
|
|
||||||
|
static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others) |
||||||
|
{ |
||||||
|
int i; |
||||||
|
for (i = 0; i < nb_output_streams; i++) { |
||||||
|
OutputStream *ost2 = output_streams[i]; |
||||||
|
ost2->finished |= ost == ost2 ? this_stream : others; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, |
||||||
|
int unqueue) |
||||||
|
{ |
||||||
|
AVFormatContext *s = of->ctx; |
||||||
|
AVStream *st = ost->st; |
||||||
|
int ret; |
||||||
|
|
||||||
|
/*
|
||||||
|
* Audio encoders may split the packets -- #frames in != #packets out. |
||||||
|
* But there is no reordering, so we can limit the number of output packets |
||||||
|
* by simply dropping them here. |
||||||
|
* Counting encoded video frames needs to be done separately because of |
||||||
|
* reordering, see do_video_out(). |
||||||
|
* Do not count the packet when unqueued because it has been counted when queued. |
||||||
|
*/ |
||||||
|
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) && !unqueue) { |
||||||
|
if (ost->frame_number >= ost->max_frames) { |
||||||
|
av_packet_unref(pkt); |
||||||
|
return; |
||||||
|
} |
||||||
|
ost->frame_number++; |
||||||
|
} |
||||||
|
|
||||||
|
if (!of->header_written) { |
||||||
|
AVPacket *tmp_pkt; |
||||||
|
/* the muxer is not initialized yet, buffer the packet */ |
||||||
|
if (!av_fifo_can_write(ost->muxing_queue)) { |
||||||
|
size_t cur_size = av_fifo_can_read(ost->muxing_queue); |
||||||
|
unsigned int are_we_over_size = |
||||||
|
(ost->muxing_queue_data_size + pkt->size) > ost->muxing_queue_data_threshold; |
||||||
|
size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX; |
||||||
|
size_t new_size = FFMIN(2 * cur_size, limit); |
||||||
|
|
||||||
|
if (new_size <= cur_size) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Too many packets buffered for output stream %d:%d.\n", |
||||||
|
ost->file_index, ost->st->index); |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
ret = av_fifo_grow2(ost->muxing_queue, new_size - cur_size); |
||||||
|
if (ret < 0) |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
ret = av_packet_make_refcounted(pkt); |
||||||
|
if (ret < 0) |
||||||
|
exit_program(1); |
||||||
|
tmp_pkt = av_packet_alloc(); |
||||||
|
if (!tmp_pkt) |
||||||
|
exit_program(1); |
||||||
|
av_packet_move_ref(tmp_pkt, pkt); |
||||||
|
ost->muxing_queue_data_size += tmp_pkt->size; |
||||||
|
av_fifo_write(ost->muxing_queue, &tmp_pkt, 1); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) || |
||||||
|
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0)) |
||||||
|
pkt->pts = pkt->dts = AV_NOPTS_VALUE; |
||||||
|
|
||||||
|
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { |
||||||
|
if (ost->frame_rate.num && ost->is_cfr) { |
||||||
|
if (pkt->duration > 0) |
||||||
|
av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n"); |
||||||
|
pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), |
||||||
|
ost->mux_timebase); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base); |
||||||
|
|
||||||
|
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { |
||||||
|
if (pkt->dts != AV_NOPTS_VALUE && |
||||||
|
pkt->pts != AV_NOPTS_VALUE && |
||||||
|
pkt->dts > pkt->pts) { |
||||||
|
av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n", |
||||||
|
pkt->dts, pkt->pts, |
||||||
|
ost->file_index, ost->st->index); |
||||||
|
pkt->pts = |
||||||
|
pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1 |
||||||
|
- FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) |
||||||
|
- FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); |
||||||
|
} |
||||||
|
if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) && |
||||||
|
pkt->dts != AV_NOPTS_VALUE && |
||||||
|
ost->last_mux_dts != AV_NOPTS_VALUE) { |
||||||
|
int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); |
||||||
|
if (pkt->dts < max) { |
||||||
|
int loglevel = max - pkt->dts > 2 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG; |
||||||
|
if (exit_on_error) |
||||||
|
loglevel = AV_LOG_ERROR; |
||||||
|
av_log(s, loglevel, "Non-monotonous DTS in output stream " |
||||||
|
"%d:%d; previous: %"PRId64", current: %"PRId64"; ", |
||||||
|
ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts); |
||||||
|
if (exit_on_error) { |
||||||
|
av_log(NULL, AV_LOG_FATAL, "aborting.\n"); |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
av_log(s, loglevel, "changing to %"PRId64". This may result " |
||||||
|
"in incorrect timestamps in the output file.\n", |
||||||
|
max); |
||||||
|
if (pkt->pts >= pkt->dts) |
||||||
|
pkt->pts = FFMAX(pkt->pts, max); |
||||||
|
pkt->dts = max; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
ost->last_mux_dts = pkt->dts; |
||||||
|
|
||||||
|
ost->data_size += pkt->size; |
||||||
|
ost->packets_written++; |
||||||
|
|
||||||
|
pkt->stream_index = ost->index; |
||||||
|
|
||||||
|
if (debug_ts) { |
||||||
|
av_log(NULL, AV_LOG_INFO, "muxer <- type:%s " |
||||||
|
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s size:%d\n", |
||||||
|
av_get_media_type_string(ost->enc_ctx->codec_type), |
||||||
|
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base), |
||||||
|
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base), |
||||||
|
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ost->st->time_base), |
||||||
|
pkt->size |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_interleaved_write_frame(s, pkt); |
||||||
|
if (ret < 0) { |
||||||
|
print_error("av_interleaved_write_frame()", ret); |
||||||
|
main_ffmpeg_return_code = 1; |
||||||
|
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static int print_sdp(void) |
||||||
|
{ |
||||||
|
char sdp[16384]; |
||||||
|
int i; |
||||||
|
int j, ret; |
||||||
|
AVIOContext *sdp_pb; |
||||||
|
AVFormatContext **avc; |
||||||
|
|
||||||
|
for (i = 0; i < nb_output_files; i++) { |
||||||
|
if (!output_files[i]->header_written) |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
avc = av_malloc_array(nb_output_files, sizeof(*avc)); |
||||||
|
if (!avc) |
||||||
|
exit_program(1); |
||||||
|
for (i = 0, j = 0; i < nb_output_files; i++) { |
||||||
|
if (!strcmp(output_files[i]->ctx->oformat->name, "rtp")) { |
||||||
|
avc[j] = output_files[i]->ctx; |
||||||
|
j++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!j) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n"); |
||||||
|
ret = AVERROR(EINVAL); |
||||||
|
goto fail; |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_sdp_create(avc, j, sdp, sizeof(sdp)); |
||||||
|
if (ret < 0) |
||||||
|
goto fail; |
||||||
|
|
||||||
|
if (!sdp_filename) { |
||||||
|
printf("SDP:\n%s\n", sdp); |
||||||
|
fflush(stdout); |
||||||
|
} else { |
||||||
|
ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename); |
||||||
|
goto fail; |
||||||
|
} |
||||||
|
|
||||||
|
avio_print(sdp_pb, sdp); |
||||||
|
avio_closep(&sdp_pb); |
||||||
|
av_freep(&sdp_filename); |
||||||
|
} |
||||||
|
|
||||||
|
fail: |
||||||
|
av_freep(&avc); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
/* open the muxer when all the streams are initialized */ |
||||||
|
int of_check_init(OutputFile *of) |
||||||
|
{ |
||||||
|
int ret, i; |
||||||
|
|
||||||
|
for (i = 0; i < of->ctx->nb_streams; i++) { |
||||||
|
OutputStream *ost = output_streams[of->ost_index + i]; |
||||||
|
if (!ost->initialized) |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
ret = avformat_write_header(of->ctx, &of->opts); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Could not write header for output file #%d " |
||||||
|
"(incorrect codec parameters ?): %s\n", |
||||||
|
of->index, av_err2str(ret)); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
//assert_avoptions(of->opts);
|
||||||
|
of->header_written = 1; |
||||||
|
|
||||||
|
av_dump_format(of->ctx, of->index, of->ctx->url, 1); |
||||||
|
nb_output_dumped++; |
||||||
|
|
||||||
|
if (sdp_filename || want_sdp) { |
||||||
|
ret = print_sdp(); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error writing the SDP.\n"); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* flush the muxing queues */ |
||||||
|
for (i = 0; i < of->ctx->nb_streams; i++) { |
||||||
|
OutputStream *ost = output_streams[of->ost_index + i]; |
||||||
|
AVPacket *pkt; |
||||||
|
|
||||||
|
/* try to improve muxing time_base (only possible if nothing has been written yet) */ |
||||||
|
if (!av_fifo_can_read(ost->muxing_queue)) |
||||||
|
ost->mux_timebase = ost->st->time_base; |
||||||
|
|
||||||
|
while (av_fifo_read(ost->muxing_queue, &pkt, 1) >= 0) { |
||||||
|
ost->muxing_queue_data_size -= pkt->size; |
||||||
|
of_write_packet(of, pkt, ost, 1); |
||||||
|
av_packet_free(&pkt); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
int of_write_trailer(OutputFile *of) |
||||||
|
{ |
||||||
|
int ret; |
||||||
|
|
||||||
|
if (!of->header_written) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Nothing was written into output file %d (%s), because " |
||||||
|
"at least one of its streams received no packets.\n", |
||||||
|
of->index, of->ctx->url); |
||||||
|
return AVERROR(EINVAL); |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_write_trailer(of->ctx); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret)); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
void of_close(OutputFile **pof) |
||||||
|
{ |
||||||
|
OutputFile *of = *pof; |
||||||
|
AVFormatContext *s; |
||||||
|
|
||||||
|
if (!of) |
||||||
|
return; |
||||||
|
|
||||||
|
s = of->ctx; |
||||||
|
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE)) |
||||||
|
avio_closep(&s->pb); |
||||||
|
avformat_free_context(s); |
||||||
|
av_dict_free(&of->opts); |
||||||
|
|
||||||
|
av_freep(pof); |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@ |
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg. |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of fopen_utf8.h file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef FFTOOLS_FOPEN_UTF8_H |
||||||
|
#define FFTOOLS_FOPEN_UTF8_H |
||||||
|
|
||||||
|
#include <stdio.h> |
||||||
|
|
||||||
|
/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8,
|
||||||
|
* except that it doesn't set O_CLOEXEC, and that it isn't exported |
||||||
|
* from a different library. (On Windows, each DLL might use a different |
||||||
|
* CRT, and FILE* handles can't be shared across them.) */ |
||||||
|
|
||||||
|
#ifdef _WIN32 |
||||||
|
#include "libavutil/wchar_filename.h" |
||||||
|
|
||||||
|
static inline FILE *fopen_utf8(const char *path_utf8, const char *mode) |
||||||
|
{ |
||||||
|
wchar_t *path_w, *mode_w; |
||||||
|
FILE *f; |
||||||
|
|
||||||
|
/* convert UTF-8 to wide chars */ |
||||||
|
if (get_extended_win32_path(path_utf8, &path_w)) /* This sets errno on error. */ |
||||||
|
return NULL; |
||||||
|
if (!path_w) |
||||||
|
goto fallback; |
||||||
|
|
||||||
|
if (utf8towchar(mode, &mode_w)) |
||||||
|
return NULL; |
||||||
|
if (!mode_w) { |
||||||
|
/* If failing to interpret the mode string as utf8, it is an invalid
|
||||||
|
* parameter. */ |
||||||
|
av_freep(&path_w); |
||||||
|
errno = EINVAL; |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
|
||||||
|
f = _wfopen(path_w, mode_w); |
||||||
|
av_freep(&path_w); |
||||||
|
av_freep(&mode_w); |
||||||
|
|
||||||
|
return f; |
||||||
|
fallback: |
||||||
|
/* path may be in CP_ACP */ |
||||||
|
return fopen(path_utf8, mode); |
||||||
|
} |
||||||
|
|
||||||
|
#else |
||||||
|
|
||||||
|
static inline FILE *fopen_utf8(const char *path, const char *mode) |
||||||
|
{ |
||||||
|
return fopen(path, mode); |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* FFTOOLS_FOPEN_UTF8_H */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,202 @@ |
|||||||
|
/*
|
||||||
|
* Option handlers shared between the tools. |
||||||
|
* copyright (c) 2022 Taner Sener ( tanersener gmail com ) |
||||||
|
* |
||||||
|
* This file is part of FFmpeg. |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of opt_common.h file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
* |
||||||
|
* 09.2022 |
||||||
|
* -------------------------------------------------------- |
||||||
|
* - CMDUTILS_COMMON_OPTIONS and CMDUTILS_COMMON_OPTIONS_AVDEVICE defines dropped |
||||||
|
* - fftools_ prefix added to fftools headers |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef FFTOOLS_OPT_COMMON_H |
||||||
|
#define FFTOOLS_OPT_COMMON_H |
||||||
|
|
||||||
|
#include "config.h" |
||||||
|
|
||||||
|
#include "fftools_cmdutils.h" |
||||||
|
|
||||||
|
#if CONFIG_AVDEVICE |
||||||
|
/**
|
||||||
|
* Print a listing containing autodetected sinks of the output device. |
||||||
|
* Device name with options may be passed as an argument to limit results. |
||||||
|
*/ |
||||||
|
int show_sinks(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing autodetected sources of the input device. |
||||||
|
* Device name with options may be passed as an argument to limit results. |
||||||
|
*/ |
||||||
|
int show_sources(void *optctx, const char *opt, const char *arg); |
||||||
|
#endif |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the license of the program to stdout. The license depends on |
||||||
|
* the license of the libraries compiled into the program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_license(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic -h handler common to all fftools. |
||||||
|
*/ |
||||||
|
int show_help(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the version of the program to stdout. The version message |
||||||
|
* depends on the current versions of the repository and of the libav* |
||||||
|
* libraries. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_version(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the build configuration of the program to stdout. The contents |
||||||
|
* depend on the definition of FFMPEG_CONFIGURATION. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_buildconf(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the formats supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_formats(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the muxers supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_muxers(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the demuxer supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_demuxers(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the devices supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_devices(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the codecs supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_codecs(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the decoders supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_decoders(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the encoders supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_encoders(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the bit stream filters supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_bsfs(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the protocols supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_protocols(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the filters supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_filters(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the pixel formats supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_pix_fmts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the standard channel layouts supported by |
||||||
|
* the program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_layouts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the sample formats supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_sample_fmts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all supported stream dispositions. |
||||||
|
*/ |
||||||
|
int show_dispositions(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the color names and values recognized |
||||||
|
* by the program. |
||||||
|
*/ |
||||||
|
int show_colors(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the libav* libraries log level. |
||||||
|
*/ |
||||||
|
int opt_loglevel(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
int opt_report(void *optctx, const char *opt, const char *arg); |
||||||
|
int init_report(const char *env, FILE **file); |
||||||
|
|
||||||
|
int opt_max_alloc(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the cpuflags. |
||||||
|
*/ |
||||||
|
int opt_cpuflags(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the cpucount. |
||||||
|
*/ |
||||||
|
int opt_cpucount(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
#endif /* FFTOOLS_OPT_COMMON_H */ |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,332 @@ |
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg. |
||||||
|
* copyright (c) 2022 Taner Sener ( tanersener gmail com ) |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of ffmpeg_mux.c file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
* |
||||||
|
* 09.2022 |
||||||
|
* -------------------------------------------------------- |
||||||
|
* - fftools_ prefix added to fftools headers |
||||||
|
* - using main_ffmpeg_return_code instead of main_return_code |
||||||
|
* - printf replaced with av_log statements |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <stdio.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include "fftools_ffmpeg.h" |
||||||
|
|
||||||
|
#include "libavutil/fifo.h" |
||||||
|
#include "libavutil/intreadwrite.h" |
||||||
|
#include "libavutil/log.h" |
||||||
|
#include "libavutil/mem.h" |
||||||
|
#include "libavutil/timestamp.h" |
||||||
|
|
||||||
|
#include "libavcodec/packet.h" |
||||||
|
|
||||||
|
#include "libavformat/avformat.h" |
||||||
|
#include "libavformat/avio.h" |
||||||
|
|
||||||
|
static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others) |
||||||
|
{ |
||||||
|
int i; |
||||||
|
for (i = 0; i < nb_output_streams; i++) { |
||||||
|
OutputStream *ost2 = output_streams[i]; |
||||||
|
ost2->finished |= ost == ost2 ? this_stream : others; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, |
||||||
|
int unqueue) |
||||||
|
{ |
||||||
|
AVFormatContext *s = of->ctx; |
||||||
|
AVStream *st = ost->st; |
||||||
|
int ret; |
||||||
|
|
||||||
|
/*
|
||||||
|
* Audio encoders may split the packets -- #frames in != #packets out. |
||||||
|
* But there is no reordering, so we can limit the number of output packets |
||||||
|
* by simply dropping them here. |
||||||
|
* Counting encoded video frames needs to be done separately because of |
||||||
|
* reordering, see do_video_out(). |
||||||
|
* Do not count the packet when unqueued because it has been counted when queued. |
||||||
|
*/ |
||||||
|
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) && !unqueue) { |
||||||
|
if (ost->frame_number >= ost->max_frames) { |
||||||
|
av_packet_unref(pkt); |
||||||
|
return; |
||||||
|
} |
||||||
|
ost->frame_number++; |
||||||
|
} |
||||||
|
|
||||||
|
if (!of->header_written) { |
||||||
|
AVPacket *tmp_pkt; |
||||||
|
/* the muxer is not initialized yet, buffer the packet */ |
||||||
|
if (!av_fifo_can_write(ost->muxing_queue)) { |
||||||
|
size_t cur_size = av_fifo_can_read(ost->muxing_queue); |
||||||
|
unsigned int are_we_over_size = |
||||||
|
(ost->muxing_queue_data_size + pkt->size) > ost->muxing_queue_data_threshold; |
||||||
|
size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX; |
||||||
|
size_t new_size = FFMIN(2 * cur_size, limit); |
||||||
|
|
||||||
|
if (new_size <= cur_size) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Too many packets buffered for output stream %d:%d.\n", |
||||||
|
ost->file_index, ost->st->index); |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
ret = av_fifo_grow2(ost->muxing_queue, new_size - cur_size); |
||||||
|
if (ret < 0) |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
ret = av_packet_make_refcounted(pkt); |
||||||
|
if (ret < 0) |
||||||
|
exit_program(1); |
||||||
|
tmp_pkt = av_packet_alloc(); |
||||||
|
if (!tmp_pkt) |
||||||
|
exit_program(1); |
||||||
|
av_packet_move_ref(tmp_pkt, pkt); |
||||||
|
ost->muxing_queue_data_size += tmp_pkt->size; |
||||||
|
av_fifo_write(ost->muxing_queue, &tmp_pkt, 1); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) || |
||||||
|
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0)) |
||||||
|
pkt->pts = pkt->dts = AV_NOPTS_VALUE; |
||||||
|
|
||||||
|
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { |
||||||
|
if (ost->frame_rate.num && ost->is_cfr) { |
||||||
|
if (pkt->duration > 0) |
||||||
|
av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n"); |
||||||
|
pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), |
||||||
|
ost->mux_timebase); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base); |
||||||
|
|
||||||
|
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { |
||||||
|
if (pkt->dts != AV_NOPTS_VALUE && |
||||||
|
pkt->pts != AV_NOPTS_VALUE && |
||||||
|
pkt->dts > pkt->pts) { |
||||||
|
av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n", |
||||||
|
pkt->dts, pkt->pts, |
||||||
|
ost->file_index, ost->st->index); |
||||||
|
pkt->pts = |
||||||
|
pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1 |
||||||
|
- FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) |
||||||
|
- FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); |
||||||
|
} |
||||||
|
if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) && |
||||||
|
pkt->dts != AV_NOPTS_VALUE && |
||||||
|
ost->last_mux_dts != AV_NOPTS_VALUE) { |
||||||
|
int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); |
||||||
|
if (pkt->dts < max) { |
||||||
|
int loglevel = max - pkt->dts > 2 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG; |
||||||
|
if (exit_on_error) |
||||||
|
loglevel = AV_LOG_ERROR; |
||||||
|
av_log(s, loglevel, "Non-monotonous DTS in output stream " |
||||||
|
"%d:%d; previous: %"PRId64", current: %"PRId64"; ", |
||||||
|
ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts); |
||||||
|
if (exit_on_error) { |
||||||
|
av_log(NULL, AV_LOG_FATAL, "aborting.\n"); |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
av_log(s, loglevel, "changing to %"PRId64". This may result " |
||||||
|
"in incorrect timestamps in the output file.\n", |
||||||
|
max); |
||||||
|
if (pkt->pts >= pkt->dts) |
||||||
|
pkt->pts = FFMAX(pkt->pts, max); |
||||||
|
pkt->dts = max; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
ost->last_mux_dts = pkt->dts; |
||||||
|
|
||||||
|
ost->data_size += pkt->size; |
||||||
|
ost->packets_written++; |
||||||
|
|
||||||
|
pkt->stream_index = ost->index; |
||||||
|
|
||||||
|
if (debug_ts) { |
||||||
|
av_log(NULL, AV_LOG_INFO, "muxer <- type:%s " |
||||||
|
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s size:%d\n", |
||||||
|
av_get_media_type_string(ost->enc_ctx->codec_type), |
||||||
|
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base), |
||||||
|
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base), |
||||||
|
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ost->st->time_base), |
||||||
|
pkt->size |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_interleaved_write_frame(s, pkt); |
||||||
|
if (ret < 0) { |
||||||
|
print_error("av_interleaved_write_frame()", ret); |
||||||
|
main_ffmpeg_return_code = 1; |
||||||
|
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static int print_sdp(void) |
||||||
|
{ |
||||||
|
char sdp[16384]; |
||||||
|
int i; |
||||||
|
int j, ret; |
||||||
|
AVIOContext *sdp_pb; |
||||||
|
AVFormatContext **avc; |
||||||
|
|
||||||
|
for (i = 0; i < nb_output_files; i++) { |
||||||
|
if (!output_files[i]->header_written) |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
avc = av_malloc_array(nb_output_files, sizeof(*avc)); |
||||||
|
if (!avc) |
||||||
|
exit_program(1); |
||||||
|
for (i = 0, j = 0; i < nb_output_files; i++) { |
||||||
|
if (!strcmp(output_files[i]->ctx->oformat->name, "rtp")) { |
||||||
|
avc[j] = output_files[i]->ctx; |
||||||
|
j++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!j) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n"); |
||||||
|
ret = AVERROR(EINVAL); |
||||||
|
goto fail; |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_sdp_create(avc, j, sdp, sizeof(sdp)); |
||||||
|
if (ret < 0) |
||||||
|
goto fail; |
||||||
|
|
||||||
|
if (!sdp_filename) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "SDP:\n%s\n", sdp); |
||||||
|
fflush(stdout); |
||||||
|
} else { |
||||||
|
ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename); |
||||||
|
goto fail; |
||||||
|
} |
||||||
|
|
||||||
|
avio_print(sdp_pb, sdp); |
||||||
|
avio_closep(&sdp_pb); |
||||||
|
av_freep(&sdp_filename); |
||||||
|
} |
||||||
|
|
||||||
|
fail: |
||||||
|
av_freep(&avc); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
/* open the muxer when all the streams are initialized */ |
||||||
|
int of_check_init(OutputFile *of) |
||||||
|
{ |
||||||
|
int ret, i; |
||||||
|
|
||||||
|
for (i = 0; i < of->ctx->nb_streams; i++) { |
||||||
|
OutputStream *ost = output_streams[of->ost_index + i]; |
||||||
|
if (!ost->initialized) |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
ret = avformat_write_header(of->ctx, &of->opts); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Could not write header for output file #%d " |
||||||
|
"(incorrect codec parameters ?): %s\n", |
||||||
|
of->index, av_err2str(ret)); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
//assert_avoptions(of->opts);
|
||||||
|
of->header_written = 1; |
||||||
|
|
||||||
|
av_dump_format(of->ctx, of->index, of->ctx->url, 1); |
||||||
|
nb_output_dumped++; |
||||||
|
|
||||||
|
if (sdp_filename || want_sdp) { |
||||||
|
ret = print_sdp(); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error writing the SDP.\n"); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* flush the muxing queues */ |
||||||
|
for (i = 0; i < of->ctx->nb_streams; i++) { |
||||||
|
OutputStream *ost = output_streams[of->ost_index + i]; |
||||||
|
AVPacket *pkt; |
||||||
|
|
||||||
|
/* try to improve muxing time_base (only possible if nothing has been written yet) */ |
||||||
|
if (!av_fifo_can_read(ost->muxing_queue)) |
||||||
|
ost->mux_timebase = ost->st->time_base; |
||||||
|
|
||||||
|
while (av_fifo_read(ost->muxing_queue, &pkt, 1) >= 0) { |
||||||
|
ost->muxing_queue_data_size -= pkt->size; |
||||||
|
of_write_packet(of, pkt, ost, 1); |
||||||
|
av_packet_free(&pkt); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
int of_write_trailer(OutputFile *of) |
||||||
|
{ |
||||||
|
int ret; |
||||||
|
|
||||||
|
if (!of->header_written) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Nothing was written into output file %d (%s), because " |
||||||
|
"at least one of its streams received no packets.\n", |
||||||
|
of->index, of->ctx->url); |
||||||
|
return AVERROR(EINVAL); |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_write_trailer(of->ctx); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret)); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
void of_close(OutputFile **pof) |
||||||
|
{ |
||||||
|
OutputFile *of = *pof; |
||||||
|
AVFormatContext *s; |
||||||
|
|
||||||
|
if (!of) |
||||||
|
return; |
||||||
|
|
||||||
|
s = of->ctx; |
||||||
|
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE)) |
||||||
|
avio_closep(&s->pb); |
||||||
|
avformat_free_context(s); |
||||||
|
av_dict_free(&of->opts); |
||||||
|
|
||||||
|
av_freep(pof); |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -1,177 +0,0 @@ |
|||||||
/*
|
|
||||||
* This file is part of FFmpeg. |
|
||||||
* |
|
||||||
* FFmpeg is free software; you can redistribute it and/or |
|
||||||
* modify it under the terms of the GNU Lesser General Public |
|
||||||
* License as published by the Free Software Foundation; either |
|
||||||
* version 2.1 of the License, or (at your option) any later version. |
|
||||||
* |
|
||||||
* FFmpeg is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
* Lesser General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public |
|
||||||
* License along with FFmpeg; if not, write to the Free Software |
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "config.h" |
|
||||||
|
|
||||||
#if HAVE_UTGETOSTYPEFROMSTRING |
|
||||||
#include <CoreServices/CoreServices.h> |
|
||||||
#endif |
|
||||||
|
|
||||||
#include "libavcodec/avcodec.h" |
|
||||||
#include "libavcodec/videotoolbox.h" |
|
||||||
#include "libavutil/imgutils.h" |
|
||||||
#include "fftools_ffmpeg.h" |
|
||||||
|
|
||||||
typedef struct VTContext { |
|
||||||
AVFrame *tmp_frame; |
|
||||||
int log_once; |
|
||||||
} VTContext; |
|
||||||
|
|
||||||
__thread char *videotoolbox_pixfmt; |
|
||||||
|
|
||||||
static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame) |
|
||||||
{ |
|
||||||
InputStream *ist = s->opaque; |
|
||||||
VTContext *vt = ist->hwaccel_ctx; |
|
||||||
CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->data[3]; |
|
||||||
OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf); |
|
||||||
CVReturn err; |
|
||||||
uint8_t *data[4] = { 0 }; |
|
||||||
int linesize[4] = { 0 }; |
|
||||||
int planes, ret, i; |
|
||||||
|
|
||||||
if (frame->format == ist->hwaccel_output_format) { |
|
||||||
av_log_once(s, AV_LOG_INFO, AV_LOG_TRACE, &vt->log_once, |
|
||||||
"There is no video filter for videotoolbox pix_fmt now, remove the " |
|
||||||
"-hwaccel_output_format option if video filter doesn't work\n"); |
|
||||||
return 0; |
|
||||||
} |
|
||||||
|
|
||||||
av_frame_unref(vt->tmp_frame); |
|
||||||
|
|
||||||
switch (pixel_format) { |
|
||||||
case kCVPixelFormatType_420YpCbCr8Planar: vt->tmp_frame->format = AV_PIX_FMT_YUV420P; break; |
|
||||||
case kCVPixelFormatType_422YpCbCr8: vt->tmp_frame->format = AV_PIX_FMT_UYVY422; break; |
|
||||||
case kCVPixelFormatType_32BGRA: vt->tmp_frame->format = AV_PIX_FMT_BGRA; break; |
|
||||||
#ifdef kCFCoreFoundationVersionNumber10_7 |
|
||||||
case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: |
|
||||||
case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_NV12; break; |
|
||||||
#endif |
|
||||||
#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE |
|
||||||
case kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange: |
|
||||||
case kCVPixelFormatType_420YpCbCr10BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_P010; break; |
|
||||||
#endif |
|
||||||
default: |
|
||||||
av_log(NULL, AV_LOG_ERROR, |
|
||||||
"%s: Unsupported pixel format: %s\n", |
|
||||||
av_fourcc2str(s->codec_tag), videotoolbox_pixfmt); |
|
||||||
return AVERROR(ENOSYS); |
|
||||||
} |
|
||||||
|
|
||||||
vt->tmp_frame->width = frame->width; |
|
||||||
vt->tmp_frame->height = frame->height; |
|
||||||
ret = av_frame_get_buffer(vt->tmp_frame, 0); |
|
||||||
if (ret < 0) |
|
||||||
return ret; |
|
||||||
|
|
||||||
err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); |
|
||||||
if (err != kCVReturnSuccess) { |
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error locking the pixel buffer.\n"); |
|
||||||
return AVERROR_UNKNOWN; |
|
||||||
} |
|
||||||
|
|
||||||
if (CVPixelBufferIsPlanar(pixbuf)) { |
|
||||||
|
|
||||||
planes = CVPixelBufferGetPlaneCount(pixbuf); |
|
||||||
for (i = 0; i < planes; i++) { |
|
||||||
data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i); |
|
||||||
linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i); |
|
||||||
} |
|
||||||
} else { |
|
||||||
data[0] = CVPixelBufferGetBaseAddress(pixbuf); |
|
||||||
linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf); |
|
||||||
} |
|
||||||
|
|
||||||
av_image_copy(vt->tmp_frame->data, vt->tmp_frame->linesize, |
|
||||||
(const uint8_t **)data, linesize, vt->tmp_frame->format, |
|
||||||
frame->width, frame->height); |
|
||||||
|
|
||||||
ret = av_frame_copy_props(vt->tmp_frame, frame); |
|
||||||
CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); |
|
||||||
if (ret < 0) |
|
||||||
return ret; |
|
||||||
|
|
||||||
av_frame_unref(frame); |
|
||||||
av_frame_move_ref(frame, vt->tmp_frame); |
|
||||||
|
|
||||||
return 0; |
|
||||||
} |
|
||||||
|
|
||||||
static void videotoolbox_uninit(AVCodecContext *s) |
|
||||||
{ |
|
||||||
InputStream *ist = s->opaque; |
|
||||||
VTContext *vt = ist->hwaccel_ctx; |
|
||||||
|
|
||||||
ist->hwaccel_uninit = NULL; |
|
||||||
ist->hwaccel_retrieve_data = NULL; |
|
||||||
|
|
||||||
av_frame_free(&vt->tmp_frame); |
|
||||||
|
|
||||||
av_videotoolbox_default_free(s); |
|
||||||
av_freep(&ist->hwaccel_ctx); |
|
||||||
} |
|
||||||
|
|
||||||
int videotoolbox_init(AVCodecContext *s) |
|
||||||
{ |
|
||||||
InputStream *ist = s->opaque; |
|
||||||
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; |
|
||||||
int ret = 0; |
|
||||||
VTContext *vt; |
|
||||||
|
|
||||||
vt = av_mallocz(sizeof(*vt)); |
|
||||||
if (!vt) |
|
||||||
return AVERROR(ENOMEM); |
|
||||||
|
|
||||||
ist->hwaccel_ctx = vt; |
|
||||||
ist->hwaccel_uninit = videotoolbox_uninit; |
|
||||||
ist->hwaccel_retrieve_data = videotoolbox_retrieve_data; |
|
||||||
|
|
||||||
vt->tmp_frame = av_frame_alloc(); |
|
||||||
if (!vt->tmp_frame) { |
|
||||||
ret = AVERROR(ENOMEM); |
|
||||||
goto fail; |
|
||||||
} |
|
||||||
|
|
||||||
// TODO: reindent
|
|
||||||
if (!videotoolbox_pixfmt) { |
|
||||||
ret = av_videotoolbox_default_init(s); |
|
||||||
} else { |
|
||||||
AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context(); |
|
||||||
CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault, |
|
||||||
videotoolbox_pixfmt, |
|
||||||
kCFStringEncodingUTF8); |
|
||||||
#if HAVE_UTGETOSTYPEFROMSTRING |
|
||||||
vtctx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str); |
|
||||||
#else |
|
||||||
av_log(s, loglevel, "UTGetOSTypeFromString() is not available " |
|
||||||
"on this platform, %s pixel format can not be honored from " |
|
||||||
"the command line\n", videotoolbox_pixfmt); |
|
||||||
#endif |
|
||||||
ret = av_videotoolbox_default_init2(s, vtctx); |
|
||||||
CFRelease(pixfmt_str); |
|
||||||
} |
|
||||||
if (ret < 0) { |
|
||||||
av_log(NULL, loglevel, "Error creating Videotoolbox decoder.\n"); |
|
||||||
goto fail; |
|
||||||
} |
|
||||||
|
|
||||||
return 0; |
|
||||||
fail: |
|
||||||
videotoolbox_uninit(s); |
|
||||||
return ret; |
|
||||||
} |
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@ |
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg. |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of fopen_utf8.h file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef FFTOOLS_FOPEN_UTF8_H |
||||||
|
#define FFTOOLS_FOPEN_UTF8_H |
||||||
|
|
||||||
|
#include <stdio.h> |
||||||
|
|
||||||
|
/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8,
|
||||||
|
* except that it doesn't set O_CLOEXEC, and that it isn't exported |
||||||
|
* from a different library. (On Windows, each DLL might use a different |
||||||
|
* CRT, and FILE* handles can't be shared across them.) */ |
||||||
|
|
||||||
|
#ifdef _WIN32 |
||||||
|
#include "libavutil/wchar_filename.h" |
||||||
|
|
||||||
|
static inline FILE *fopen_utf8(const char *path_utf8, const char *mode) |
||||||
|
{ |
||||||
|
wchar_t *path_w, *mode_w; |
||||||
|
FILE *f; |
||||||
|
|
||||||
|
/* convert UTF-8 to wide chars */ |
||||||
|
if (get_extended_win32_path(path_utf8, &path_w)) /* This sets errno on error. */ |
||||||
|
return NULL; |
||||||
|
if (!path_w) |
||||||
|
goto fallback; |
||||||
|
|
||||||
|
if (utf8towchar(mode, &mode_w)) |
||||||
|
return NULL; |
||||||
|
if (!mode_w) { |
||||||
|
/* If failing to interpret the mode string as utf8, it is an invalid
|
||||||
|
* parameter. */ |
||||||
|
av_freep(&path_w); |
||||||
|
errno = EINVAL; |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
|
||||||
|
f = _wfopen(path_w, mode_w); |
||||||
|
av_freep(&path_w); |
||||||
|
av_freep(&mode_w); |
||||||
|
|
||||||
|
return f; |
||||||
|
fallback: |
||||||
|
/* path may be in CP_ACP */ |
||||||
|
return fopen(path_utf8, mode); |
||||||
|
} |
||||||
|
|
||||||
|
#else |
||||||
|
|
||||||
|
static inline FILE *fopen_utf8(const char *path, const char *mode) |
||||||
|
{ |
||||||
|
return fopen(path, mode); |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* FFTOOLS_FOPEN_UTF8_H */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,202 @@ |
|||||||
|
/*
|
||||||
|
* Option handlers shared between the tools. |
||||||
|
* copyright (c) 2022 Taner Sener ( tanersener gmail com ) |
||||||
|
* |
||||||
|
* This file is part of FFmpeg. |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of opt_common.h file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
* |
||||||
|
* 09.2022 |
||||||
|
* -------------------------------------------------------- |
||||||
|
* - CMDUTILS_COMMON_OPTIONS and CMDUTILS_COMMON_OPTIONS_AVDEVICE defines dropped |
||||||
|
* - fftools_ prefix added to fftools headers |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef FFTOOLS_OPT_COMMON_H |
||||||
|
#define FFTOOLS_OPT_COMMON_H |
||||||
|
|
||||||
|
#include "config.h" |
||||||
|
|
||||||
|
#include "fftools_cmdutils.h" |
||||||
|
|
||||||
|
#if CONFIG_AVDEVICE |
||||||
|
/**
|
||||||
|
* Print a listing containing autodetected sinks of the output device. |
||||||
|
* Device name with options may be passed as an argument to limit results. |
||||||
|
*/ |
||||||
|
int show_sinks(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing autodetected sources of the input device. |
||||||
|
* Device name with options may be passed as an argument to limit results. |
||||||
|
*/ |
||||||
|
int show_sources(void *optctx, const char *opt, const char *arg); |
||||||
|
#endif |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the license of the program to stdout. The license depends on |
||||||
|
* the license of the libraries compiled into the program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_license(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic -h handler common to all fftools. |
||||||
|
*/ |
||||||
|
int show_help(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the version of the program to stdout. The version message |
||||||
|
* depends on the current versions of the repository and of the libav* |
||||||
|
* libraries. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_version(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the build configuration of the program to stdout. The contents |
||||||
|
* depend on the definition of FFMPEG_CONFIGURATION. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_buildconf(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the formats supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_formats(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the muxers supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_muxers(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the demuxer supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_demuxers(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the devices supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_devices(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the codecs supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_codecs(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the decoders supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_decoders(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the encoders supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_encoders(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the bit stream filters supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_bsfs(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the protocols supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_protocols(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the filters supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_filters(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the pixel formats supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_pix_fmts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the standard channel layouts supported by |
||||||
|
* the program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_layouts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the sample formats supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_sample_fmts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all supported stream dispositions. |
||||||
|
*/ |
||||||
|
int show_dispositions(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the color names and values recognized |
||||||
|
* by the program. |
||||||
|
*/ |
||||||
|
int show_colors(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the libav* libraries log level. |
||||||
|
*/ |
||||||
|
int opt_loglevel(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
int opt_report(void *optctx, const char *opt, const char *arg); |
||||||
|
int init_report(const char *env, FILE **file); |
||||||
|
|
||||||
|
int opt_max_alloc(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the cpuflags. |
||||||
|
*/ |
||||||
|
int opt_cpuflags(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the cpucount. |
||||||
|
*/ |
||||||
|
int opt_cpucount(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
#endif /* FFTOOLS_OPT_COMMON_H */ |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,331 @@ |
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg. |
||||||
|
* copyright (c) 2022 Taner Sener ( tanersener gmail com ) |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of ffmpeg_mux.c file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
* |
||||||
|
* 09.2022 |
||||||
|
* -------------------------------------------------------- |
||||||
|
* - fftools_ prefix added to fftools headers |
||||||
|
* - using main_ffmpeg_return_code instead of main_return_code |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <stdio.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include "fftools_ffmpeg.h" |
||||||
|
|
||||||
|
#include "libavutil/fifo.h" |
||||||
|
#include "libavutil/intreadwrite.h" |
||||||
|
#include "libavutil/log.h" |
||||||
|
#include "libavutil/mem.h" |
||||||
|
#include "libavutil/timestamp.h" |
||||||
|
|
||||||
|
#include "libavcodec/packet.h" |
||||||
|
|
||||||
|
#include "libavformat/avformat.h" |
||||||
|
#include "libavformat/avio.h" |
||||||
|
|
||||||
|
static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others) |
||||||
|
{ |
||||||
|
int i; |
||||||
|
for (i = 0; i < nb_output_streams; i++) { |
||||||
|
OutputStream *ost2 = output_streams[i]; |
||||||
|
ost2->finished |= ost == ost2 ? this_stream : others; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, |
||||||
|
int unqueue) |
||||||
|
{ |
||||||
|
AVFormatContext *s = of->ctx; |
||||||
|
AVStream *st = ost->st; |
||||||
|
int ret; |
||||||
|
|
||||||
|
/*
|
||||||
|
* Audio encoders may split the packets -- #frames in != #packets out. |
||||||
|
* But there is no reordering, so we can limit the number of output packets |
||||||
|
* by simply dropping them here. |
||||||
|
* Counting encoded video frames needs to be done separately because of |
||||||
|
* reordering, see do_video_out(). |
||||||
|
* Do not count the packet when unqueued because it has been counted when queued. |
||||||
|
*/ |
||||||
|
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) && !unqueue) { |
||||||
|
if (ost->frame_number >= ost->max_frames) { |
||||||
|
av_packet_unref(pkt); |
||||||
|
return; |
||||||
|
} |
||||||
|
ost->frame_number++; |
||||||
|
} |
||||||
|
|
||||||
|
if (!of->header_written) { |
||||||
|
AVPacket *tmp_pkt; |
||||||
|
/* the muxer is not initialized yet, buffer the packet */ |
||||||
|
if (!av_fifo_can_write(ost->muxing_queue)) { |
||||||
|
size_t cur_size = av_fifo_can_read(ost->muxing_queue); |
||||||
|
unsigned int are_we_over_size = |
||||||
|
(ost->muxing_queue_data_size + pkt->size) > ost->muxing_queue_data_threshold; |
||||||
|
size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX; |
||||||
|
size_t new_size = FFMIN(2 * cur_size, limit); |
||||||
|
|
||||||
|
if (new_size <= cur_size) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Too many packets buffered for output stream %d:%d.\n", |
||||||
|
ost->file_index, ost->st->index); |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
ret = av_fifo_grow2(ost->muxing_queue, new_size - cur_size); |
||||||
|
if (ret < 0) |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
ret = av_packet_make_refcounted(pkt); |
||||||
|
if (ret < 0) |
||||||
|
exit_program(1); |
||||||
|
tmp_pkt = av_packet_alloc(); |
||||||
|
if (!tmp_pkt) |
||||||
|
exit_program(1); |
||||||
|
av_packet_move_ref(tmp_pkt, pkt); |
||||||
|
ost->muxing_queue_data_size += tmp_pkt->size; |
||||||
|
av_fifo_write(ost->muxing_queue, &tmp_pkt, 1); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) || |
||||||
|
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0)) |
||||||
|
pkt->pts = pkt->dts = AV_NOPTS_VALUE; |
||||||
|
|
||||||
|
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { |
||||||
|
if (ost->frame_rate.num && ost->is_cfr) { |
||||||
|
if (pkt->duration > 0) |
||||||
|
av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n"); |
||||||
|
pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), |
||||||
|
ost->mux_timebase); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base); |
||||||
|
|
||||||
|
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { |
||||||
|
if (pkt->dts != AV_NOPTS_VALUE && |
||||||
|
pkt->pts != AV_NOPTS_VALUE && |
||||||
|
pkt->dts > pkt->pts) { |
||||||
|
av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n", |
||||||
|
pkt->dts, pkt->pts, |
||||||
|
ost->file_index, ost->st->index); |
||||||
|
pkt->pts = |
||||||
|
pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1 |
||||||
|
- FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) |
||||||
|
- FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); |
||||||
|
} |
||||||
|
if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) && |
||||||
|
pkt->dts != AV_NOPTS_VALUE && |
||||||
|
ost->last_mux_dts != AV_NOPTS_VALUE) { |
||||||
|
int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); |
||||||
|
if (pkt->dts < max) { |
||||||
|
int loglevel = max - pkt->dts > 2 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG; |
||||||
|
if (exit_on_error) |
||||||
|
loglevel = AV_LOG_ERROR; |
||||||
|
av_log(s, loglevel, "Non-monotonous DTS in output stream " |
||||||
|
"%d:%d; previous: %"PRId64", current: %"PRId64"; ", |
||||||
|
ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts); |
||||||
|
if (exit_on_error) { |
||||||
|
av_log(NULL, AV_LOG_FATAL, "aborting.\n"); |
||||||
|
exit_program(1); |
||||||
|
} |
||||||
|
av_log(s, loglevel, "changing to %"PRId64". This may result " |
||||||
|
"in incorrect timestamps in the output file.\n", |
||||||
|
max); |
||||||
|
if (pkt->pts >= pkt->dts) |
||||||
|
pkt->pts = FFMAX(pkt->pts, max); |
||||||
|
pkt->dts = max; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
ost->last_mux_dts = pkt->dts; |
||||||
|
|
||||||
|
ost->data_size += pkt->size; |
||||||
|
ost->packets_written++; |
||||||
|
|
||||||
|
pkt->stream_index = ost->index; |
||||||
|
|
||||||
|
if (debug_ts) { |
||||||
|
av_log(NULL, AV_LOG_INFO, "muxer <- type:%s " |
||||||
|
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s size:%d\n", |
||||||
|
av_get_media_type_string(ost->enc_ctx->codec_type), |
||||||
|
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base), |
||||||
|
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base), |
||||||
|
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ost->st->time_base), |
||||||
|
pkt->size |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_interleaved_write_frame(s, pkt); |
||||||
|
if (ret < 0) { |
||||||
|
print_error("av_interleaved_write_frame()", ret); |
||||||
|
main_ffmpeg_return_code = 1; |
||||||
|
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static int print_sdp(void) |
||||||
|
{ |
||||||
|
char sdp[16384]; |
||||||
|
int i; |
||||||
|
int j, ret; |
||||||
|
AVIOContext *sdp_pb; |
||||||
|
AVFormatContext **avc; |
||||||
|
|
||||||
|
for (i = 0; i < nb_output_files; i++) { |
||||||
|
if (!output_files[i]->header_written) |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
avc = av_malloc_array(nb_output_files, sizeof(*avc)); |
||||||
|
if (!avc) |
||||||
|
exit_program(1); |
||||||
|
for (i = 0, j = 0; i < nb_output_files; i++) { |
||||||
|
if (!strcmp(output_files[i]->ctx->oformat->name, "rtp")) { |
||||||
|
avc[j] = output_files[i]->ctx; |
||||||
|
j++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!j) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n"); |
||||||
|
ret = AVERROR(EINVAL); |
||||||
|
goto fail; |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_sdp_create(avc, j, sdp, sizeof(sdp)); |
||||||
|
if (ret < 0) |
||||||
|
goto fail; |
||||||
|
|
||||||
|
if (!sdp_filename) { |
||||||
|
printf("SDP:\n%s\n", sdp); |
||||||
|
fflush(stdout); |
||||||
|
} else { |
||||||
|
ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename); |
||||||
|
goto fail; |
||||||
|
} |
||||||
|
|
||||||
|
avio_print(sdp_pb, sdp); |
||||||
|
avio_closep(&sdp_pb); |
||||||
|
av_freep(&sdp_filename); |
||||||
|
} |
||||||
|
|
||||||
|
fail: |
||||||
|
av_freep(&avc); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
/* open the muxer when all the streams are initialized */ |
||||||
|
int of_check_init(OutputFile *of) |
||||||
|
{ |
||||||
|
int ret, i; |
||||||
|
|
||||||
|
for (i = 0; i < of->ctx->nb_streams; i++) { |
||||||
|
OutputStream *ost = output_streams[of->ost_index + i]; |
||||||
|
if (!ost->initialized) |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
ret = avformat_write_header(of->ctx, &of->opts); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Could not write header for output file #%d " |
||||||
|
"(incorrect codec parameters ?): %s\n", |
||||||
|
of->index, av_err2str(ret)); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
//assert_avoptions(of->opts);
|
||||||
|
of->header_written = 1; |
||||||
|
|
||||||
|
av_dump_format(of->ctx, of->index, of->ctx->url, 1); |
||||||
|
nb_output_dumped++; |
||||||
|
|
||||||
|
if (sdp_filename || want_sdp) { |
||||||
|
ret = print_sdp(); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error writing the SDP.\n"); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* flush the muxing queues */ |
||||||
|
for (i = 0; i < of->ctx->nb_streams; i++) { |
||||||
|
OutputStream *ost = output_streams[of->ost_index + i]; |
||||||
|
AVPacket *pkt; |
||||||
|
|
||||||
|
/* try to improve muxing time_base (only possible if nothing has been written yet) */ |
||||||
|
if (!av_fifo_can_read(ost->muxing_queue)) |
||||||
|
ost->mux_timebase = ost->st->time_base; |
||||||
|
|
||||||
|
while (av_fifo_read(ost->muxing_queue, &pkt, 1) >= 0) { |
||||||
|
ost->muxing_queue_data_size -= pkt->size; |
||||||
|
of_write_packet(of, pkt, ost, 1); |
||||||
|
av_packet_free(&pkt); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
int of_write_trailer(OutputFile *of) |
||||||
|
{ |
||||||
|
int ret; |
||||||
|
|
||||||
|
if (!of->header_written) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, |
||||||
|
"Nothing was written into output file %d (%s), because " |
||||||
|
"at least one of its streams received no packets.\n", |
||||||
|
of->index, of->ctx->url); |
||||||
|
return AVERROR(EINVAL); |
||||||
|
} |
||||||
|
|
||||||
|
ret = av_write_trailer(of->ctx); |
||||||
|
if (ret < 0) { |
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret)); |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
void of_close(OutputFile **pof) |
||||||
|
{ |
||||||
|
OutputFile *of = *pof; |
||||||
|
AVFormatContext *s; |
||||||
|
|
||||||
|
if (!of) |
||||||
|
return; |
||||||
|
|
||||||
|
s = of->ctx; |
||||||
|
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE)) |
||||||
|
avio_closep(&s->pb); |
||||||
|
avformat_free_context(s); |
||||||
|
av_dict_free(&of->opts); |
||||||
|
|
||||||
|
av_freep(pof); |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@ |
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg. |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of fopen_utf8.h file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef FFTOOLS_FOPEN_UTF8_H |
||||||
|
#define FFTOOLS_FOPEN_UTF8_H |
||||||
|
|
||||||
|
#include <stdio.h> |
||||||
|
|
||||||
|
/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8,
|
||||||
|
* except that it doesn't set O_CLOEXEC, and that it isn't exported |
||||||
|
* from a different library. (On Windows, each DLL might use a different |
||||||
|
* CRT, and FILE* handles can't be shared across them.) */ |
||||||
|
|
||||||
|
#ifdef _WIN32 |
||||||
|
#include "libavutil/wchar_filename.h" |
||||||
|
|
||||||
|
static inline FILE *fopen_utf8(const char *path_utf8, const char *mode) |
||||||
|
{ |
||||||
|
wchar_t *path_w, *mode_w; |
||||||
|
FILE *f; |
||||||
|
|
||||||
|
/* convert UTF-8 to wide chars */ |
||||||
|
if (get_extended_win32_path(path_utf8, &path_w)) /* This sets errno on error. */ |
||||||
|
return NULL; |
||||||
|
if (!path_w) |
||||||
|
goto fallback; |
||||||
|
|
||||||
|
if (utf8towchar(mode, &mode_w)) |
||||||
|
return NULL; |
||||||
|
if (!mode_w) { |
||||||
|
/* If failing to interpret the mode string as utf8, it is an invalid
|
||||||
|
* parameter. */ |
||||||
|
av_freep(&path_w); |
||||||
|
errno = EINVAL; |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
|
||||||
|
f = _wfopen(path_w, mode_w); |
||||||
|
av_freep(&path_w); |
||||||
|
av_freep(&mode_w); |
||||||
|
|
||||||
|
return f; |
||||||
|
fallback: |
||||||
|
/* path may be in CP_ACP */ |
||||||
|
return fopen(path_utf8, mode); |
||||||
|
} |
||||||
|
|
||||||
|
#else |
||||||
|
|
||||||
|
static inline FILE *fopen_utf8(const char *path, const char *mode) |
||||||
|
{ |
||||||
|
return fopen(path, mode); |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* FFTOOLS_FOPEN_UTF8_H */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,202 @@ |
|||||||
|
/*
|
||||||
|
* Option handlers shared between the tools. |
||||||
|
* copyright (c) 2022 Taner Sener ( tanersener gmail com ) |
||||||
|
* |
||||||
|
* This file is part of FFmpeg. |
||||||
|
* |
||||||
|
* FFmpeg is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Lesser General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2.1 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* FFmpeg is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Lesser General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Lesser General Public |
||||||
|
* License along with FFmpeg; if not, write to the Free Software |
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is the modified version of opt_common.h file living in ffmpeg source code under the fftools folder. We |
||||||
|
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied |
||||||
|
* by us to develop the ffmpeg-kit library. |
||||||
|
* |
||||||
|
* ffmpeg-kit changes by Taner Sener |
||||||
|
* |
||||||
|
* 09.2022 |
||||||
|
* -------------------------------------------------------- |
||||||
|
* - CMDUTILS_COMMON_OPTIONS and CMDUTILS_COMMON_OPTIONS_AVDEVICE defines dropped |
||||||
|
* - fftools_ prefix added to fftools headers |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef FFTOOLS_OPT_COMMON_H |
||||||
|
#define FFTOOLS_OPT_COMMON_H |
||||||
|
|
||||||
|
#include "config.h" |
||||||
|
|
||||||
|
#include "fftools_cmdutils.h" |
||||||
|
|
||||||
|
#if CONFIG_AVDEVICE |
||||||
|
/**
|
||||||
|
* Print a listing containing autodetected sinks of the output device. |
||||||
|
* Device name with options may be passed as an argument to limit results. |
||||||
|
*/ |
||||||
|
int show_sinks(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing autodetected sources of the input device. |
||||||
|
* Device name with options may be passed as an argument to limit results. |
||||||
|
*/ |
||||||
|
int show_sources(void *optctx, const char *opt, const char *arg); |
||||||
|
#endif |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the license of the program to stdout. The license depends on |
||||||
|
* the license of the libraries compiled into the program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_license(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic -h handler common to all fftools. |
||||||
|
*/ |
||||||
|
int show_help(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the version of the program to stdout. The version message |
||||||
|
* depends on the current versions of the repository and of the libav* |
||||||
|
* libraries. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_version(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the build configuration of the program to stdout. The contents |
||||||
|
* depend on the definition of FFMPEG_CONFIGURATION. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_buildconf(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the formats supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_formats(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the muxers supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_muxers(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the demuxer supported by the |
||||||
|
* program (including devices). |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_demuxers(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the devices supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_devices(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the codecs supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_codecs(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the decoders supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_decoders(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the encoders supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_encoders(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the bit stream filters supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_bsfs(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the protocols supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_protocols(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the filters supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_filters(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the pixel formats supported by the |
||||||
|
* program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_pix_fmts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the standard channel layouts supported by |
||||||
|
* the program. |
||||||
|
* This option processing function does not utilize the arguments. |
||||||
|
*/ |
||||||
|
int show_layouts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the sample formats supported by the |
||||||
|
* program. |
||||||
|
*/ |
||||||
|
int show_sample_fmts(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all supported stream dispositions. |
||||||
|
*/ |
||||||
|
int show_dispositions(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the color names and values recognized |
||||||
|
* by the program. |
||||||
|
*/ |
||||||
|
int show_colors(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the libav* libraries log level. |
||||||
|
*/ |
||||||
|
int opt_loglevel(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
int opt_report(void *optctx, const char *opt, const char *arg); |
||||||
|
int init_report(const char *env, FILE **file); |
||||||
|
|
||||||
|
int opt_max_alloc(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the cpuflags. |
||||||
|
*/ |
||||||
|
int opt_cpuflags(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the cpucount. |
||||||
|
*/ |
||||||
|
int opt_cpucount(void *optctx, const char *opt, const char *arg); |
||||||
|
|
||||||
|
#endif /* FFTOOLS_OPT_COMMON_H */ |
Loading…
Reference in new issue