41 #include "libavformat/avformat.h"
42 #include "libavdevice/avdevice.h"
43 #include "libswscale/swscale.h"
44 #include "libswresample/swresample.h"
45 #include "libavutil/opt.h"
46 #include "libavutil/channel_layout.h"
47 #include "libavutil/parseutils.h"
48 #include "libavutil/samplefmt.h"
49 #include "libavutil/fifo.h"
50 #include "libavutil/intreadwrite.h"
51 #include "libavutil/dict.h"
52 #include "libavutil/mathematics.h"
53 #include "libavutil/pixdesc.h"
54 #include "libavutil/avstring.h"
56 #include "libavutil/imgutils.h"
57 #include "libavutil/timestamp.h"
58 #include "libavutil/bprint.h"
59 #include "libavutil/time.h"
64 # include "libavfilter/avcodec.h"
65 # include "libavfilter/avfilter.h"
66 # include "libavfilter/buffersrc.h"
67 # include "libavfilter/buffersink.h"
69 #if HAVE_SYS_RESOURCE_H
71 #include <sys/types.h>
72 #include <sys/resource.h>
73 #elif HAVE_GETPROCESSTIMES
76 #if HAVE_GETPROCESSMEMORYINFO
82 #include <sys/select.h>
87 #include <sys/ioctl.h>
103 #include "libavutil/avassert.h"
142 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
190 uint32_t *pal, *dst2;
198 if (r->
x < 0 || r->
x + r->
w > w || r->
y < 0 || r->
y + r->
h > h) {
203 dst += r->
y * dst_linesize + r->
x * 4;
206 for (y = 0; y < r->
h; y++) {
207 dst2 = (uint32_t *)dst;
209 for (x = 0; x < r->
w; x++)
210 *(dst2++) = pal[*(src2++)];
236 int64_t pts, end_pts;
253 "Impossible to get a blank canvas.\n");
256 dst = frame->
data [0];
258 for (i = 0; i < num_rects; i++)
282 if (pts2 <= ist2->sub2video.last_pts)
286 for (j = 0, nb_reqs = 0; j < ist2->
nb_filters; j++)
308 tcsetattr (0, TCSANOW, &
oldtty);
332 istty = isatty(0) && isatty(2);
334 if (istty && tcgetattr (0, &tty) == 0) {
338 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
339 |INLCR|IGNCR|ICRNL|IXON);
340 tty.c_oflag |= OPOST;
341 tty.c_lflag &= ~(
ECHO|ECHONL|ICANON|IEXTEN);
342 tty.c_cflag &= ~(CSIZE|PARENB);
347 tcsetattr (0, TCSANOW, &tty);
374 n = select(1, &rfds, NULL, NULL, &tv);
383 # if HAVE_PEEKNAMEDPIPE
385 static HANDLE input_handle;
388 input_handle = GetStdHandle(STD_INPUT_HANDLE);
389 is_pipe = !GetConsoleMode(input_handle, &dw);
392 if (stdin->_cnt > 0) {
398 if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL)) {
430 printf(
"bench: maxrss=%ikB\n", maxrss);
435 for (j = 0; j < filtergraphs[i]->
nb_inputs; j++) {
440 for (j = 0; j < filtergraphs[i]->
nb_outputs; j++) {
445 av_freep(&filtergraphs[i]->graph_desc);
471 av_freep(&output_streams[i]->forced_keyframes);
472 av_expr_free(output_streams[i]->forced_keyframes_pexpr);
473 av_freep(&output_streams[i]->avfilter);
474 av_freep(&output_streams[i]->logfile_prefix);
539 printf(
"bench: %8"PRIu64
" %s \n", t -
current_time, buf);
579 memcpy(t, new_pkt.
data, new_pkt.
size);
594 av_log(NULL,
AV_LOG_ERROR,
"Failed to open bitstream filter %s for stream %d with codec %s",
611 if (pkt->
dts < max) {
613 av_log(s, loglevel,
"Non-monotonous DTS in output stream "
614 "%d:%d; previous: %"PRId64
", current: %"PRId64
"; ",
620 av_log(s, loglevel,
"changing to %"PRId64
". This may result "
621 "in incorrect timestamps in the output file.\n",
634 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
709 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
726 int subtitle_out_max_size = 1024 * 1024;
727 int subtitle_out_size, nb, i;
757 for (i = 0; i < nb; i++) {
770 subtitle_out_max_size, sub);
771 if (subtitle_out_size < 0) {
778 pkt.
size = subtitle_out_size;
785 pkt.
pts += 90 * sub->start_display_time;
787 pkt.
pts += 90 * sub->end_display_time;
798 int ret, format_video_sync;
802 double sync_ipts,
delta;
813 sync_ipts = in_picture->
pts;
830 switch (format_video_sync) {
832 if (ost->
frame_number == 0 && delta - duration >= 0.5) {
841 else if (delta > 1.1)
842 nb_frames =
lrintf(delta);
847 else if (delta > 0.6)
859 if (nb_frames == 0) {
863 }
else if (nb_frames > 1) {
865 av_log(NULL,
AV_LOG_ERROR,
"%d frame duplication too large, skipping\n", nb_frames - 1);
874 for (i = 0; i < nb_frames; i++) {
907 int got_packet, forced_keyframe = 0;
937 av_dlog(NULL,
"force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
955 if (forced_keyframe) {
979 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
984 frame_size = pkt.
size;
1010 return -10.0 * log(d) / log(10.0);
1017 double ti1, bitrate, avg_bitrate;
1042 avg_bitrate = (double)(
video_size * 8) / ti1 / 1000.0;
1043 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
1044 (
double)
video_size / 1024, ti1, bitrate, avg_bitrate);
1057 AVFrame *filtered_frame = NULL;
1082 "Error in av_buffersink_get_frame_flags(): %s\n",
av_err2str(ret));
1102 filtered_frame->
pts = frame_pts;
1109 filtered_frame->
pts = frame_pts;
1113 "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
1138 int frame_number, vid, i;
1140 int64_t pts = INT64_MIN;
1141 static int64_t last_time = -1;
1142 static int qp_histogram[52];
1143 int hours, mins, secs, us;
1145 if (!
print_stats && !is_last_report && !progress_avio)
1148 if (!is_last_report) {
1149 if (last_time == -1) {
1153 if ((cur_time - last_time) < 500000)
1159 oc = output_files[0]->
ctx;
1162 if (total_size <= 0)
1170 ost = output_streams[i];
1175 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"q=%2.1f ", q);
1176 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1180 float fps,
t = (cur_time-timer_start) / 1000000.0;
1183 fps = t > 1 ? frame_number / t : 0;
1184 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"frame=%5d fps=%3.*f q=%3.1f ",
1185 frame_number, fps < 9.95, fps, q);
1186 av_bprintf(&buf_script,
"frame=%d\n", frame_number);
1188 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1191 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"L");
1197 for (j = 0; j < 32; j++)
1198 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%X", (
int)
lrintf(
log2(qp_histogram[j] + 1)));
1202 double error, error_sum = 0;
1203 double scale, scale_sum = 0;
1205 char type[3] = {
'Y',
'U',
'V' };
1206 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"PSNR=");
1207 for (j = 0; j < 3; j++) {
1208 if (is_last_report) {
1209 error = enc->
error[j];
1210 scale = enc->
width * enc->
height * 255.0 * 255.0 * frame_number;
1219 p =
psnr(error / scale);
1220 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%c:%2.2f ", type[j], p);
1221 av_bprintf(&buf_script,
"stream_%d_%d_psnr_%c=%2.2f\n",
1224 p =
psnr(error_sum / scale_sum);
1225 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"*:%2.2f ",
psnr(error_sum / scale_sum));
1226 av_bprintf(&buf_script,
"stream_%d_%d_psnr_all=%2.2f\n",
1244 bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
1246 if (total_size < 0)
snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1248 else snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1249 "size=%8.0fkB time=", total_size / 1024.0);
1250 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1251 "%02d:%02d:%02d.%02d ", hours, mins, secs,
1253 if (bitrate < 0)
snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1255 else snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1256 "bitrate=%6.1fkbits/s", bitrate);
1257 if (total_size < 0)
av_bprintf(&buf_script,
"total_size=N/A\n");
1258 else av_bprintf(&buf_script,
"total_size=%"PRId64
"\n", total_size);
1259 av_bprintf(&buf_script,
"out_time_ms=%"PRId64
"\n", pts);
1260 av_bprintf(&buf_script,
"out_time=%02d:%02d:%02d.%06d\n",
1261 hours, mins, secs, us);
1264 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" dup=%d drop=%d",
1271 fprintf(stderr,
"%s \r", buf);
1278 if (progress_avio) {
1280 is_last_report ?
"end" :
"continue");
1282 FFMIN(buf_script.len, buf_script.size - 1));
1285 if (is_last_report) {
1287 progress_avio = NULL;
1291 if (is_last_report) {
1294 av_log(NULL,
AV_LOG_INFO,
"video:%1.0fkB audio:%1.0fkB subtitle:%1.0f global headers:%1.0fkB muxing overhead %f%%\n",
1298 extra_size / 1024.0,
1299 100.0 * (total_size - raw) / raw
1302 av_log(NULL,
AV_LOG_WARNING,
"Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)\n");
1315 int stop_encoding = 0;
1353 ret = encode(enc, &pkt, NULL, &got_packet);
1463 opkt.
dts -= ost_tb_start_time;
1495 avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
1502 ost->st->codec->frame_number++;
1510 char layout_name[256];
1529 int i,
ret, err = 0, resample_changed;
1547 if (*got_output || ret<0 || pkt->
size)
1550 if (!*got_output || ret < 0) {
1575 if (resample_changed) {
1576 char layout1[64], layout2[64];
1580 "layout for Input Stream #%d.%d\n", ist->
file_index,
1592 "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:%s to rate:%d fmt:%s ch:%d chl:%s\n",
1632 decoded_frame->
pts = pkt->
pts;
1636 decoded_frame->
pts = ist->
dts;
1642 (
AVRational){1, ist->st->codec->sample_rate});
1643 for (i = 0; i < ist->nb_filters; i++) {
1644 if (i < ist->nb_filters - 1) {
1645 f = ist->filter_frame;
1662 return err < 0 ? err :
ret;
1668 void *buffer_to_free = NULL;
1669 int i,
ret = 0, err = 0, resample_changed;
1670 int64_t best_effort_timestamp;
1682 decoded_frame, got_output, pkt);
1685 if (*got_output || ret<0 || pkt->
size)
1688 if (!*got_output || ret < 0) {
1709 "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64
" best_effort_ts_time:%s keyframe:%d frame_type:%d \n",
1712 best_effort_timestamp,
1725 if (resample_changed) {
1727 "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
1747 if (!frame_sample_aspect->
num)
1750 if (i < ist->nb_filters - 1) {
1760 }
else if (ret < 0) {
1762 "Failed to inject frame into filter network: %s\n",
av_err2str(ret));
1770 return err < 0 ? err :
ret;
1777 &subtitle, got_output, pkt);
1779 if (*got_output || ret<0 || pkt->
size)
1782 if (ret < 0 || !*got_output) {
1792 if (end < ist->prev_sub.subtitle.end_display_time) {
1794 "Subtitle duration reduced from %d to %d\n",
1806 if (!*got_output || !subtitle.
num_rects)
1870 "Multiple frames in a packet from stream %d\n", pkt->
stream_index);
1971 avc[i] = output_files[i]->ctx;
1974 printf(
"SDP:\n%s\n", sdp);
1987 snprintf(error, error_len,
"Decoder (codec %s) not found for input stream #%d:%d",
2004 "Error while opening decoder for input stream "
2028 int64_t va = *(int64_t *)a, vb = *(int64_t *)
b;
2029 return va < vb ? -1 : va > vb ? +1 : 0;
2039 for (p = kf; *p; p++)
2050 for (i = 0; i <
n; i++) {
2051 char *next = strchr(p,
',');
2056 if (!memcmp(p,
"chapters", 8)) {
2065 "Could not allocate forced key frames array.\n");
2097 InputFile *file = input_files[input_index];
2103 "New %s stream %d:%d at pos:%"PRId64
" and DTS:%ss\n",
2112 int ret = 0, i, j, k;
2129 if (fg->
inputs[0]->
ist == input_streams[k])
2145 oc = output_files[i]->
ctx;
2161 ost = output_streams[i];
2195 if (extra_size > INT_MAX) {
2204 unsigned int codec_tag;
2251 if( copy_tb<0 && icodec->time_base.den
2277 av_log(NULL,
AV_LOG_FATAL,
"-acodec copy and -vol are incompatible (frames are not decoded)\n");
2301 "with stream copy may produce invalid files\n");
2325 snprintf(error,
sizeof(error),
"Encoder (codec %s) not found for output stream #%d:%d",
2375 "Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
2388 if (!strncmp(ost->
enc->
name,
"libx264", 7) &&
2392 "No pixel format specified, %s for H.264 encoding chosen.\n"
2393 "Use -pix_fmt yuv420p for compatibility with outdated media players.\n",
2395 if (!strncmp(ost->
enc->
name,
"mpeg2video", 10) &&
2399 "No pixel format specified, %s for MPEG-2 encoding chosen.\n"
2400 "Use -pix_fmt yuv420p for compatibility with outdated media players.\n",
2405 codec->
width != icodec->width ||
2406 codec->
height != icodec->height ||
2407 codec->
pix_fmt != icodec->pix_fmt) {
2431 if (!codec->
width) {
2445 snprintf(logfilename,
sizeof(logfilename),
"%s-%d.log",
2449 if (!strcmp(ost->
enc->
name,
"libx264")) {
2454 size_t logbuffer_size;
2463 f = fopen(logfilename,
"wb");
2466 logfilename, strerror(errno));
2478 ost = output_streams[i];
2479 if (ost->encoding_needed) {
2484 dec = ist->st->
codec;
2488 if (!ost->st->codec->subtitle_header) {
2500 snprintf(error,
sizeof(error),
"Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height",
2501 ost->file_index, ost->index);
2507 ost->st->codec->frame_size);
2509 if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
2511 " It takes bits/s as argument, not kbits/s\n");
2512 extra_size += ost->st->codec->extradata_size;
2514 if (ost->st->codec->me_threshold)
2525 ost = output_streams[i];
2549 oc = output_files[i]->
ctx;
2555 "Could not write header for output file #%d "
2556 "(incorrect codec parameters ?): %s",
2562 if (strcmp(oc->oformat->name,
"rtp")) {
2571 av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1);
2577 ist = input_streams[i];
2579 for (j = 0; j < ist->nb_filters; j++) {
2580 if (ist->filters[j]->graph->graph_desc) {
2582 ist->file_index, ist->st->index, ist->dec ? ist->dec->name :
"?",
2583 ist->filters[j]->name);
2592 ost = output_streams[i];
2594 if (ost->attachment_filename) {
2597 ost->attachment_filename, ost->file_index, ost->index);
2601 if (ost->filter && ost->filter->graph->graph_desc) {
2608 ost->index, ost->enc ? ost->enc->name :
"?");
2613 input_streams[ost->source_index]->
file_index,
2614 input_streams[ost->source_index]->
st->
index,
2617 if (ost->sync_ist != input_streams[ost->source_index])
2619 ost->sync_ist->file_index,
2620 ost->sync_ist->st->index);
2621 if (ost->stream_copy)
2625 input_streams[ost->source_index]->
dec->
name :
"?",
2626 ost->enc ? ost->enc->name :
"?");
2676 int64_t opts_min = INT64_MAX;
2694 static int64_t last_time;
2717 if (key ==
'c' || key ==
'C'){
2721 fprintf(stderr,
"\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
2723 while ((k =
read_key()) !=
'\n' && k !=
'\r' && i <
sizeof(buf)-1)
2728 (n = sscanf(buf,
"%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
2730 target, time, command, arg);
2737 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s", i, ret, buf);
2738 }
else if (key ==
'c') {
2739 fprintf(stderr,
"Queing commands only on filters supporting the specific command is unsupported\n");
2748 "Parse error, at least 3 arguments were expected, "
2749 "only %d given in string '%s'\n", n, buf);
2752 if (key ==
'd' || key ==
'D'){
2756 if(!debug) debug = 1;
2760 if(scanf(
"%d", &debug)!=1)
2761 fprintf(stderr,
"error parsing debug value\n");
2770 fprintf(stderr,
"debug=%d\n", debug);
2773 fprintf(stderr,
"key function\n"
2774 "? show this help\n"
2775 "+ increase verbosity\n"
2776 "- decrease verbosity\n"
2777 "c Send command to first matching filter supporting it\n"
2778 "C Send/Que command to all matching filters\n"
2779 "D cycle through available debug modes\n"
2780 "h dump packets/hex press to cycle through the 3 states\n"
2782 "s Show QP histogram\n"
2823 if (nb_input_files == 1)
2858 if (nb_input_files == 1)
2912 if (nb_input_files > 1)
2922 if (output_streams[i]->unavailable)
2931 input_files[i]->eagain = 0;
2933 output_streams[i]->unavailable = 0;
2945 InputFile *ifile = input_files[file_index];
2967 ist = input_streams[ifile->
ist_index + i];
2994 goto discard_packet;
2999 goto discard_packet;
3003 "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
3014 int64_t stime, stime2;
3021 int64_t new_start_time = INT64_MAX;
3067 "Inter stream timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
3086 "timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
3116 av_log(NULL,
AV_LOG_INFO,
"demuxer+ffmpeg -> ist_index:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
3152 int nb_requests, nb_requests_max = 0;
3170 for (i = 0; i < graph->
nb_inputs; i++) {
3171 ifilter = graph->
inputs[i];
3177 if (nb_requests > nb_requests_max) {
3178 nb_requests_max = nb_requests;
3243 int64_t timer_start;
3292 ist = input_streams[i];
3303 os = output_files[i]->
ctx;
3312 ost = output_streams[i];
3321 ist = input_streams[i];
3335 if (output_streams) {
3337 ost = output_streams[i];
3361 struct rusage rusage;
3363 getrusage(RUSAGE_SELF, &rusage);
3364 return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
3365 #elif HAVE_GETPROCESSTIMES
3367 FILETIME
c, e, k,
u;
3368 proc = GetCurrentProcess();
3369 GetProcessTimes(proc, &c, &e, &k, &u);
3370 return ((int64_t) u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
3378 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
3379 struct rusage rusage;
3380 getrusage(RUSAGE_SELF, &rusage);
3381 return (int64_t)rusage.ru_maxrss * 1024;
3382 #elif HAVE_GETPROCESSMEMORYINFO
3384 PROCESS_MEMORY_COUNTERS memcounters;
3385 proc = GetCurrentProcess();
3386 memcounters.cb =
sizeof(memcounters);
3387 GetProcessMemoryInfo(proc, &memcounters,
sizeof(memcounters));
3388 return memcounters.PeakPagefileUsage;
3405 setvbuf(stderr,NULL,_IONBF,0);
3410 if(argc>1 && !strcmp(argv[1],
"-d")){
3434 if (nb_output_files <= 0 && nb_input_files == 0) {
3441 if (nb_output_files <= 0) {
3456 printf(
"bench: utime=%0.3fs\n", ti / 1000000.0);
3458 av_log(NULL,
AV_LOG_DEBUG,
"%"PRIu64
" frames successfully decoded, %"PRIu64
" decoding errors\n",
unsigned int nb_chapters
Number of chapters in AVChapter array.
static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
int guess_input_channel_layout(InputStream *ist)
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
#define AVERROR_PATCHWELCOME
void av_free_packet(AVPacket *pkt)
Free a packet.
This structure describes decoded (raw) audio or video data.
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts)
Queue a command for one or more filter instances.
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
int x
top left corner of pict, undefined when pict is not set
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
static void sub2video_flush(InputStream *ist)
unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
Get the number of failed requests.
#define CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
static int process_input(int file_index)
#define CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int64_t pos
byte position in stream, -1 if unknown
uint8_t * subtitle_header
Header containing style information for text subtitles.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
#define CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
int av_usleep(unsigned usec)
Sleep for a period of time.
void av_log_set_level(int level)
Set the log level.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
int h
agreed upon image height
int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
AVFrame * avcodec_alloc_frame(void)
Allocate an AVFrame and set its fields to default values.
static int64_t audio_size
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
AVCodecContext * codec
Codec context associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
FilterGraph * init_simple_filtergraph(InputStream *ist, OutputStream *ost)
static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time)
int index
stream index in AVFormatContext
static int64_t getmaxrss(void)
static InputStream * get_input_stream(OutputStream *ost)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVBitStreamFilterContext * bitstream_filters
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
static void abort_codec_experimental(AVCodec *c, int encoder)
static int transcode_init(void)
static int compare_int64(const void *a, const void *b)
static int init_input_threads(void)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time...
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
int av_dup_packet(AVPacket *pkt)
static void report_new_stream(int input_index, AVPacket *pkt)
struct AVBitStreamFilterContext * next
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
int avpicture_fill(AVPicture *picture, const uint8_t *ptr, enum AVPixelFormat pix_fmt, int width, int height)
Setup the picture fields based on the specified image parameters and the provided image data buffer...
float dts_error_threshold
int64_t start_time
start time in microseconds == AV_TIME_BASE units
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int decode_interrupt_cb(void *ctx)
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
static void update_benchmark(const char *fmt,...)
static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
static int check_keyboard_interaction(int64_t cur_time)
int av_fifo_size(AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
unsigned int nb_stream_indexes
#define AV_LOG_QUIET
Print no output.
#define CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
int w
width of pict, undefined when pict is not set
static uint8_t * subtitle_out
#define DEFAULT_PASS_LOGFILENAME_PREFIX
static int64_t start_time
int copy_initial_nonkeyframes
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
enum AVSampleFormat sample_fmt
audio sample format
static void * input_thread(void *arg)
int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
static void sub2video_push_ref(InputStream *ist, int64_t pts)
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
miscellaneous OS support macros and functions.
attribute_deprecated void(* destruct)(struct AVPacket *)
static av_cold int end(AVCodecContext *avctx)
#define ECHO(name, type, min, max)
static int need_output(void)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static double psnr(double d)
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
int av_codec_get_tag2(const struct AVCodecTag *const *tags, enum AVCodecID id, unsigned int *tag)
Get the codec tag for the given codec id.
void avfilter_register_all(void)
Initialize the filter system.
static int64_t getutime(void)
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Immediately push the frame to the output.
static double av_q2d(AVRational a)
Convert rational to double.
AVRational av_mul_q(AVRational b, AVRational c) av_const
Multiply two rationals.
AVDictionary * resample_opts
static void parse_forced_key_frames(char *kf, OutputStream *ost, AVCodecContext *avctx)
int avformat_network_init(void)
Do global initialization of network components.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
static int read_key(void)
#define AV_LOG_VERBOSE
Detailed information.
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
static void do_video_stats(OutputStream *ost, int frame_size)
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
int interlaced_frame
The content of the picture is interlaced.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
int h
height of pict, undefined when pict is not set
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define FFSWAP(type, a, b)
enum AVDiscard discard
selects which program to discard and which to feed to the caller
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
#define AVERROR_EXPERIMENTAL
static const vf_info_t *const filters[]
static void sub2video_heartbeat(InputStream *ist, int64_t pts)
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx)
Get the frame rate of the input.
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
static const uint8_t frame_size[4]
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Callback for checking whether to abort blocking functions.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
#define av_err2str(errnum)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static void reset_eagain(void)
static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
int ffmpeg_parse_options(int argc, char **argv)
FilterGraph ** filtergraphs
const AVIOInterruptCB int_cb
#define CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
int sample_rate
samples per second
const AVRational * supported_framerates
array of supported framerates, or NULL if any, array is terminated by {0,0}
#define CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
int y
top left corner of pict, undefined when pict is not set
char filename[1024]
input or output filename
static int64_t decode_error_stat[2]
int avfilter_link_get_channels(AVFilterLink *link)
Get the number of channels of a link.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static void do_video_out(AVFormatContext *s, OutputStream *ost, AVFrame *in_picture)
const char *const forced_keyframes_const_names[]
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_bitstream_filter_close(AVBitStreamFilterContext *bsf)
Release bitstream filter context.
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
preferred ID for decoding MPEG audio layer 1, 2 or 3
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int rc_max_rate
maximum bitrate
int av_log_get_level(void)
Get the current log level.
int av_frame_get_channels(const AVFrame *frame)
static int check_recording_time(OutputStream *ost)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVRational avg_frame_rate
Average framerate.
New fields can be added to the end with minor version bumps.
static char logfilename[1024]
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare 2 timestamps each in its own timebases.
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
void * av_opt_ptr(const AVClass *avclass, void *obj, const char *name)
Gets a pointer to the requested field in a struct.
uint32_t end_display_time
int64_t pts
Same as packet pts, in AV_TIME_BASE.
int rc_buffer_size
decoder bitstream buffer size
struct AVBitStreamFilter * filter
uint64_t channel_layout
Channel layout of the audio data.
int w
agreed upon image width
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
AVRational frame_aspect_ratio
const int program_birth_year
program birth year, defined by the program for show_banner()
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Init a print buffer.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
unsigned int nb_streams
A list of all streams in the file.
#define FF_ARRAY_ELEMS(a)
int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
static int nb_frames_drop
A bitmap, pict will be set.
int64_t av_gettime(void)
Get the current time in microseconds.
Buffer to print data progressively.
int bit_rate
the average bitrate
static int64_t video_size
static int transcoding_finished
enum AVPictureType pict_type
Picture type of the frame.
static int transcode(void)
Opaque data information usually continuous.
AVPicture pict
data+linesize for the bitmap of this subtitle.
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const
Rescale a 64-bit integer with rounding to nearest.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_TIME_BASE
Internal time base represented as integer.
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
struct OutputStream * ost
int width
picture width / height.
int av_buffersrc_add_ref(AVFilterContext *buffer_src, AVFilterBufferRef *picref, int flags)
Add buffer data in picref to buffer_src.
double forced_keyframes_expr_const_values[FKF_NB]
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define FF_DEBUG_DCT_COEFF
uint64_t error[AV_NUM_DATA_POINTERS]
error
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static int get_input_packet_mt(InputFile *f, AVPacket *pkt)
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
#define CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
static int reap_filters(void)
Get and encode new output from any of the filtergraphs, without causing activity. ...
static int output_packet(InputStream *ist, const AVPacket *pkt)
char * stats_out
pass1 encoding statistics output buffer
static int got_eagain(void)
preferred ID for MPEG-1/2 video decoding
static void sub2video_update(InputStream *ist, AVSubtitle *sub)
int av_find_nearest_q_idx(AVRational q, const AVRational *q_list)
Find the nearest value in q_list to q.
#define FF_DEBUG_VIS_MB_TYPE
int format
agreed upon media format
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int frame_size
Number of samples per channel in an audio frame.
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
static int sub2video_get_blank_frame(InputStream *ist)
#define AV_LOG_INFO
Standard information.
int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
Filter bitstream.
enum AVMediaType codec_type
int me_threshold
Motion estimation threshold below which no motion estimation is performed, but instead the user speci...
static int init_input_stream(int ist_index, char *error, int error_len)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_opt_set_dict(void *obj, struct AVDictionary **options)
Set all the options from a given dictionary on an object.
Keep a reference to the frame.
static int64_t extra_size
static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, AVSubtitleRect *r)
int sample_rate
samples per second
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb)
Rescale a timestamp while preserving known durations.
static void print_sdp(void)
main external API structure.
static int64_t subtitle_size
static void ffmpeg_cleanup(int ret)
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
void * av_realloc_f(void *ptr, size_t nelem, size_t elsize)
Allocate or reallocate a block of memory.
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
const char * attachment_filename
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int check_output_constraints(InputStream *ist, OutputStream *ost)
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
void assert_avoptions(AVDictionary *m)
AVIOContext * pb
I/O context.
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Replacements for frequently missing libm functions.
static int transcode_from_filter(FilterGraph *graph, InputStream **best_ist)
Perform a step of transcoding for the specified filter graph.
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
#define VSYNC_PASSTHROUGH
int sample_rate
Sample rate of the audio data.
int configure_filtergraph(FilterGraph *fg)
OutputStream ** output_streams
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
rational number numerator/denominator
AVFrame * coded_frame
the picture in the bitstream
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
Parse a string specifying a time and return its corresponding value as a number of microseconds...
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
discard useless packets like 0 size packets in avi
static av_always_inline av_const long int lrint(double x)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
uint64_t error[AV_NUM_DATA_POINTERS]
error
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int frame_bits_per_raw_sample
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
static void do_subtitle_out(AVFormatContext *s, OutputStream *ost, InputStream *ist, AVSubtitle *sub)
static int transcode_step(void)
Run a single step of transcoding.
static void free_input_threads(void)
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static volatile int received_nb_signals
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
Read the file with name filename, and put its content in a newly allocated 0-terminated buffer...
int global_quality
Global quality for codecs which cannot change it per frame.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static const uint16_t scale[4]
enum AVMediaType type
filter media type
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
AVExpr * forced_keyframes_pexpr
struct AVCodecParserContext * parser
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame)
Accessors for some AVFrame fields.
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
struct FilterGraph * graph
AVIOContext * progress_avio
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
int disposition
AV_DISPOSITION_* bit field.
uint32_t start_display_time
int pts_wrap_bits
number of bits in pts (used for wrapping control)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
AVRational time_base
time base in which the start/end timestamps are specified
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int64_t nb_frames
number of frames in this stream if known or 0
static FILE * vstats_file
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
Send a command to one or more filter instances.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
static struct termios oldtty
void av_bprintf(AVBPrint *buf, const char *fmt,...) av_printf_format(2
Append a formatted string to a print buffer.
static void do_audio_out(AVFormatContext *s, OutputStream *ost, AVFrame *frame)
struct AVOutputFormat * oformat
#define AVERROR_INVALIDDATA
int top_field_first
If the content is interlaced, is top field displayed first.
float dts_delta_threshold
struct AVFrac pts
encoding: pts generation when outputting stream
int channels
number of audio channels
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
void av_log_set_flags(int arg)
int key_frame
1 -> keyframe, 0-> not
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
Opaque data information usually sparse.
void avcodec_free_frame(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int repeat_pict
This field is used for proper frame duration computation in lavf.
enum AVFieldOrder field_order
Field order.
#define AV_DICT_IGNORE_SUFFIX
OutputFile ** output_files
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void flush_encoders(void)
static volatile int received_sigterm
static int get_input_packet(InputFile *f, AVPacket *pkt)
void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, AVStream *st)
Send a nice dump of a packet to the log.
int main(int argc, char **argv)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
int av_fifo_space(AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
unsigned int * stream_index
This structure stores compressed data.
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
static OutputStream * choose_output(void)
Select the output stream to process.
int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src, AVFrame *frame, int flags)
Add a frame to the buffer source.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static void sigterm_handler(int sig)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
const AVClass * avcodec_get_frame_class(void)
Get the AVClass for AVFrame.
const char program_name[]
program name, defined by the program for show_version().
#define AV_NOPTS_VALUE
Undefined timestamp value.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
InputStream ** input_streams
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
static void close_output_stream(OutputStream *ost)
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.