summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-02-13 22:33:43 +0100
committerGravatar waker <wakeroid@gmail.com>2011-02-13 22:33:43 +0100
commitb2bea0dc42256b3660e527fec1091bcd8beff30a (patch)
tree8004cc3923c9678673b58e44867fda7d61b024fe /plugins
parent2673b30661b89d521028ff888e6b3029ab038fd2 (diff)
added properties to ffmpeg plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ffmpeg/ffmpeg.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/ffmpeg/ffmpeg.c b/plugins/ffmpeg/ffmpeg.c
index d0775c66..c155b04a 100644
--- a/plugins/ffmpeg/ffmpeg.c
+++ b/plugins/ffmpeg/ffmpeg.c
@@ -552,6 +552,32 @@ ffmpeg_insert (DB_playItem_t *after, const char *fname) {
// add metainfo
ffmpeg_read_metadata_internal (it, fctx);
+
+ int64_t fsize = -1;
+
+ DB_FILE *fp = deadbeef->fopen (it->fname);
+ if (fp) {
+ if (!fp->vfs->is_streaming ()) {
+ fsize = deadbeef->fgetlength (fp);
+ }
+ deadbeef->fclose (fp);
+ }
+
+ if (fsize >= 0 && duration > 0) {
+ char s[100];
+ snprintf (s, sizeof (s), "%lld", fsize);
+ deadbeef->pl_add_meta (it, ":FILE_SIZE", s);
+ snprintf (s, sizeof (s), "%d", av_get_bits_per_sample_format (ctx->sample_fmt));
+ deadbeef->pl_add_meta (it, ":BPS", s);
+ snprintf (s, sizeof (s), "%d", ctx->channels);
+ deadbeef->pl_add_meta (it, ":CHANNELS", s);
+ snprintf (s, sizeof (s), "%d", samplerate);
+ deadbeef->pl_add_meta (it, ":SAMPLERATE", s);
+ int br = (int)roundf(fsize / duration * 8 / 1000);
+ snprintf (s, sizeof (s), "%d", br);
+ deadbeef->pl_add_meta (it, ":BITRATE", s);
+ }
+
// free decoder
avcodec_close (ctx);
av_close_input_file(fctx);