‘壹’ 做跨平台app必须的会web吗
是一定要会的
webapp可以通过互联网上的第三方app开发平台实现,比如“应用之星”等网站;
跨平台app一般都要程序猿写代码开发,得有一定的预算请人才行,
要能成功编译出官方Web源码,需完整下载三部分。一是Web核心代码,大概30M;二是第三方支持库,像BoringSSL、libvpx、ffmpeg等等。
‘贰’ QT Web引擎支持rtsp流吗
支持
qt客户端实时播放rtsp音频流demo并且无杂音
推流工具使用EasyDarwin
推流直接使用ffmpeg 推流到 EasyDarwin 服务器,音频流取自电脑拾音器,ffmepg指令为:
ffmpeg -f dshow -i audio=“麦克风 (Realtek® Audio)” -codec:a aac -ac 2 -ar 16000 -f rtsp rtsp://10.1.3.170:554/3_a.sdp
至于怎么推流自行网络呀
客户端采用FFMPEG 取流,解析出PCM 音频裸流,在一个线程中接收rtsp流并解析出音频数据,具体代码如下PlayVoicePlayer.c:
#include "playvoiceplayer.h"
#include <QDebug>
PlayVoicePlayer::PlayVoicePlayer(QObject *parent) : QThread(parent)
{
}
void PlayVoicePlayer::startPlay(QString url)
{
qDebug() << "Video2PCM::startPlay()";
playUrl = url;
unGetStream = true;
this->start();
}
void PlayVoicePlayer::run()
{
qDebug() << "Video2PCM::run():"<<playUrl;
isStart = true;
AVFormatContext *pFormatCtx = NULL;
AVCodecContext *pCodecCtx = NULL;
AVCodec *pCodec = NULL;
AVPacket packet;
AVFrame *pAudioFrame = NULL;
uint8_t *buffer = NULL;
struct SwrContext *audio_convert_ctx = NULL;
int got_picture;
int audioIndex;
int out_buffer_size;
av_register_all();
if (avformat_open_input(&pFormatCtx, playUrl.toStdString().data(), NULL, NULL) != 0)
{
emit getPcmStreamStop();
qDebug()<< " Video2PCM Couldn't open an input stream.";
return;
}
pFormatCtx->probesize = 5 *1024; //使用1000*1024 延时大概是2秒开始开始播放1920*1080使用这个参数暂时没发新崩溃的情况
pFormatCtx->max_analyze_ration = 1 * AV_TIME_BASE;
if (avformat_find_stream_info(pFormatCtx, NULL) < 0)
{
emit getPcmStreamStop();
qDebug()<< "Video2PCM Couldn't find stream information.";
return;
}
audioIndex = -1;
for (int i = 0; i < pFormatCtx->nb_streams; i++)
{
if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
{
audioIndex = i;
break;
}
}
if (audioIndex == -1)
{
emit getPcmStreamStop();
qDebug()<< "Video2PCM Couldn't find a audio stream.";
return;
}
pCodecCtx = pFormatCtx->streams[audioIndex]->codec;
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
if (pCodec == NULL) printf("Codec not found.\n");
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0)
{
emit getPcmStreamStop();
qDebug()<< "Video2PCM Could not open codec.";
return;
}
pAudioFrame = av_frame_alloc();
if (pAudioFrame == NULL)
{
emit getPcmStreamStop();
qDebug()<< "Video2PCM Could not alloc AVFrame";
return;
}
//音频输出参数
uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO;//声道格式
AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S32;//采样格式
int out_nb_samples = pCodecCtx->frame_size;//nb_samples: AAC-1024 MP3-1152
// int out_sample_rate = 44100;//采样率
int out_sample_rate = 16000;//采样率
int out_nb_channels = av_get_channel_layout_nb_channels(out_channel_layout);//根据声道格式返回声道个数
out_buffer_size = av_samples_get_buffer_size(NULL, out_nb_channels, out_nb_samples, out_sample_fmt, 1);
buffer = (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE);
audio_convert_ctx = swr_alloc();
if (audio_convert_ctx == NULL)
{
{
emit getPcmStreamStop();
qDebug()<< " Video2PCM Could not allocate SwrContext";
return;
}
}
swr_alloc_set_opts(audio_convert_ctx, out_channel_layout, out_sample_fmt,out_sample_rate,
pCodecCtx->channel_layout, pCodecCtx->sample_fmt, pCodecCtx->sample_rate, 0, NULL);
swr_init(audio_convert_ctx);
int index = 0;//计数器
while (isStart)
{
if(av_read_frame(pFormatCtx, &packet)<0)
{
emit getPcmStreamStop();
break;
}
if (packet.stream_index == audioIndex) {
if (avcodec_decode_audio4(pCodecCtx, pAudioFrame, &got_picture, &packet) < 0) {
qDebug() <<("Error in decoding audio frame.\n");
emit getPcmStreamStop();
break;
}
if (got_picture) {
// int dst_nb_samples = av_rescale_rnd(swr_get_delay(audio_convert_ctx, pAudioFrame->sample_rate) + pAudioFrame->nb_samples, pAudioFrame->sample_rate, pAudioFrame->sample_rate, AVRounding(1));
swr_convert(audio_convert_ctx, &buffer, MAX_AUDIO_FRAME_SIZE, (const uint8_t **)pAudioFrame->data, pAudioFrame->nb_samples);
if(unGetStream == true)
{
qDebug() << "Video2PCM unGetStream";
unGetStream =false;
emit getAudioStream();
}
// printf("index:%5d\t pts:%lld\t packet size:%d\n", index, packet.pts, packet.size);
//Write PCM
// fwrite(buffer, 1, out_buffer_size, fp_pcm);
emit decodePCM(packet.pts, QByteArray((char*)buffer, out_buffer_size));
index++;
}
}
av_free_packet(&packet);
}
qDebug() << "Video2PCM close1";
swr_free(&audio_convert_ctx);
av_free(buffer);
av_frame_free(&pAudioFrame);
avcodec_close(pCodecCtx);
avformat_close_input(&pFormatCtx);
isStart= false;
对应的PlayVoicePlayer.h文件如下:
#ifndef PLAYVOICEPLAYER_H
#define PLAYVOICEPLAYER_H
#include <QObject>
#include <QThread>
#ifdef _WINDOWS
extern "C"
{
#include "libavcodec\avcodec.h"
#include "libavformat\avformat.h"
#include "libswresample\swresample.h"
};
#else
extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswresample/swresample.h"
};
#endif
#include <QAudioFormat>
#include <QAudioOutput>
#define MAX_AUDIO_FRAME_SIZE 192000
class PlayVoicePlayer : public QThread
{
Q_OBJECT
public:
explicit PlayVoicePlayer(QObject *parent = nullptr);
void startPlay(QString url);
private:
bool isStart = true;
QString playUrl;
bool unGetStream;
signals:
void getPcmStreamStop();
void getAudioStream();
void decodePCM(qint64 pts, const QByteArray& pcm);
protected:
void run();
};
#endif // PLAYVOICEPLAYER_H
‘叁’ 有没有认识FFmpeg Webui这套程序
为什么要用带ui的?ffmpeg本来就可以用命令行来本地转视频格式,而且也免费,这种ui是给普通用户手动转码的,一般不需要。