|
|
|
@ -51,6 +51,8 @@ |
|
|
|
|
|
|
|
|
|
typedef struct InputStream { |
|
|
|
|
AVStream *st; |
|
|
|
|
|
|
|
|
|
AVCodecContext *dec_ctx; |
|
|
|
|
} InputStream; |
|
|
|
|
|
|
|
|
|
typedef struct InputFile { |
|
|
|
@ -1757,10 +1759,10 @@ static inline int show_tags(WriterContext *w, AVDictionary *tags, int section_id |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx) |
|
|
|
|
static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int packet_idx) |
|
|
|
|
{ |
|
|
|
|
char val_str[128]; |
|
|
|
|
AVStream *st = fmt_ctx->streams[pkt->stream_index]; |
|
|
|
|
AVStream *st = ifile->streams[pkt->stream_index].st; |
|
|
|
|
AVBPrint pbuf; |
|
|
|
|
const char *s; |
|
|
|
|
|
|
|
|
@ -1768,7 +1770,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk |
|
|
|
|
|
|
|
|
|
writer_print_section_header(w, SECTION_ID_PACKET); |
|
|
|
|
|
|
|
|
|
s = av_get_media_type_string(st->codec->codec_type); |
|
|
|
|
s = av_get_media_type_string(st->codecpar->codec_type); |
|
|
|
|
if (s) print_str ("codec_type", s); |
|
|
|
|
else print_str_opt("codec_type", "unknown"); |
|
|
|
|
print_int("stream_index", pkt->stream_index); |
|
|
|
@ -1857,7 +1859,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, |
|
|
|
|
|
|
|
|
|
writer_print_section_header(w, SECTION_ID_FRAME); |
|
|
|
|
|
|
|
|
|
s = av_get_media_type_string(stream->codec->codec_type); |
|
|
|
|
s = av_get_media_type_string(stream->codecpar->codec_type); |
|
|
|
|
if (s) print_str ("media_type", s); |
|
|
|
|
else print_str_opt("media_type", "unknown"); |
|
|
|
|
print_int("stream_index", stream->index); |
|
|
|
@ -1875,7 +1877,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, |
|
|
|
|
if (av_frame_get_pkt_size(frame) != -1) print_val ("pkt_size", av_frame_get_pkt_size(frame), unit_byte_str); |
|
|
|
|
else print_str_opt("pkt_size", "N/A"); |
|
|
|
|
|
|
|
|
|
switch (stream->codec->codec_type) { |
|
|
|
|
switch (stream->codecpar->codec_type) { |
|
|
|
|
AVRational sar; |
|
|
|
|
|
|
|
|
|
case AVMEDIA_TYPE_VIDEO: |
|
|
|
@ -1945,15 +1947,17 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static av_always_inline int process_frame(WriterContext *w, |
|
|
|
|
AVFormatContext *fmt_ctx, |
|
|
|
|
InputFile *ifile, |
|
|
|
|
AVFrame *frame, AVPacket *pkt) |
|
|
|
|
{ |
|
|
|
|
AVCodecContext *dec_ctx = fmt_ctx->streams[pkt->stream_index]->codec; |
|
|
|
|
AVFormatContext *fmt_ctx = ifile->fmt_ctx; |
|
|
|
|
AVCodecContext *dec_ctx = ifile->streams[pkt->stream_index].dec_ctx; |
|
|
|
|
AVCodecParameters *par = ifile->streams[pkt->stream_index].st->codecpar; |
|
|
|
|
AVSubtitle sub; |
|
|
|
|
int ret = 0, got_frame = 0; |
|
|
|
|
|
|
|
|
|
if (dec_ctx->codec) { |
|
|
|
|
switch (dec_ctx->codec_type) { |
|
|
|
|
switch (par->codec_type) { |
|
|
|
|
case AVMEDIA_TYPE_VIDEO: |
|
|
|
|
ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, pkt); |
|
|
|
|
break; |
|
|
|
@ -1974,13 +1978,13 @@ static av_always_inline int process_frame(WriterContext *w, |
|
|
|
|
pkt->data += ret; |
|
|
|
|
pkt->size -= ret; |
|
|
|
|
if (got_frame) { |
|
|
|
|
int is_sub = (dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE); |
|
|
|
|
int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE); |
|
|
|
|
nb_streams_frames[pkt->stream_index]++; |
|
|
|
|
if (do_show_frames) |
|
|
|
|
if (is_sub) |
|
|
|
|
show_subtitle(w, &sub, fmt_ctx->streams[pkt->stream_index], fmt_ctx); |
|
|
|
|
show_subtitle(w, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx); |
|
|
|
|
else |
|
|
|
|
show_frame(w, frame, fmt_ctx->streams[pkt->stream_index], fmt_ctx); |
|
|
|
|
show_frame(w, frame, ifile->streams[pkt->stream_index].st, fmt_ctx); |
|
|
|
|
if (is_sub) |
|
|
|
|
avsubtitle_free(&sub); |
|
|
|
|
} |
|
|
|
@ -2011,9 +2015,10 @@ static void log_read_interval(const ReadInterval *interval, void *log_ctx, int l |
|
|
|
|
av_log(log_ctx, log_level, "\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx, |
|
|
|
|
static int read_interval_packets(WriterContext *w, InputFile *ifile, |
|
|
|
|
const ReadInterval *interval, int64_t *cur_ts) |
|
|
|
|
{ |
|
|
|
|
AVFormatContext *fmt_ctx = ifile->fmt_ctx; |
|
|
|
|
AVPacket pkt, pkt1; |
|
|
|
|
AVFrame *frame = NULL; |
|
|
|
|
int ret = 0, i = 0, frame_count = 0; |
|
|
|
@ -2055,14 +2060,14 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx, |
|
|
|
|
goto end; |
|
|
|
|
} |
|
|
|
|
while (!av_read_frame(fmt_ctx, &pkt)) { |
|
|
|
|
if (fmt_ctx->nb_streams > nb_streams) { |
|
|
|
|
if (ifile->nb_streams > nb_streams) { |
|
|
|
|
REALLOCZ_ARRAY_STREAM(nb_streams_frames, nb_streams, fmt_ctx->nb_streams); |
|
|
|
|
REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams); |
|
|
|
|
REALLOCZ_ARRAY_STREAM(selected_streams, nb_streams, fmt_ctx->nb_streams); |
|
|
|
|
nb_streams = fmt_ctx->nb_streams; |
|
|
|
|
nb_streams = ifile->nb_streams; |
|
|
|
|
} |
|
|
|
|
if (selected_streams[pkt.stream_index]) { |
|
|
|
|
AVRational tb = fmt_ctx->streams[pkt.stream_index]->time_base; |
|
|
|
|
AVRational tb = ifile->streams[pkt.stream_index].st->time_base; |
|
|
|
|
|
|
|
|
|
if (pkt.pts != AV_NOPTS_VALUE) |
|
|
|
|
*cur_ts = av_rescale_q(pkt.pts, tb, AV_TIME_BASE_Q); |
|
|
|
@ -2087,12 +2092,12 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx, |
|
|
|
|
frame_count++; |
|
|
|
|
if (do_read_packets) { |
|
|
|
|
if (do_show_packets) |
|
|
|
|
show_packet(w, fmt_ctx, &pkt, i++); |
|
|
|
|
show_packet(w, ifile, &pkt, i++); |
|
|
|
|
nb_streams_packets[pkt.stream_index]++; |
|
|
|
|
} |
|
|
|
|
if (do_read_frames) { |
|
|
|
|
pkt1 = pkt; |
|
|
|
|
while (pkt1.size && process_frame(w, fmt_ctx, frame, &pkt1) > 0); |
|
|
|
|
while (pkt1.size && process_frame(w, ifile, frame, &pkt1) > 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
av_packet_unref(&pkt); |
|
|
|
@ -2104,7 +2109,7 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx, |
|
|
|
|
for (i = 0; i < fmt_ctx->nb_streams; i++) { |
|
|
|
|
pkt.stream_index = i; |
|
|
|
|
if (do_read_frames) |
|
|
|
|
while (process_frame(w, fmt_ctx, frame, &pkt) > 0); |
|
|
|
|
while (process_frame(w, ifile, frame, &pkt) > 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
end: |
|
|
|
@ -2124,10 +2129,10 @@ static int read_packets(WriterContext *w, InputFile *ifile) |
|
|
|
|
|
|
|
|
|
if (read_intervals_nb == 0) { |
|
|
|
|
ReadInterval interval = (ReadInterval) { .has_start = 0, .has_end = 0 }; |
|
|
|
|
ret = read_interval_packets(w, fmt_ctx, &interval, &cur_ts); |
|
|
|
|
ret = read_interval_packets(w, ifile, &interval, &cur_ts); |
|
|
|
|
} else { |
|
|
|
|
for (i = 0; i < read_intervals_nb; i++) { |
|
|
|
|
ret = read_interval_packets(w, fmt_ctx, &read_intervals[i], &cur_ts); |
|
|
|
|
ret = read_interval_packets(w, ifile, &read_intervals[i], &cur_ts); |
|
|
|
|
if (ret < 0) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -2136,9 +2141,10 @@ static int read_packets(WriterContext *w, InputFile *ifile) |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, int in_program) |
|
|
|
|
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program) |
|
|
|
|
{ |
|
|
|
|
AVStream *stream = fmt_ctx->streams[stream_idx]; |
|
|
|
|
AVStream *stream = ist->st; |
|
|
|
|
AVCodecParameters *par; |
|
|
|
|
AVCodecContext *dec_ctx; |
|
|
|
|
char val_str[128]; |
|
|
|
|
const char *s; |
|
|
|
@ -2154,8 +2160,9 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id |
|
|
|
|
|
|
|
|
|
print_int("index", stream->index); |
|
|
|
|
|
|
|
|
|
dec_ctx = stream->codec; |
|
|
|
|
if (cd = avcodec_descriptor_get(stream->codec->codec_id)) { |
|
|
|
|
par = stream->codecpar; |
|
|
|
|
dec_ctx = ist->dec_ctx; |
|
|
|
|
if (cd = avcodec_descriptor_get(par->codec_id)) { |
|
|
|
|
print_str("codec_name", cd->name); |
|
|
|
|
if (!do_bitexact) { |
|
|
|
|
print_str("codec_long_name", |
|
|
|
@ -2168,76 +2175,80 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!do_bitexact && (profile = avcodec_profile_name(dec_ctx->codec_id, dec_ctx->profile))) |
|
|
|
|
if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile))) |
|
|
|
|
print_str("profile", profile); |
|
|
|
|
else { |
|
|
|
|
if (dec_ctx->profile != FF_PROFILE_UNKNOWN) { |
|
|
|
|
if (par->profile != FF_PROFILE_UNKNOWN) { |
|
|
|
|
char profile_num[12]; |
|
|
|
|
snprintf(profile_num, sizeof(profile_num), "%d", dec_ctx->profile); |
|
|
|
|
snprintf(profile_num, sizeof(profile_num), "%d", par->profile); |
|
|
|
|
print_str("profile", profile_num); |
|
|
|
|
} else |
|
|
|
|
print_str_opt("profile", "unknown"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s = av_get_media_type_string(dec_ctx->codec_type); |
|
|
|
|
s = av_get_media_type_string(par->codec_type); |
|
|
|
|
if (s) print_str ("codec_type", s); |
|
|
|
|
else print_str_opt("codec_type", "unknown"); |
|
|
|
|
#if FF_API_LAVF_AVCTX |
|
|
|
|
print_q("codec_time_base", dec_ctx->time_base, '/'); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* print AVI/FourCC tag */ |
|
|
|
|
av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag); |
|
|
|
|
av_get_codec_tag_string(val_str, sizeof(val_str), par->codec_tag); |
|
|
|
|
print_str("codec_tag_string", val_str); |
|
|
|
|
print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag); |
|
|
|
|
print_fmt("codec_tag", "0x%04x", par->codec_tag); |
|
|
|
|
|
|
|
|
|
switch (dec_ctx->codec_type) { |
|
|
|
|
switch (par->codec_type) { |
|
|
|
|
case AVMEDIA_TYPE_VIDEO: |
|
|
|
|
print_int("width", dec_ctx->width); |
|
|
|
|
print_int("height", dec_ctx->height); |
|
|
|
|
print_int("coded_width", dec_ctx->coded_width); |
|
|
|
|
print_int("coded_height", dec_ctx->coded_height); |
|
|
|
|
print_int("has_b_frames", dec_ctx->has_b_frames); |
|
|
|
|
print_int("width", par->width); |
|
|
|
|
print_int("height", par->height); |
|
|
|
|
if (dec_ctx) { |
|
|
|
|
print_int("coded_width", dec_ctx->coded_width); |
|
|
|
|
print_int("coded_height", dec_ctx->coded_height); |
|
|
|
|
} |
|
|
|
|
print_int("has_b_frames", par->video_delay); |
|
|
|
|
sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); |
|
|
|
|
if (sar.den) { |
|
|
|
|
print_q("sample_aspect_ratio", sar, ':'); |
|
|
|
|
av_reduce(&dar.num, &dar.den, |
|
|
|
|
dec_ctx->width * sar.num, |
|
|
|
|
dec_ctx->height * sar.den, |
|
|
|
|
par->width * sar.num, |
|
|
|
|
par->height * sar.den, |
|
|
|
|
1024*1024); |
|
|
|
|
print_q("display_aspect_ratio", dar, ':'); |
|
|
|
|
} else { |
|
|
|
|
print_str_opt("sample_aspect_ratio", "N/A"); |
|
|
|
|
print_str_opt("display_aspect_ratio", "N/A"); |
|
|
|
|
} |
|
|
|
|
s = av_get_pix_fmt_name(dec_ctx->pix_fmt); |
|
|
|
|
s = av_get_pix_fmt_name(par->format); |
|
|
|
|
if (s) print_str ("pix_fmt", s); |
|
|
|
|
else print_str_opt("pix_fmt", "unknown"); |
|
|
|
|
print_int("level", dec_ctx->level); |
|
|
|
|
if (dec_ctx->color_range != AVCOL_RANGE_UNSPECIFIED) |
|
|
|
|
print_str ("color_range", av_color_range_name(dec_ctx->color_range)); |
|
|
|
|
print_int("level", par->level); |
|
|
|
|
if (par->color_range != AVCOL_RANGE_UNSPECIFIED) |
|
|
|
|
print_str ("color_range", av_color_range_name(par->color_range)); |
|
|
|
|
else |
|
|
|
|
print_str_opt("color_range", "N/A"); |
|
|
|
|
|
|
|
|
|
s = av_get_colorspace_name(dec_ctx->colorspace); |
|
|
|
|
s = av_get_colorspace_name(par->color_space); |
|
|
|
|
if (s) print_str ("color_space", s); |
|
|
|
|
else print_str_opt("color_space", "unknown"); |
|
|
|
|
|
|
|
|
|
if (dec_ctx->color_trc != AVCOL_TRC_UNSPECIFIED) |
|
|
|
|
print_str("color_transfer", av_color_transfer_name(dec_ctx->color_trc)); |
|
|
|
|
if (par->color_trc != AVCOL_TRC_UNSPECIFIED) |
|
|
|
|
print_str("color_transfer", av_color_transfer_name(par->color_trc)); |
|
|
|
|
else |
|
|
|
|
print_str_opt("color_transfer", av_color_transfer_name(dec_ctx->color_trc)); |
|
|
|
|
print_str_opt("color_transfer", av_color_transfer_name(par->color_trc)); |
|
|
|
|
|
|
|
|
|
if (dec_ctx->color_primaries != AVCOL_PRI_UNSPECIFIED) |
|
|
|
|
print_str("color_primaries", av_color_primaries_name(dec_ctx->color_primaries)); |
|
|
|
|
if (par->color_primaries != AVCOL_PRI_UNSPECIFIED) |
|
|
|
|
print_str("color_primaries", av_color_primaries_name(par->color_primaries)); |
|
|
|
|
else |
|
|
|
|
print_str_opt("color_primaries", av_color_primaries_name(dec_ctx->color_primaries)); |
|
|
|
|
print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries)); |
|
|
|
|
|
|
|
|
|
if (dec_ctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) |
|
|
|
|
print_str("chroma_location", av_chroma_location_name(dec_ctx->chroma_sample_location)); |
|
|
|
|
if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED) |
|
|
|
|
print_str("chroma_location", av_chroma_location_name(par->chroma_location)); |
|
|
|
|
else |
|
|
|
|
print_str_opt("chroma_location", av_chroma_location_name(dec_ctx->chroma_sample_location)); |
|
|
|
|
print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location)); |
|
|
|
|
|
|
|
|
|
#if FF_API_PRIVATE_OPT |
|
|
|
|
if (dec_ctx->timecode_frame_start >= 0) { |
|
|
|
|
if (dec_ctx && dec_ctx->timecode_frame_start >= 0) { |
|
|
|
|
char tcbuf[AV_TIMECODE_STR_SIZE]; |
|
|
|
|
av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start); |
|
|
|
|
print_str("timecode", tcbuf); |
|
|
|
@ -2245,40 +2256,41 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id |
|
|
|
|
print_str_opt("timecode", "N/A"); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
print_int("refs", dec_ctx->refs); |
|
|
|
|
if (dec_ctx) |
|
|
|
|
print_int("refs", dec_ctx->refs); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case AVMEDIA_TYPE_AUDIO: |
|
|
|
|
s = av_get_sample_fmt_name(dec_ctx->sample_fmt); |
|
|
|
|
s = av_get_sample_fmt_name(par->format); |
|
|
|
|
if (s) print_str ("sample_fmt", s); |
|
|
|
|
else print_str_opt("sample_fmt", "unknown"); |
|
|
|
|
print_val("sample_rate", dec_ctx->sample_rate, unit_hertz_str); |
|
|
|
|
print_int("channels", dec_ctx->channels); |
|
|
|
|
print_val("sample_rate", par->sample_rate, unit_hertz_str); |
|
|
|
|
print_int("channels", par->channels); |
|
|
|
|
|
|
|
|
|
if (dec_ctx->channel_layout) { |
|
|
|
|
if (par->channel_layout) { |
|
|
|
|
av_bprint_clear(&pbuf); |
|
|
|
|
av_bprint_channel_layout(&pbuf, dec_ctx->channels, dec_ctx->channel_layout); |
|
|
|
|
av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout); |
|
|
|
|
print_str ("channel_layout", pbuf.str); |
|
|
|
|
} else { |
|
|
|
|
print_str_opt("channel_layout", "unknown"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id)); |
|
|
|
|
print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id)); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case AVMEDIA_TYPE_SUBTITLE: |
|
|
|
|
if (dec_ctx->width) |
|
|
|
|
print_int("width", dec_ctx->width); |
|
|
|
|
if (par->width) |
|
|
|
|
print_int("width", par->width); |
|
|
|
|
else |
|
|
|
|
print_str_opt("width", "N/A"); |
|
|
|
|
if (dec_ctx->height) |
|
|
|
|
print_int("height", dec_ctx->height); |
|
|
|
|
if (par->height) |
|
|
|
|
print_int("height", par->height); |
|
|
|
|
else |
|
|
|
|
print_str_opt("height", "N/A"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) { |
|
|
|
|
if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) { |
|
|
|
|
const AVOption *opt = NULL; |
|
|
|
|
while (opt = av_opt_next(dec_ctx->priv_data,opt)) { |
|
|
|
|
uint8_t *str; |
|
|
|
@ -2299,12 +2311,14 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id |
|
|
|
|
print_time("start_time", stream->start_time, &stream->time_base); |
|
|
|
|
print_ts ("duration_ts", stream->duration); |
|
|
|
|
print_time("duration", stream->duration, &stream->time_base); |
|
|
|
|
if (dec_ctx->bit_rate > 0) print_val ("bit_rate", dec_ctx->bit_rate, unit_bit_per_second_str); |
|
|
|
|
if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str); |
|
|
|
|
else print_str_opt("bit_rate", "N/A"); |
|
|
|
|
if (dec_ctx->rc_max_rate > 0) print_val ("max_bit_rate", dec_ctx->rc_max_rate, unit_bit_per_second_str); |
|
|
|
|
else print_str_opt("max_bit_rate", "N/A"); |
|
|
|
|
if (dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample); |
|
|
|
|
else print_str_opt("bits_per_raw_sample", "N/A"); |
|
|
|
|
#if FF_API_LAVF_AVCTX |
|
|
|
|
if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str); |
|
|
|
|
else print_str_opt("max_bit_rate", "N/A"); |
|
|
|
|
#endif |
|
|
|
|
if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample); |
|
|
|
|
else print_str_opt("bits_per_raw_sample", "N/A"); |
|
|
|
|
if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames); |
|
|
|
|
else print_str_opt("nb_frames", "N/A"); |
|
|
|
|
if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]); |
|
|
|
@ -2312,10 +2326,10 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id |
|
|
|
|
if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]); |
|
|
|
|
else print_str_opt("nb_read_packets", "N/A"); |
|
|
|
|
if (do_show_data) |
|
|
|
|
writer_print_data(w, "extradata", dec_ctx->extradata, |
|
|
|
|
dec_ctx->extradata_size); |
|
|
|
|
writer_print_data_hash(w, "extradata_hash", dec_ctx->extradata, |
|
|
|
|
dec_ctx->extradata_size); |
|
|
|
|
writer_print_data(w, "extradata", par->extradata, |
|
|
|
|
par->extradata_size); |
|
|
|
|
writer_print_data_hash(w, "extradata_hash", par->extradata, |
|
|
|
|
par->extradata_size); |
|
|
|
|
|
|
|
|
|
/* Print disposition information */ |
|
|
|
|
#define PRINT_DISPOSITION(flagname, name) do { \ |
|
|
|
@ -2373,9 +2387,9 @@ static int show_streams(WriterContext *w, InputFile *ifile) |
|
|
|
|
int i, ret = 0; |
|
|
|
|
|
|
|
|
|
writer_print_section_header(w, SECTION_ID_STREAMS); |
|
|
|
|
for (i = 0; i < fmt_ctx->nb_streams; i++) |
|
|
|
|
for (i = 0; i < ifile->nb_streams; i++) |
|
|
|
|
if (selected_streams[i]) { |
|
|
|
|
ret = show_stream(w, fmt_ctx, i, 0); |
|
|
|
|
ret = show_stream(w, fmt_ctx, i, &ifile->streams[i], 0); |
|
|
|
|
if (ret < 0) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -2384,8 +2398,9 @@ static int show_streams(WriterContext *w, InputFile *ifile) |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int show_program(WriterContext *w, AVFormatContext *fmt_ctx, AVProgram *program) |
|
|
|
|
static int show_program(WriterContext *w, InputFile *ifile, AVProgram *program) |
|
|
|
|
{ |
|
|
|
|
AVFormatContext *fmt_ctx = ifile->fmt_ctx; |
|
|
|
|
int i, ret = 0; |
|
|
|
|
|
|
|
|
|
writer_print_section_header(w, SECTION_ID_PROGRAM); |
|
|
|
@ -2406,7 +2421,7 @@ static int show_program(WriterContext *w, AVFormatContext *fmt_ctx, AVProgram *p |
|
|
|
|
writer_print_section_header(w, SECTION_ID_PROGRAM_STREAMS); |
|
|
|
|
for (i = 0; i < program->nb_stream_indexes; i++) { |
|
|
|
|
if (selected_streams[program->stream_index[i]]) { |
|
|
|
|
ret = show_stream(w, fmt_ctx, program->stream_index[i], 1); |
|
|
|
|
ret = show_stream(w, fmt_ctx, program->stream_index[i], &ifile->streams[program->stream_index[i]], 1); |
|
|
|
|
if (ret < 0) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -2428,7 +2443,7 @@ static int show_programs(WriterContext *w, InputFile *ifile) |
|
|
|
|
AVProgram *program = fmt_ctx->programs[i]; |
|
|
|
|
if (!program) |
|
|
|
|
continue; |
|
|
|
|
ret = show_program(w, fmt_ctx, program); |
|
|
|
|
ret = show_program(w, ifile, program); |
|
|
|
|
if (ret < 0) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -2562,21 +2577,44 @@ static int open_input_file(InputFile *ifile, const char *filename) |
|
|
|
|
|
|
|
|
|
ist->st = stream; |
|
|
|
|
|
|
|
|
|
if (stream->codec->codec_id == AV_CODEC_ID_PROBE) { |
|
|
|
|
if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) { |
|
|
|
|
av_log(NULL, AV_LOG_WARNING, |
|
|
|
|
"Failed to probe codec for input stream %d\n", |
|
|
|
|
stream->index); |
|
|
|
|
} else if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
codec = avcodec_find_decoder(stream->codecpar->codec_id); |
|
|
|
|
if (!codec) { |
|
|
|
|
av_log(NULL, AV_LOG_WARNING, |
|
|
|
|
"Unsupported codec with id %d for input stream %d\n", |
|
|
|
|
stream->codec->codec_id, stream->index); |
|
|
|
|
} else { |
|
|
|
|
AVDictionary *opts = filter_codec_opts(codec_opts, stream->codec->codec_id, |
|
|
|
|
stream->codecpar->codec_id, stream->index); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
AVDictionary *opts = filter_codec_opts(codec_opts, stream->codecpar->codec_id, |
|
|
|
|
fmt_ctx, stream, codec); |
|
|
|
|
if (avcodec_open2(stream->codec, codec, &opts) < 0) { |
|
|
|
|
|
|
|
|
|
ist->dec_ctx = avcodec_alloc_context3(codec); |
|
|
|
|
if (!ist->dec_ctx) |
|
|
|
|
exit(1); |
|
|
|
|
|
|
|
|
|
err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar); |
|
|
|
|
if (err < 0) |
|
|
|
|
exit(1); |
|
|
|
|
|
|
|
|
|
ist->dec_ctx->pkt_timebase = stream->time_base; |
|
|
|
|
#if FF_API_LAVF_AVCTX |
|
|
|
|
ist->dec_ctx->time_base = stream->codec->time_base; |
|
|
|
|
ist->dec_ctx->framerate = stream->codec->framerate; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) { |
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n", |
|
|
|
|
stream->index); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { |
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n", |
|
|
|
|
t->key, stream->index); |
|
|
|
@ -2592,12 +2630,11 @@ static int open_input_file(InputFile *ifile, const char *filename) |
|
|
|
|
static void close_input_file(InputFile *ifile) |
|
|
|
|
{ |
|
|
|
|
int i; |
|
|
|
|
AVFormatContext *fmt_ctx = ifile->fmt_ctx; |
|
|
|
|
|
|
|
|
|
/* close decoder for each stream */ |
|
|
|
|
for (i = 0; i < fmt_ctx->nb_streams; i++) |
|
|
|
|
if (fmt_ctx->streams[i]->codec->codec_id != AV_CODEC_ID_NONE) |
|
|
|
|
avcodec_close(fmt_ctx->streams[i]->codec); |
|
|
|
|
for (i = 0; i < ifile->nb_streams; i++) |
|
|
|
|
if (ifile->streams[i].st->codecpar->codec_id != AV_CODEC_ID_NONE) |
|
|
|
|
avcodec_free_context(&ifile->streams[i].dec_ctx); |
|
|
|
|
|
|
|
|
|
av_freep(&ifile->streams); |
|
|
|
|
ifile->nb_streams = 0; |
|
|
|
|