39 case AVERROR(EIO):
return "-EIO";
40 case AVERROR(ENOMEM):
return "-ENOMEM";
41 case AVERROR(EINVAL):
return "-EINVAL";
55 snprintf(
buffer, 60,
"%c%"PRId64
".%06"PRId64
"", ts<0 ?
'-' :
' ',
FFABS(ts)/1000000,
FFABS(ts)%1000000);
58int main(
int argc,
char **argv)
62 int i,
ret, stream_id;
71 int seekfirst_stream = -1;
73 for(
i=2;
i<argc;
i+=2){
74 if (!strcmp(argv[
i],
"-seekforw")){
75 seekfirst = atoi(argv[
i+1]);
76 }
else if(!strcmp(argv[
i],
"-seekback")){
77 seekfirst = atoi(argv[
i+1]);
79 }
else if(!strcmp(argv[
i],
"-seekmin")){
80 seekfirst_min = atoi(argv[
i+1]);
81 }
else if(!strcmp(argv[
i],
"-stream_id")){
82 seekfirst_stream = atoi(argv[
i+1]);
83 }
else if(!strcmp(argv[
i],
"-frames")){
84 frame_count = atoi(argv[
i+1]);
85 }
else if(!strcmp(argv[
i],
"-duration")){
87 }
else if(!strcmp(argv[
i],
"-fastseek")) {
88 if (atoi(argv[
i+1])) {
91 }
else if(argv[
i][0] ==
'-' && argv[
i+1]) {
102 printf(
"usage: %s input_file\n"
112 fprintf(stderr,
"cannot open %s\n", filename);
118 fprintf(stderr,
"%s: could not find codec parameters\n", filename);
123 if(firstback)
avformat_seek_file(ic, seekfirst_stream, INT64_MIN, seekfirst, seekfirst, 0);
126 seekfirst, INT64_MAX, 0);
134 for(j=0; j<frame_count; j++) {
143 printf(
"ret:%-10s st:%2d flags:%d dts:%s pts:%s pos:%7" PRId64
" size:%6d",
ret_str(
ret),
pkt.stream_index,
pkt.flags, dts_buf, ts_buf,
pkt.pos,
pkt.size);
145 if (
skip && skip_size >= 8)
165 ts_str(ts_buf, timestamp, stream_id < 0 ? AV_TIME_BASE_Q : st->time_base);
166 printf(
"ret:%-10s st:%2d flags:%d ts:%s\n",
ret_str(
ret), stream_id,
i&1, ts_buf);
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define i(width, name, range_min, range_max)
AVDictionary * format_opts
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
__device__ int printf(const char *,...)
@ AV_PKT_DATA_SKIP_SAMPLES
Recommends skipping the specified number of samples.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_EOF
End of file.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE
Internal time base represented as integer.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int flags
Flags modifying the (de)muxer behaviour.
AVStream ** streams
A list of all streams in the file.
This structure stores compressed data.
Rational number (pair of numerator and denominator).
static const char * ret_str(int v)
static void ts_str(char buffer[60], int64_t ts, AVRational base)