Recherche avancée
Médias (39)
-
Zap Mama - Wadidyusay ?
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
David Byrne - My Fair Lady
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Beastie Boys - Now Get Busy
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (12)
-
MediaSPIP Init et Diogène : types de publications de MediaSPIP
11 novembre 2010, parÀ l’installation d’un site MediaSPIP, le plugin MediaSPIP Init réalise certaines opérations dont la principale consiste à créer quatre rubriques principales dans le site et de créer cinq templates de formulaire pour Diogène.
Ces quatre rubriques principales (aussi appelées secteurs) sont : Medias ; Sites ; Editos ; Actualités ;
Pour chacune de ces rubriques est créé un template de formulaire spécifique éponyme. Pour la rubrique "Medias" un second template "catégorie" est créé permettant d’ajouter (...) -
MediaSPIP Player : les contrôles
26 mai 2010, parLes contrôles à la souris du lecteur
En plus des actions au click sur les boutons visibles de l’interface du lecteur, il est également possible d’effectuer d’autres actions grâce à la souris : Click : en cliquant sur la vidéo ou sur le logo du son, celui ci se mettra en lecture ou en pause en fonction de son état actuel ; Molette (roulement) : en plaçant la souris sur l’espace utilisé par le média (hover), la molette de la souris n’exerce plus l’effet habituel de scroll de la page, mais diminue ou (...) -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)
Sur d’autres sites (515)
-
Capture desktop with gdigrab and save the result to video file using ffmpeg and C++
13 mai 2019, par SkunzI’m building a C++ application that is able to capture the screen and save the output to a file (.mkv, .mp4, doesn’t matter).
I tried to switch codecs and played with the AVCodecContext settings. When subsitute the gdi capture with reading from a static .mp4 file everything works fine.
Here is my gdigrab initalization.
_inputFormat = av_find_input_format("gdigrab");
if (!_inputFormat) {
std::cout << "Unable to open input Format" << std::endl;
exit(1);
}
if (avformat_open_input(&_screenFormatContext, "desktop", _inputFormat, &_recordOptions) < 0) {
std::cout << "Unable to open input stream" << std::endl;
exit(1);
}
if (avformat_find_stream_info(_screenFormatContext, &_recordOptions) < 0) {
std::cout << "Couldn't find input stream" << std::endl;
exit(1);
}
av_dump_format(_screenFormatContext, 0, "GDI Capture", 0);
for (int i = 0; i < _screenFormatContext->nb_streams; i++) {
if (_screenFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
_videoStreamIdx = i;
break;
}
}
if (_videoStreamIdx == -1) {
std::cout << "Unable to find video Stream" << std::endl;
exit(1);
}
_codecPar = _screenFormatContext->streams[_videoStreamIdx]->codecpar;Here is my setup code for the encoder and decoder.
/*
Decoder
*/
_dCodec = avcodec_find_decoder(_codecPar->codec_id);
if (!_dCodec) {
std::cout << "Unable to find decoder" << std::endl;
exit(1);
}
_dCodecContext = avcodec_alloc_context3(_dCodec);
if (avcodec_parameters_to_context(_dCodecContext, _codecPar) < 0) {
std::cout << "Unable to copy context" << std::endl;
exit(1);
}
if (avcodec_open2(_dCodecContext, _dCodec, NULL) < 0) {
std::cout << "Unable to open dCodec" << std::endl;
exit(1);
}
/*
Encoder
*/
_eCodec = avcodec_find_encoder(AV_CODEC_ID_H265);
if (!_eCodec) {
std::cout << "Unable to find encoder" << std::endl;
exit(1);
}
_eCodecContext = avcodec_alloc_context3(_eCodec);
//width and height have to be divisible by 2
if (_codecPar->width % 2 != 0)
_codecPar->width--;
if (_codecPar->height % 2 != 0)
_codecPar->height--;
_eCodecContext->pix_fmt = AV_PIX_FMT_YUV422P;
_eCodecContext->width = _codecPar->width;
_eCodecContext->height = _codecPar->height;
_eCodecContext->gop_size = 10;
_eCodecContext->max_b_frames = 1;
_eCodecContext->time_base.den = 30;
_eCodecContext->time_base.num = 1;
if (avcodec_open2(_eCodecContext, _eCodec, NULL) < 0) {
std::cout << "Unable to open eCodec" << std::endl;
exit(1);
}Here is my main loop. Grabbing the packets from gdi, decoding them and encoding them.
while (av_read_frame(_screenFormatContext, _pkt) == 0) {
if (_pkt->stream_index == _videoStreamIdx) {
if (_decodePacket() < 0)
exit(1);
_encodeFrame();
}
av_packet_unref(_pkt);
}And here the encoding/decoding functions
int ScreenRecorder::_decodePacket(void)
{
//send packet to decoder
int ret = avcodec_send_packet(_dCodecContext, _pkt);
if (ret < 0) {
std::cout << "error while sending packet to decoder" << std::endl;
return ret;
}
ret = avcodec_receive_frame(_dCodecContext, _frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return 0;
//Was there an error?
else if (ret < 0) {
std::cout << "Error with receiving frame" << std::endl;
exit(1);
}
//No errors -> got frame
std::cout << "Got frame " << _dCodecContext->frame_number << " with size " << _frame->pkt_size << std::endl;
char frame_filename[1024];
snprintf(frame_filename, sizeof(frame_filename), "%s-%d.pgm", "frame", _dCodecContext->frame_number);
//_saveGrayFrame(_frame->data[0], _frame->linesize[0], _frame->width, _frame->height, frame_filename);
return 0;
}
void ScreenRecorder::_encodeFrame(void)
{
AVPacket* pkt = av_packet_alloc();
// send frame to encoder - 0 on success
int ret = avcodec_send_frame(_eCodecContext, _frame);
if (ret < 0) {
std::cerr << "Unable to send frame! ERRORCODE: " << ret << std::endl;
exit(1);
}
while (ret == 0) {
ret = avcodec_receive_packet(_eCodecContext, pkt);
//Do I need to send more packets?
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
std::cout << "Needing one more packet " << std::endl;
av_packet_unref(pkt);
return ;
}
//Was there an error?
else if (ret < 0) {
std::cout << "Error with receiving packet" << std::endl;
exit(1);
}
//No errors -> got packet
std::cout << "Got packet " << pkt->pts << " of size " << pkt->size << std::endl;
if (av_write_frame(_outFormatContext, pkt) < 0) {
std::cout << "Unable to write frame" << std::endl;
exit(1);
}
av_packet_unref(pkt);
}
}In case you still need the header file
#ifndef SCREENRECORDER_HPP
# define SCREENRECORDER_HPP
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavdevice/avdevice.h"
#include "libavformat/avformat.h"
#include "libavformat/avio.h"
}
class ScreenRecorder
{
private:
AVCodecContext *_dCodecContext;
AVCodecContext *_eCodecContext;
AVFormatContext *_fileFormatContext;
AVFormatContext *_screenFormatContext;
AVFormatContext *_outFormatContext;
AVInputFormat *_inputFormat;
AVCodecParameters *_codecPar;
AVStream *_videoTrack;
AVCodec *_dCodec;
AVCodec *_eCodec;
AVFrame *_frame;
AVPacket *_pkt;
AVDictionary *_options;
AVDictionary *_recordOptions;
int _videoStreamIdx;
int _decodePacket(void);
void _encodeFrame(void);
void _openInputFile(void);
void _initalizeCodec(void);
void _initalizeOutputFile(void);
void _closeCodec(void);
void _initalizeGDI(void);
void _saveGrayFrame(unsigned char* buf, int wrap, int xsize, int ysize, char* filename);
public:
ScreenRecorder();
~ScreenRecorder();
void start();
};
#endifWhen I run my code I am getting Exception thrown at 0x00007FF819864A80 (msvcrt.dll) in Streaming.exe : 0xC0000005 : Access violation reading location 0x0000000000000EF0.
It comes from avcodec_send_frame function. Seems like I’m trying to access memory that wasn’t allocated.
I am new to the ffmpeg lib and hope that someone can get me on the right track. Thank you very much. If you have any questions please ask them. -
How to record screen and sound with gdigrab in ffmpeg ? [closed]
22 novembre 2019, par Nguyên PhươngI’m using window 10 and i want to record screen + sound (e.g sound of video) using ffmpeg.
I don’t know how to do it ! Help me ! -
FFMPEG gdigrab optimization Windows OS
20 septembre 2018, par chipimixI’m developing a python script to capture a video at 1 FPS.
This script will run on the background of a multiplayer videogame.As such, I’m trying to minimize performance impacts.
Additionally, I need the video format to be either .mp4, .webm or .ogg as it will be used in an HTML < video>.TLDR : Is there a more efficient way to capture a 1fps video other than this :
ffmpeg -f gdigrab -framerate 1-i desktop output.mp4
Maybe capturing as an .mkv and then converting it to another format ?
Thanks in Advance ![EDIT]
Should I be using this ?