МихаилллApril 17, 2020, 11:02 a.m.
Qt and ffmpeg, как работать со звуком.
Добрый день.
Так получаю данные звука:
static struct SwsContext *img_convert_ctx; int videoStream, i, numBytes, audioStream; int ret, got_picture; avformat_network_init(); //初始化FFmpeg网络模块 av_register_all(); //初始化FFMPEG 调用了这个才能正常适用编码器和解码器 AVFormatContext *pFormatCtx = NULL; //Allocate an AVFormatContext. pFormatCtx = avformat_alloc_context(); // Open video file if(avformat_open_input(&pFormatCtx, "./Wildlife.wmv", 0, 0) != 0) qDebug()<<"Couldn't open file"; if(avformat_find_stream_info(pFormatCtx, NULL) < 0) qDebug()<<"Couldn't find stream information"; av_dump_format(pFormatCtx, 0, "./Wildlife.wmv", 0);//information abaut file //vide0 AVCodecContext *pCodecCtxOrig = NULL; AVCodecContext *pCodecCtx = NULL; //audio AVCodecContext *aCodecCtxOrig; AVCodecContext *aCodecCtx; // Find the first video and audio stream videoStream = -1; audioStream = -1; for(i=0; i < pFormatCtx->nb_streams; i++) { if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && videoStream < 0) { videoStream=i; } if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audioStream < 0) { audioStream=i; } } if(videoStream==-1) qDebug()<<"Didn't find a video stream"; if(audioStream==-1) qDebug()<<"Didn't find a audio stream"; // Get a pointer to the codec context for the video stream pCodecCtx=pFormatCtx->streams[videoStream]->codec; //audio aCodecCtxOrig=pFormatCtx->streams[audioStream]->codec; //aCodecCtx=pFormatCtx->streams[audioStream]->codec; //audio AVCodec *aCodec; aCodec = avcodec_find_decoder(aCodecCtxOrig->codec_id); if(!aCodec) { qDebug()<<"Unsupported codec!"; } // Copy context aCodecCtx = avcodec_alloc_context3(aCodec); if(avcodec_copy_context(aCodecCtx, aCodecCtxOrig) != 0) { qDebug()<<"Couldn't copy codec contextt"; } /* set up SDL Audio here */ avcodec_open2(aCodecCtx, aCodec, NULL);
Так предлогается работать со звуком с помощью STL:
wanted_spec.freq = aCodecCtx->sample_rate; wanted_spec.format = AUDIO_S16SYS; wanted_spec.channels = aCodecCtx->channels; wanted_spec.silence = 0; wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE; wanted_spec.callback = audio_callback; wanted_spec.userdata = aCodecCtx; if(SDL_OpenAudio(&wanted_spec, &spec) < 0) { fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError()); return -1; }
Начал делать так:
QAudioRecorder audioRecorder; QAudioEncoderSettings audioSettings; audioSettings.setCodec("audio/amr"); audioSettings.setQuality(QMultimedia::HighQuality); audioRecorder.setEncodingSettings(audioSettings);
Как правильно сделать воспроизведение с помощью Qt?
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Do you like it? Share on social networks!
AD
- Akiv Doros
- Nov. 12, 2024, 1:58 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:50points,
- Rating points-4
m
- molni99
- Oct. 26, 2024, 11:37 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
m
- molni99
- Oct. 26, 2024, 11:29 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:20points,
- Rating points-10
Last comments
Django - Tutorial 055. How to write auto populate field functionality Freckles because of several brand names retin a, atralin buy generic priligy
QML - Tutorial 035. Using enumerations in QML without C ++ priligy cvs 24 Together with antibiotics such as amphotericin B 10, griseofulvin 11 and streptomycin 12, chloramphenicol 9 is in the World Health Organisation s List of Essential Medici…
Qt/C++ - Lesson 052. Customization Qt Audio player in the style of AIMP It decreases stress, supports hormone balance, and regulates and increases blood flow to the reproductive organs buy priligy online safe Promising data were reported in a PDX model re…
Heap sorting algorithm The role of raloxifene in preventing breast cancer priligy precio
PyQt5 - Lesson 006. Work with QTableWidget buy priligy 60 mg 53 have been reported by Javanovic Santa et al
Now discuss on the forum
добавить qlineseries в функции buy priligy senior brother Chu He, whom he had known for many years
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
IscanderCheNov. 1, 2024, 1:43 a.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…
ИМ
Реализация навигации по разделам Спасибо Евгений!
Игорь МаксимовOct. 3, 2024, 2:05 p.m.
Добрый день
Могу только предположение высказать, что возможно формат кодека не соответствует, а также какие-то параметры не соотносятся.
Пробовли соотнести параметры настройки кодека Qt, а также библиотеки... SDL может всё-же?
Я похоже пользовался не теми инструментами Qt. А какие точно нужня я пока не знаю.