-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request Player Basic Functions #417
Comments
Since the player sends audio frames, there are two options:
|
2 options there:
|
This is not yet supported, but looks it is possible to implement. Since QAudioSink is used from QtMM. Right now QAVAudioOutput is suggested to play audio, but it uses the audio format from the audio frames. But maybe it is possible to override channels. Will check |
The player guarantees that all frames are sent to an app, but it does not send empty frame on eof, cancel or stop. Btw QAVPlayer::stop() does not cancel the decoding, it pauses the pipeline: pauses decoding and sending frames. |
Thanks for your suggestion and answer. I'll try them as your suggest. |
But I want to toggle audio mute during video playing.
so I test with toggle mute or unmute during playing as your suggestion attach or unattach m_audioOutput.play(m_AudioFrame).
void handleAudioFrame(const QAVAudioFrame &frame) |
If you would like to toggle audio, looks the best way is handleAudioFrame(const QAVPlayer::audioFrame &frame ) {
if (!muted) m_audioOutput.play(frame);
} |
Yes. |
I test player in windows 10 64bit computer. in windows 7 32bit computer. Is the using hardware decoding depend upon hardware or windows? I apologize for log with picture. Next time I try with text. |
It depends on pixel format of the video frames, ffmpeg hw accel imp and if QAVPlayer supports it. Never tried Windows 7, About the log, do you see "Using hardware device context:" ? If not shown, means ffmpeg does not support AV_HWDEVICE_TYPE_D3D11VA. Suspicious that there is QIODevice: Cannot call seek, maybe you play from QIODevice and try to seek? |
It might be a bug, it is implemented there https://github.com/valbok/QtAVPlayer/blob/master/src/QtAVPlayer/qavaudiooutput.cpp#L186 Does it set the correct volume there? |
Thanks for your quick reply. |
is sound ok before seek? |
Yes sound is ok, before seek. After seek, volume cannot change especially old mpeg format video. Now I installed DirectX. sound is ok. |
yes, https://doc.qt.io/qt-5.15/qaudiooutput.html#setVolume btw volume is not related to ffmpeg, you receive audio frames and can render them using audio device |
Video Forward and Backward while video is playing. For fast forward, setSpeed can be used. But it is not backward. |
Originally forward/backward was implemented to send only one frame, and make a pause. What you mean about "fast forward playing", like increasing speed? |
FWD fast forward is playing faster forward speed eg. 2X, 3X, 4X faster than normal playback speed (like setSpeed) So I use eg. position + seek(10) per 1000 msec for fast forward. position - seek(10) per 1500 msec for fast backward (rewind) |
May I ask more questions?
|
Looks it is possible to workaround? Why you need timer here? Just do seek(pos+10/100/1000)? |
Nice to hear this. Just to make sure,
|
QtAVPlayer supports playing from QIODevice QFile file(QLatin1String(":/alarm.wav"));
file.open(QIODevice::ReadOnly));
player.setSource("alarm", &file); So you would need to implement QIODevice which will return raw data, which might be transmitted over network. Never tried myself, but AFAIK for some projects it was implemented reading from stdin and playing the stream. |
any iterating with network and decoding is done by ffmpeg, so it needs to find answer there. |
Maybe it is possible to inject external audio stream from ffmpeg filters. QtAVPlayer does not support this. Because audio frames are synchronized with video frames using pts. You can simulate yourself like 2 players: 1 for audio, 1 for video and when you collect all audio and video frames render them synchronously. |
If I do not use timer, single seek(pos+1000) will be done. |
Today, I learn and build AVPlayer, all functions are working. I use these resources: deployed test targets are: Windows 7 32bit, Windows 10 64bit, and Windows 11 64bit computers. I want to also build AVPlayer for macOS, iOS. I'll show my results after that. |
Last time I tried, did not have any issues, but you should be prepared to have some since Qt 5 is a bit outdated. |
#420 is this something helpful for you? |
|
When I test player on (China) Android TV Box with [Android 12 for TV), player not play video. Sound is play just 1 sec and video is not show. So I debug and get log. some part of log are: --------- beginning of main ...... 12-03 16:00:38.235 15339 27688 E omx_vdec_aw: anSubmitCopy:587: req vbs fail! maybe vbs buffer is full! require_size[5579] 12-03 16:00:59.917 15339 27688 E omx_vdec_aw: anSubmitCopy:587: req vbs fail! maybe vbs buffer is full! require_size[5579] 12-03 16:01:53.432 15339 27688 E omx_vdec_aw: anSubmitCopy:587: req vbs fail! maybe vbs buffer is full! require_size[5579] |
Is it rendering issue or decoding issue? |
Hi, I've Server and Client Player Projects. In My Client (Player), some parts of code are I found below codes are read a file as buffer and play it. `void AVPlayer::playBuffer()
}` How can I play received (QByteArray) during transferring? Thanks. |
You would need to implement QIODevice and provides bytes from it by Looks you have already seen this |
Thank valbok, |
In Windows But in Android. Could not find input format: "android_camera" I also check permission |
means |
Get Audio Only(raw data) QByteArray from MP4 file. I want (extract) audio as QByteArray from video file and send to client or play it. `QAVDemuxer d;
I think myData is audio raw data. But when I run it program is crack. In Debug Mode receive size is greater than mp4 file size and program is stop. |
This exactly what QAVPlayer does, it sends QAVAudioFrame to users, where you can get the data using QAVAudioFrame::data() which returns QByteArray |
How can I play extract audio qbytearray? I read a whole file as QByteArray and write to buffer and play buffer. But I extract audio frame.data() and write to buffer and play buffer. I get myData QByteArray from QAVAudioFrame frame.data() myBuffer->m_size = myData.size(); void playBuffer(QSharedPointer buffer) in Debug |
I can guess that audio mp3 is wrong extension here, since audio is raw WAV, so rename to tmp.wav |
reading from file (*.mp3 or *.mp4) into buffer then play from buffer. void playBuffer(QSharedPointer buffer) But, i play video and add audio qbytearray into myData during playback.
durationChanged 0 |
Sorry, still did not get, does it work? |
I want to get audio (QByteArray) from mp4 file and send it to client to play. I test it as two ways.
//write my audio qbytearray to Buffer.
{ It's not working. So. I read data (both audio and video) from mp4 and test it.
|
Sorry, just forgot, if you would like to play raw pcm data, you should use QAVAudioOutput, without QAVPlayer |
QAVAudioOutput m_ao; QAVAudioOutput can use QAVAudioFrame. How can I convert QByteArray myData to QAVAudioFrame? |
maybe we could introduce or event just use QAudioOutput from qt, why you need a wrapper here |
m_ao.play(m_af); //m_ao(m_af); missing .play. QAVAudioOutput::play can be used to play QAVAudioFrame. How can I use audio qbytearray in QAVAudioOutput? or |
QAVAudioFrame provides not only raw data but also its format. https://doc.qt.io/qt-5/qaudiooutput.html is used to play pcm data, and it is used by QAVAudioOutput. Suggesting to use it directly. |
Thank for your advice and quick replay. I'll try it as your suggestion. |
Audio RawData file or QAVAudioFrame.data() can by played by QAudioOutput. I get myData QByteArray from QAVAudioFrame frame.data() QBuffer buffer; I can play qbytearray data with QAudioOutput. But I want to use QtAVPlayer to play rawdata. How to play it? |
I test ffmpeg filters So I test
|
looks idea to reuse QAVAudioOutput to play not only audio frames is quite nice: #425 To play raw data you must know its format, and QAVPlayer does not actually "play", it parses, demuxes, decodes and synchronizes the streams. |
Never tested this and looks it is unsupported for now. |
|
Looks like |
Yes, I'll do it. |
Yes. |
If you don't mind, let's close the issue, and feel free to reopen in any case. |
I'm very interested your QtAVPlayer based on FFmpeg. Thanks for your contribution of source code.
I'll test it on Windows, Android, macOS and iOS.
May I ask some questions?
I search video player basic functions
audio mute,
audio channels(Left, Right, Mono, Stereo) not found in your code.
I use setFilter for channels, It's working. But I think player has basic channels function in it.
playback current position (video timeline)
I want to get current position of video for video time line.
So I get position of every sec with timer.
m_positionTimer.setInterval(1000); connect(&m_positionTimer, &QTimer::timeout, this, &MAVPlayer::updatePosition);
void updatePosition() { if (m_player.state() == QAVPlayer::PlayingState) { qint64 currentPosition = m_player.position() / 1000; emit positionChanged(currentPosition); } }
or Is there onPositionChange in your code?
Thanks.
The text was updated successfully, but these errors were encountered: