wang-bin / QtAV

A cross-platform multimedia framework based on Qt and FFmpeg. 基于Qt和FFmpeg的跨平台高性能音视频播放框架. Recommand to use new sdk https://github.com/wang-bin/mdk-sdk
http://qtav.org
3.86k stars 1.48k forks source link

No Audio on SailfishOS #505

Open ejjoman opened 8 years ago

ejjoman commented 8 years ago

Hello,

I try to include QtAV into my internet radio player app for SailfishOS in order to support more codecs and extended features compared to QtMulimedia.

I compiled the latest FFmpeg (2.7.2) and QtAV (1.8.0) according to your documentation:

The build process went fine. Then I included all needed files into my app and did some testing in QML and C++ side. I started by trying to play a live stream (http://217.151.151.90/stream4) and then tried to play a local mp3 file. But I could not get it to work. There simply is no audio output and no errors or other messages.

The only thing that happens is, that the player switches instantly from "Buffering" to "Buffered" state and after several seconds (2-3s) switches again to "Buffering" and so on...

I also tried different configurations of FFmpeg but with no success.

Is this a bug in QtAV, or did I something wrong?

Code samples: QML:

    AVPlayer {
        source: "/absolut/path/to/some.mp3" // same  with source: "http://217.151.151.90/stream4"

        autoLoad: true
        autoPlay: true

        onError: {
            console.log("[Audio]", "Error", error, errorString)
        }

        onStatusChanged: {
            console.log("[Audio]", "Status changed:", status)
        }

        onPlaybackStateChanged: {
            console.log("[Audio]", "PlaybackState changed:", playbackState)
        }

        onBufferProgressChanged: {
            console.log("[Audio]", "BufferProgress changed:", bufferProgress * 100)
        }
    }

Output:

[D] onStatusChanged:76 - [Audio] Status changed: 3
[D] onPlaybackStateChanged:80 - [Audio] PlaybackState changed: 1
[D] onStatusChanged:76 - [Audio] Status changed: 5
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 100
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 100
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 100
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 100
[D] onStatusChanged:76 - [Audio] Status changed: 6
[D] onStatusChanged:76 - [Audio] Status changed: 5
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 0
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 0
[D] onStatusChanged:76 - [Audio] Status changed: 6
[D] onStatusChanged:76 - [Audio] Status changed: 5
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 0
[D] onBufferProgressChanged:84 - [Audio] BufferProgress changed: 0
[D] onStatusChanged:76 - [Audio] Status changed: 6
... and so on ...

Thank you!

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26539265-no-audio-on-sailfishos?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github).
wang-bin commented 8 years ago

Add environment var QTAV_LOG=all and show me your log

ejjoman commented 8 years ago

Didn't know one can activate logging :)

# Starting application

[D] QtAV::Internal::print_library_info:129 - "QtAV 1.8.0(Sep  8 2015, 18:57:02)
A media playing library base on Qt and FFmpeg.
Distributed under the terms of LGPLv2.1 or later.
Shanghai University->S3 Graphics->Deepin, Shanghai, ChinaCopyright (C) 2012-2015 Wang Bin (aka. Lucas Wang) wbsecg1@gmail.com
Donate: http://www.qtav.org/donate.html
Source: https://github.com/wang-bin/QtAV
Home page: http://www.qtav.org" 
[D] QtAV::Internal::print_library_info:132 - "Build with Qt-5.2.2" 
[D] QtAV::Internal::print_library_info:132 - "Build with avutil-54.27.100" 
[D] QtAV::Internal::print_library_info:132 - "Build with avcodec-56.41.100" 
[D] QtAV::Internal::print_library_info:132 - "Build with avformat-56.36.100" 
[D] QtAV::Internal::print_library_info:132 - "Build with avfilter-5.16.101" 
[D] QtAV::Internal::print_library_info:132 - "Build with avdevice-56.4.100" 
[D] QtAV::Internal::print_library_info:132 - "Build with avresample-2.1.0" 
[D] QtAV::Internal::print_library_info:132 - "Build with swresample-1.2.100" 
[D] QtAV::Internal::print_library_info:132 - "Build with swscale-3.1.101" 
[D] QtAV::AudioOutput::AudioOutput:260 - Registered audio backends:  ("null", "Pulse") 

# Open stream
[D] QtAV::AVPlayer::loadInternal:682 - Loading  QVariant(QString, "http://217.151.151.90/stream4")  ... 
[D] QtAV::AVDemuxer::load:669 - "all closed and reseted" 
[D] QtAV::AVDemuxer::load:725 - "avformat_open_input: d->format_ctx:'0x4852faf0', url:'http://217.151.151.90/stream4'..." 
[D] QtAV::qtav_ffmpeg_log_callback:230 - "[FFmpeg:mp3] Skipping 0 bytes of junk at 0." 
[D] QtAV::AVDemuxer::load:727 - "avformat_open_input: url:'http://217.151.151.90/stream4' ret:0" 
[D] QtAV::AVDemuxer::load:771 - "avfmtctx.flag: 513" 
[D] QtAV::AVDemuxer::load:772 - "AVFMT_NOTIMESTAMPS: 0, AVFMT_TS_DISCONT: 512, AVFMT_NO_BYTE_SEEK:0" 
[D] onStatusChanged:344 - [Audio] Status changed: 3
[W] QtAV::AVDemuxer::setStreamIndex:842 - "invalid index 0 (valid is 0~0) for stream type 2." 
[D] QtAV::AVPlayer::Private::updateNotifyInterval:168 - "notify_interval: 500" 
[D] QtAV::AVPlayer::Private::initCommonStatistics:211 - "stream: 0, duration=-9223372036854775808 (-653583619391636 ms), time_base=0.000000" 
[D] QtAV::AVPlayer::Private::initCommonStatistics:217 - "codec: mp3(MP3 (MPEG audio layer 3))" 
[D] QtAV::AVPlayer::Private::setupAudioThread:300 - "has audio" 
[D] QtAV::AVPlayer::Private::setupAudioThread:345 - AudioOutput format:  QtAV::AudioFormat(44100Hz, 2Bytes, channelCount:2, channelLayout: "stereo", sampleFormat: "s16") 
[D] QtAV::AudioOutputPulse::init:273 - "PulseAudio 6.0.0, protocol: 30, server protocol: 4294967295" 
[W] QtAV::AudioResamplerFF::prepare:132 - "src audio parameters 'channel layout(or channels), sample rate and sample format must be set before initialize resampler" 
[D] QtAV::AVPlayer::Private::setupAudioThread:359 - "new audio thread" 
[D] QtAV::AVPlayer::Private::setupAudioThread:364 - "demux thread setAudioThread" 
[D] QtAV::AVPlayer::Private::setAVOutput:65 - "output not changed: 0x4a223cc0" 
[D] QtAV::AVPlayer::Private::setAVOutput:88 - "set AVThread output" 
[D] QtAV::AVPlayer::Private::initCommonStatistics:211 - "stream: 0, duration=-9223372036854775808 (-653583619391636 ms), time_base=0.000000" 
[D] QtAV::AVPlayer::Private::initCommonStatistics:217 - "codec: mp3(MP3 (MPEG audio layer 3))" 
[W] QtAV::AVDemuxer::setStreamIndex:842 - "invalid index 0 (valid is 0~0) for stream type 1." 
[D] QtAV::AVPlayer::playInternal:1214 - "auto select clock: audio > external" 
[D] QtAV::AVPlayer::playInternal:1219 - "Using AudioClock" 
[D] QtAV::AVPlayer::playInternal:1223 - "Clock initial value: 0.000000" 
[D] QtAV::AVPlayer::playInternal:1227 - "Starting audio thread..." 
[D] QtAV::AVDemuxThread::run:406 - "get av queue a/v thread = 0x4b9f5d90 0x0" 
[D] QtAV::AudioResamplerFF::prepare:173 - "swr speed=1.00" 
[D] QtAV::AudioResamplerFF::prepare:196 - "out: {cl: 3, fmt: s16, freq: 44100}" 
[D] QtAV::AudioResamplerFF::prepare:200 - "in {cl: 3, fmt: s16p, freq: 44100}" 
[D] onPlaybackStateChanged:355 - [Audio] PlaybackState changed: 1
[D] onStatusChanged:344 - [Audio] Status changed: 5
[D] QtAV::AVClock::start:139 - "AVClock started!!!!!!!!" 
[D] onStatusChanged:344 - [Audio] Status changed: 6
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[D] onStatusChanged:344 - [Audio] Status changed: 5
[D] onStatusChanged:344 - [Audio] Status changed: 6
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[D] onStatusChanged:344 - [Audio] Status changed: 5
[D] onStatusChanged:344 - [Audio] Status changed: 6
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[W] QtAV::AudioOutput::receiveData:430 - "ao backend maybe not open" 
[D] onStatusChanged:344 - [Audio] Status changed: 5
[D] onStatusChanged:344 - [Audio] Status changed: 6
# and so on...
wang-bin commented 8 years ago

I tested your live stream with other players. No sound. Local audio should work.

The buffering state changes frequently because for audio stream the default buffer value is 1. That means the state is buffered if it gets an audio data, but it will be played immediately and state changes to buffering state. There are c++ apis to change the bufferValue but not for qml. You can simply change the value 1LL to a larger one (for example 10) in AVPlayerPrivate.cpp@568

                        statistics.audio.frame_rate : 1LL;
ejjoman commented 8 years ago

That's odd. I tried another stream, that plays just fine on other players: http://188.94.97.90/rockland.mp3 It even works on my desktop build of QtAV.

I get the same result (ao backend maybe not open) with this stream and no audio (not even stutter or something).

I'll try with increased buffer size this evening.

wang-bin commented 8 years ago

I see pulseaudio is open and no error. Can you try openal? I tested with openal on emulator and it works.

There's no api to select an audio output in qml so you can change QtAV source code. In AudioOutput.cpp remove the line << QStringLiteral("Pulse") and then openal will be used

ejjoman commented 8 years ago

I'll test this this evening after my work. Just in case it makes any difference: I run this directly on the Jolla Phone (armv7hl).

Is there any reason why one can not adjust buffer settings and audio output in QML? Or is it just a matter of time to implement it?

wang-bin commented 8 years ago

I'm not sure if those APIs are important for users so they are not added.

ejjoman commented 8 years ago

Okay, but why should they be less important on QML side than on C++ side? :)

In my app I need to be able to adjust at least the buffer settings depending on user options and/or connectivity (wifi, mobile network). So this setting might be very interesting for me.

Should I try to add those settings to your QML implementation and do a merge request (when the other problems got sorted out)?

wang-bin commented 8 years ago

You are welcome