diff options
author | wm4 <wm4@nowhere> | 2014-09-01 23:47:27 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-01 23:47:27 +0200 |
commit | 5f14543668f77b552b6b7690ff274736df02a9cc (patch) | |
tree | 722a8ff1ccc6f93d04a32318da5f544a7a082e42 /demux/demux_lavf.c | |
parent | 8d92128f6b587095b9983b17c96b68125b038a27 (diff) | |
download | mpv-5f14543668f77b552b6b7690ff274736df02a9cc.tar.bz2 mpv-5f14543668f77b552b6b7690ff274736df02a9cc.tar.xz |
player: simplistic HLS bitrate selection
--hls-bitrate=min/max lets you select the min or max bitrate. That's it.
Something more sophisticated might be possible, but is probably not even
worth the effort.
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r-- | demux/demux_lavf.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 65a5264705..fda0698b9c 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -429,6 +429,19 @@ static void export_replaygain(demuxer_t *demuxer, sh_audio_t *sh, AVStream *st) #endif } +// Return a dictionary entry as (decimal) integer. +static int dict_get_decimal(AVDictionary *dict, const char *entry, int def) +{ + AVDictionaryEntry *e = av_dict_get(dict, entry, NULL, 0); + if (e && e->value) { + char *end = NULL; + long int r = strtol(e->value, &end, 10); + if (end && !end[0] && r >= INT_MIN && r <= INT_MAX) + return r; + } + return def; +} + static void handle_stream(demuxer_t *demuxer, int i) { lavf_priv_t *priv = demuxer->priv; @@ -505,13 +518,9 @@ static void handle_stream(demuxer_t *demuxer, int i) if (sd) sh_video->rotate = -av_display_rotation_get((uint32_t *)sd); #else - AVDictionaryEntry *rot = av_dict_get(st->metadata, "rotate", NULL, 0); - if (rot && rot->value) { - char *end = NULL; - long int r = strtol(rot->value, &end, 10); - if (end && !end[0]) - sh_video->rotate = r; - } + int rot = dict_get_decimal(st->metadata, "rotate", -1); + if (rot >= 0) + sh_video->rotate = rot; #endif sh_video->rotate = ((sh_video->rotate % 360) + 360) % 360; @@ -589,6 +598,7 @@ static void handle_stream(demuxer_t *demuxer, int i) AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); if (lang && lang->value) sh->lang = talloc_strdup(sh, lang->value); + sh->hls_bitrate = dict_get_decimal(st->metadata, "variant_bitrate", 0); } select_tracks(demuxer, i); |