Commit fcc8b660 authored by Julian Rother's avatar Julian Rother

Added fileduration and filesize functions

parent 1a06687a
......@@ -13,6 +13,8 @@ char *mprintf(const char *fmt, ...);
void *xmalloc(size_t size);
char *hashfile(char *path);
double fileduration(char *path);
size_t filesize(char *path);
/* JSON av parsing */
void parse_dict(AVDictionary **d, char *s);
......
#include <libavformat/avformat.h>
#include "../util.h"
double fileduration(char *path)
{
double res;
AVFormatContext *demux;
demux = 0;
if (avformat_open_input(&demux, path, 0, 0) < 0)
return 0;
avformat_find_stream_info(demux, 0);
res = demux->duration*av_q2d(AV_TIME_BASE_Q);
avformat_close_input(&demux);
return res;
}
#include <unistd.h>
#include <sys/stat.h>
#include "../util.h"
size_t filesize(char *path)
{
struct stat s;
if (stat(path, &s))
return 0;
return s.st_size;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment