diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-10-09 21:19:15 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-10-09 21:19:15 +0000 |
| commit | c92c2f96b6ffbbf6969e28ba64953d32ed7ef509 (patch) | |
| tree | b4a0e5a464496390fc89f55330616dec1a0f4eb1 | |
| parent | 7fa9623e77e984ec5f792bef8ce911d36f717709 (diff) | |
| download | qmmp-c92c2f96b6ffbbf6969e28ba64953d32ed7ef509.tar.gz qmmp-c92c2f96b6ffbbf6969e28ba64953d32ed7ef509.tar.bz2 qmmp-c92c2f96b6ffbbf6969e28ba64953d32ed7ef509.zip | |
impoved ffmpeg plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7537 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp | 20 | ||||
| -rw-r--r-- | src/plugins/Input/ffmpeg/decoder_ffmpeg.h | 4 | ||||
| -rw-r--r-- | src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp | 25 |
3 files changed, 21 insertions, 28 deletions
diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp index 77ff3f0af..36d7bb9ef 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp @@ -81,7 +81,7 @@ DecoderFFmpeg::DecoderFFmpeg(const QString &path, QIODevice *i) m_decoded_frame = 0; m_channels = 0; c = 0; - wma_idx = 0; + audioIndex = 0; av_init_packet(&m_pkt); av_init_packet(&m_temp_pkt); } @@ -213,16 +213,18 @@ bool DecoderFFmpeg::initialize() ic->flags |= AVFMT_FLAG_GENPTS; av_read_play(ic); - for (wma_idx = 0; wma_idx < (int)ic->nb_streams; wma_idx++) + audioIndex = av_find_best_stream(ic, AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0); + if(audioIndex < 0) { + qWarning("DecoderFFmpeg: unable to find audio stream"); + return false; + } + #if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 - avcodec_parameters_to_context(c, ic->streams[wma_idx]->codecpar); + avcodec_parameters_to_context(c, ic->streams[audioIndex]->codecpar); #else - c = ic->streams[wma_idx]->codec; + c = ic->streams[audioIndex]->codec; #endif - if (c->codec_type == AVMEDIA_TYPE_AUDIO) - break; - } #if (LIBAVCODEC_VERSION_INT >= ((55<<16)+(34<<8)+0)) //libav-10: 55.34.1; ffmpeg-2.1: 55.39.100 if (c->channels == 1) @@ -367,7 +369,7 @@ qint64 DecoderFFmpeg::ffmpeg_decode() { int out_size = 0; int got_frame = 0; - if(m_pkt.stream_index == wma_idx) + if(m_pkt.stream_index == audioIndex) { #if (LIBAVCODEC_VERSION_INT >= ((55<<16)+(34<<8)+0)) //libav-10: 55.34.1; ffmpeg-2.1: 55.39.100 @@ -453,7 +455,7 @@ void DecoderFFmpeg::fillBuffer() m_temp_pkt.size = m_pkt.size; m_temp_pkt.data = m_pkt.data; - if(m_pkt.stream_index != wma_idx) + if(m_pkt.stream_index != audioIndex) { if(m_pkt.data) #if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(24<<8)+102)) //ffmpeg-3.0 diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h index 461440efd..ee3724802 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2016 by Ilya Kotov * + * Copyright (C) 2006-2017 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -54,7 +54,7 @@ private: AVFormatContext *ic; AVCodecContext *c; - int m_bitrate, wma_idx; + int m_bitrate, audioIndex; QString m_path; qint64 m_totalTime; diff --git a/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp b/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp index a493d4401..2e4dfbd80 100644 --- a/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp +++ b/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp @@ -48,28 +48,19 @@ QHash<QString, QString> FFmpegMetaDataModel::audioProperties() QString text = QString("%1").arg(int(m_in->duration/AV_TIME_BASE)/60); text +=":"+QString("%1").arg(int(m_in->duration/AV_TIME_BASE)%60,2,10,QChar('0')); ap.insert(tr("Length"), text); - ap.insert(tr("File size"), QString("%1 ").arg(avio_size(m_in->pb)) + " " + tr("KB")); - ap.insert(tr("Bitrate"), QString("%1 "+tr("kbps")).arg(m_in->bit_rate/1000)); + ap.insert(tr("File size"), tr("%1 KB").arg(avio_size(m_in->pb) / 1000)); + ap.insert(tr("Bitrate"), tr("%1 kbps").arg(m_in->bit_rate/1000)); -#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 - AVCodecParameters *c = 0; -#else - AVCodecContext *c = 0; -#endif - uint idx; - for (idx = 0; idx < m_in->nb_streams; idx++) + int idx = av_find_best_stream(m_in, AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0); + + if(idx >= 0) { #if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 - c = m_in->streams[idx]->codecpar; + AVCodecParameters *c = m_in->streams[idx]->codecpar; #else - c = m_in->streams[idx]->codec; + AVCodecContext *c = m_in->streams[idx]->codec; #endif - if (c->codec_type == AVMEDIA_TYPE_AUDIO) - break; - } - if (c) - { - ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(c->sample_rate)); + ap.insert(tr("Sample rate"), tr("%1 Hz").arg(c->sample_rate)); ap.insert(tr("Channels"), QString("%1").arg(c->channels)); } return ap; |
