When I used AndroidFFmpeg to play audio file (MP3 file), I got issue
header missing while seeking.
Video play is ok; error occurs only in mp3 file.
Anyone knows how to fix it?
I have a temporary solution to fix it. In mpegaudiodec.c, you comment out errors return:
header = AV_RB32(buf);
if (header>>8 == AV_RB32("TAG")>>8) {
av_log(avctx, AV_LOG_DEBUG, "discarding ID3 tag\n");
return buf_size;
}
if (ff_mpa_check_header(header) < 0) {
av_log(avctx, AV_LOG_ERROR, "Header missing\n");
//return AVERROR_INVALIDDATA; do not return errors
}
Related
When I try to execute "play" with loop on file that not exist, I got exaption "stack_overflow".
I use Qt 5.15.2 and windows 7
playlist->addMedia(QUrl::fromLocalFile("not_exist"));
playlist->setPlaybackMode(QMediaPlaylist::Loop);
QMediaPlayer *music = new QMediaPlayer();
music->setPlaylist(playlist);
music->play();
Can I catch this exception or maybe I can use another way to run sound in the loop to exclude this problem?
You have to use the error signal of QMediaPlayer:
connect(music, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error),
[music](QMediaPlayer::Error error){
qDebug() << error << music->errorString();
});
Output:
QMediaPlayer::ResourceError "Could not open resource for reading."
I am using fluent-ffmpeg to resize a video.
I can't figure out what's happening though. I have 2 video files, one works but the other doesn't. I've been scouring the mediainfo outputs of both files, checking for discrepancies but other than filesize, duration etc. there's no difference (same codec, format, width/height, frame rate etc)
Here's a link to both files.
I've been reading these video files into fluent-ffmpeg using an input stream, as so:
await new Promise((resolve, reject) => {
ffmpeg(file.stream)
.output(path)
.size('426x240')
.on('start', function() {
console.log('started');
})
.on('error', function(err) {
console.log('An error occurred: ' + err.message);
})
.on('progress', function(progress) {
console.log('... frames: ' + progress.frames);
})
.on('end', function() {
console.log('Finished processing');
resolve();
})
.run();
});
The working file prints:
started
... frames: 86
... frames: 107
Finished processing
But the non-working file doesn't seem to have any frames, and prints:
started
... frames: 0
Finished processing
Any idea what could be wrong?
The ffmpeg command being executed:
ffmpeg -i pipe:0 -y -filter:v scale=w=426:h=240 uploads/works.mp4
I've been scouring the mediainfo outputs of both files, checking for discrepancies but other than filesize, duration etc. there's no difference
It does, but in full mode only. try mediainfo -f on the files, you'll see:
IsStreamable : Yes
for the working file, and
IsStreamable : No
For the non working file.
a "no" here means that the input needs to support seek (header is at the end, player needs to seek to end for parsing header then seek back to beginning for parsing data).
It seems like ffmpeg have problem probing the file when you pass it as a stream. But it does work if you pass it as a file. Could be because probing/demuxer can optionally use seeks etc. I tried to increase the probe buffer but didn't get it to work.
This do not work:
cat doesnt_work.mp4 | ffmpeg -i pipe:0 test.mp4
But this works:
ffmpeg -i doesnt_work.mp4 test.mp4
I am trying to make a simple av player, and in some cases I am getting values correctly as below:
checking /media/timecapsule/Music/02 Baawre.mp3
[mp3 # 0x7f0698005660] Skipping 0 bytes of junk at 2102699.
dur is 4396400640
duration is 311
However, in other places, I am getting negative durations:
checking /media/timecapsule/Music/01 Just Chill.mp3
[mp3 # 0x7f0694005f20] Skipping 0 bytes of junk at 1318922.
dur is -9223372036854775808
duration is -653583619391
I am not sure what's causing the duration to end up negative only in some audio files. Any ideas to where I might be wrong are welcome!
Source code here https://github.com/heroic/musika/blob/master/player/library.c
I would suggest two things:
1. Make sure that failed files are not corrupt, i.e. you can use ffmpeg command line tool to dump details.
2. Break this in 2 if conditions to avoid order of operation and ensure open succeeded.
if(!(avformat_open_input(&container, name, NULL, NULL) < 0 && avformat_find_stream_info(container, NULL) < 0)) {
Also you can use av_dump_format to ensure that it headers are correct. See ex - https://www.ffmpeg.org/doxygen/2.8/avio_reading_8c-example.html#a24
Ketan
I've copied a .bat-file from Qt-ressources to a file system and executed it.
After that I wanted to delete the file, but it fails in Qt. If fails also when I restart the application. However, the file can be removed in the file-explorer.
I tried QFile::remove as well as QDir::remove. Static as well as not-static versions - no effect.
I tried to call using native file-separator - didn't help either.
What is wrong with this code?
if ( QFileInfo( dataRootPath+"/backupdb.bat" ).exists() )
{
//debugger stepps in
QFile f( QFileInfo( dataRootPath+"/backupdb.bat" ).canonicalFilePath());
f.remove( );
}
I had the same problem copying file from resources to file system and trying to remove it after that. QFile::errorString() returns "Access denied". So it seems that resource file has some nasty permissions that are copied by QFile::copy. May be it's possible to change permissions but I used my own 2 functions to copy file:
bool copyTextFile(QString srcPath, QString dstPath)
{
QFile file(srcPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
return writeTextFile(QString::fromUtf8(file.readAll()), dstPath);
}
bool writeTextFile(QString data, QString dstPath)
{
QFile file(dstPath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
QTextStream stream(&file);
stream << data;
return true;
}
I change its permissions before remove it.
QFile::copy(":/res/1.txt", "D:\\1.txt");
QFile file("D:\\1.txt");
file.setPermissions(file.permissions() |
QFileDevice::WriteOwner |
QFileDevice::WriteUser |
QFileDevice::WriteGroup |
QFileDevice::WriteOther);
file.remove();
I encountered the same error, but in my case the posted solutions did not work. However, it turned out that I had created a std::ofstream object in my code, that was unclosed. Thus, this was keeping the source file open which prevented the copying on Windows.
I wrote a test application to play '.wav' audio files using qt(latest version) on mac (OSX Yosemite Version 10.10.5). Here is the code from cpp file.
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
m_player = new QMediaPlayer(this);
connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(onMediaStatusChanged()));
connect(m_player, SIGNAL(positionChanged(qint64)), this, SLOT(onProgressed(qint64)));
m_player->setMedia(QMediaContent(QUrl("/Users/testUser/Library/Metal.wav")));
m_player->play();
}
Widget::~Widget()
{
}
void Widget::onProgressed(qint64 pos)
{
qDebug()<<"Position is:"<<pos;
}
void Widget::onMediaStatusChanged()
{
qDebug()<<"Media Status Changed:" << m_player->mediaStatus() << " " << m_player->error();
}
and here is the output I am getting
Media Status Changed: QMediaPlayer::LoadingMedia QMediaPlayer::NoError
[11:16:13.300] FigByteFlumeCustomURLOpen signalled err=-12936 (kFigByteFlumeError_BadState) (no provider) at /SourceCache/CoreMedia/CoreMedia-1562.240/Prototypes/FigHTTP/FigByteFlumeCustomURL.c line 1486
Media Status Changed: QMediaPlayer::InvalidMedia QMediaPlayer::FormatError
I don't understand why I am getting Format error and however, the same code (except the path of the track) in windows is working fine.
Is there a fix for QMediaPlayer on Mac or Should I be using other APIs to play .wav files?
Any help would be appreciated! Thanks.
I suspect the reason of the failure (or at least one of them) is that you are passing a file path to QUrl instead of a URL. So either you set "file:///Users/testUser/Library/Metal.wav" or you use QUrl::fromLocalFile("/Users/testUser/Library/Metal.wav").