
Recherche avancée
Médias (16)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (40)
-
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Keeping control of your media in your hands
13 avril 2011, parThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...) -
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)
Sur d’autres sites (5177)
-
Vinyl record animation with ffmpeg
14 avril 2023, par pabsdennIs it possible to archive this with ffmpeg ?


Basically I want to have a black or vinyl background, one circle for the cover and one circle for the hole. I then need to replace the cover with an image of 500x500px and let it rotate as loop with a certain speed.


Or is it better to automate it with e.g. After Effects ?


-
FFmpeg avcodec_open2 throws -22 ("Invalid Argument")
14 avril 2023, par stupidbutseekingI got stuck trying to write a simple video conversion using C++ and ffmpeg.


When trying to convert a video using FFmpeg, calling avcodec_open2 fails with the code "-22" which seems to be an "Invalid Argument"-error.


I can't figure out why it fails, nor what the invalid argument is. In the following snippet I create the output codec and pass its context the information from the source (code further down below).


The check for the "outputCodec" works and does not throw an error. As far as I know an "AVDictionary"-argument is optional. So I guess the reason for the error is the context.


const AVCodec* outputCodec = avcodec_find_encoder_by_name(codecName.c_str());

 if (!outputCodec)
 {
 std::cout << "Zielformat-Codec nicht gefunden" << std::endl;
 return -1;
 }

 AVCodecContext* outputCodecContext = avcodec_alloc_context3(outputCodec);
 outputCodecContext->bit_rate = bitRate;
 outputCodecContext->width = inputCodecContext->width;
 outputCodecContext->height = inputCodecContext->height;
 outputCodecContext->pix_fmt = outputCodec->pix_fmts[0];
 outputCodecContext->time_base = inputCodecContext->time_base;

 **int errorCode = avcodec_open2(outputCodecContext, outputCodec, NULL); //THIS RETURNS -22**
 if (errorCode != 0)
 {
 std::cout << "Fehler beim Öffnen des Zielformat-Codecs" << std::endl;
 return -1;
 }



Here is the code for getting the input file & context :


std::string inputFilename = "input_video.mp4";
 std::string outputFilename = "output.avi";
 std::string codecName = "mpeg4";
 int bitRate = 400000;

 AVFormatContext* inputFormatContext = NULL;
 if (avformat_open_input(&inputFormatContext, inputFilename.c_str(), NULL, NULL) != 0)
 {
 std::cout << "Fehler beim Öffnen der Eingabedatei" << std::endl;
 return -1;
 }

 [Do Video Stream Search)

 AVCodecParameters* inputCodecParameters = inputFormatContext->streams[videoStreamIndex]->codecpar;
 const AVCodec* inputCodec = avcodec_find_decoder(inputCodecParameters->codec_id);
 AVCodecContext* inputCodecContext = avcodec_alloc_context3(inputCodec);
 if (avcodec_parameters_to_context(inputCodecContext, inputCodecParameters) != 0)
 {
 std::cout << "Fehler beim Setzen des Eingabecodecs" << std::endl;
 return -1;
 }
 if (avcodec_open2(inputCodecContext, inputCodec, NULL) != 0)
 {
 std::cout << "Fehler beim Öffnen des Eingabecodecs" << std::endl;
 return -1;
 }



The purpose was simply to get started with ffmpeg in an own C++ project.


If it is of any need, I downloaded the ffmpeg libs from here. I used the gpl shared ones. The architecture is win x64. I referenced them through the project properties (additional libraries and so on).


I tried to convert a .mp4 video to an .avi video with an "mpeg4" compression.
I also tried other compressions like "libx264" but none worked.


I searched for the problem on stackoverflow but could not find the exact same problem. While its purpose is different this post is about the same error code when calling avcodec_open2. But its solution is not working for me. I inspected the watch for the "outputContext" while running the code and the codec_id, codec_type and format is set. I use the time_base from the input file. According to my understanding, this should be equal to the source. So I can not find out what I am missing.


Thanks in advance and sorry for my english.


And for completion, here is the whole method :


int TestConvert()
{
 std::string inputFilename = "input_video.mp4";
 std::string outputFilename = "output.avi";
 std::string codecName = "mpeg4";
 int bitRate = 400000;

 AVFormatContext* inputFormatContext = NULL;
 if (avformat_open_input(&inputFormatContext, inputFilename.c_str(), NULL, NULL) != 0)
 {
 std::cout << "Fehler beim Öffnen der Eingabedatei" << std::endl;
 return -1;
 }

 int videoStreamIndex = -1;
 for (unsigned int i = 0; i < inputFormatContext->nb_streams; i++)
 {
 if (inputFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
 {
 videoStreamIndex = i;
 break;
 }
 }

 AVCodecParameters* inputCodecParameters = inputFormatContext->streams[videoStreamIndex]->codecpar;
 const AVCodec* inputCodec = avcodec_find_decoder(inputCodecParameters->codec_id);
 AVCodecContext* inputCodecContext = avcodec_alloc_context3(inputCodec);
 if (avcodec_parameters_to_context(inputCodecContext, inputCodecParameters) != 0)
 {
 std::cout << "Fehler beim Setzen des Eingabecodecs" << std::endl;
 return -1;
 }
 if (avcodec_open2(inputCodecContext, inputCodec, NULL) != 0)
 {
 std::cout << "Fehler beim Öffnen des Eingabecodecs" << std::endl;
 return -1;
 }

 const AVCodec* outputCodec = avcodec_find_encoder_by_name(codecName.c_str());

 if (!outputCodec)
 {
 std::cout << "Zielformat-Codec nicht gefunden" << std::endl;
 return -1;
 }

 AVCodecContext* outputCodecContext = avcodec_alloc_context3(outputCodec);
 outputCodecContext->bit_rate = bitRate;
 outputCodecContext->width = inputCodecContext->width;
 outputCodecContext->height = inputCodecContext->height;
 outputCodecContext->pix_fmt = outputCodec->pix_fmts[0];
 outputCodecContext->time_base = inputCodecContext->time_base;

 int errorCode = avcodec_open2(outputCodecContext, outputCodec, NULL);
 if (errorCode != 0)
 {
 std::cout << "Fehler beim Öffnen des Zielformat-Codecs" << std::endl;
 return -1;
 }

 AVFormatContext* outputFormatContext = NULL;
 if (avformat_alloc_output_context2(&outputFormatContext, NULL, NULL, outputFilename.c_str()) != 0)
 {
 std::cout << "Fehler beim Erstellen des Ausgabe-Formats" << std::endl;
 return -1;
 }

 AVStream* outputVideoStream = avformat_new_stream(outputFormatContext, outputCodec);
 if (outputVideoStream == NULL)
 {
 std::cout << "Fehler beim Hinzufügen des Video-Streams zum Ausgabe-Format" << std::endl;
 return -1;
 }
 outputVideoStream->id = outputFormatContext->nb_streams - 1;
 AVCodecParameters* outputCodecParameters = outputVideoStream->codecpar;
 if (avcodec_parameters_from_context(outputCodecParameters, outputCodecContext) != 0)
 {
 std::cout << "Fehler beim Setzen des Ausgabe-Codecs" << std::endl;
 return -1;
 }

 if (!(outputFormatContext->oformat->flags & AVFMT_NOFILE))
 {
 if (avio_open(&outputFormatContext->pb, outputFilename.c_str(), AVIO_FLAG_WRITE) != 0)
 {
 std::cout << "Fehler beim Öffnen der Ausgabedatei" << std::endl;
 return -1;
 }
 }

 if (avformat_write_header(outputFormatContext, NULL) != 0)
 {
 std::cout << "Fehler beim Schreiben des Ausgabe-Formats in die Ausgabedatei" << std::endl;
 return -1;
 }

 AVPacket packet;
 int response;
 AVFrame* frame = av_frame_alloc();
 AVFrame* outputFrame = av_frame_alloc();
 while (av_read_frame(inputFormatContext, &packet) == 0)
 {
 if (packet.stream_index == videoStreamIndex)
 {
 response = avcodec_send_packet(inputCodecContext, &packet);
 while (response >= 0)
 {
 response = avcodec_receive_frame(inputCodecContext, frame);
 if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)
 {
 break;
 }
 else if (response < 0)
 {
 std::cout << "Fehler beim Dekodieren des Video-Pakets" << std::endl;
 return -1;
 }

 struct SwsContext* swsContext = sws_getContext(inputCodecContext->width, inputCodecContext->height, inputCodecContext->pix_fmt, outputCodecContext->width, outputCodecContext->height, outputCodecContext->pix_fmt, SWS_BILINEAR, NULL, NULL, NULL); if (!swsContext)
 {
 std::cout << "Fehler beim Erstellen des SwsContext" << std::endl;
 return -1;
 }
 sws_scale(swsContext, frame->data, frame->linesize, 0, inputCodecContext->height, outputFrame->data, outputFrame->linesize);
 sws_freeContext(swsContext);

 outputFrame->pts = frame->pts;
 outputFrame->pkt_dts = frame->pkt_dts;
 //outputFrame->pkt_duration = frame->pkt_duration;
 response = avcodec_send_frame(outputCodecContext, outputFrame);
 while (response >= 0)
 {
 response = avcodec_receive_packet(outputCodecContext, &packet);
 if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)
 {
 break;
 }
 else if (response < 0)
 {
 std::cout << "Fehler beim Kodieren des Ausgabe-Frames" << std::endl;
 return -1;
 }

 packet.stream_index = outputVideoStream->id;
 av_packet_rescale_ts(&packet, outputCodecContext->time_base, outputVideoStream->time_base);
 if (av_interleaved_write_frame(outputFormatContext, &packet) != 0)
 {
 std::cout << "Fehler beim Schreiben des Ausgabe-Pakets" << std::endl;
 return -1;
 }
 av_packet_unref(&packet);
 }
 }
 }
 av_packet_unref(&packet);
 }

 av_write_trailer(outputFormatContext);
 avcodec_free_context(&inputCodecContext);
 avcodec_free_context(&outputCodecContext);
 avformat_close_input(&inputFormatContext);
 avformat_free_context(inputFormatContext);
 avformat_free_context(outputFormatContext);
 av_frame_free(&frame);
 av_frame_free(&outputFrame);

 return 0;

}



-
How to Save an Image (Current Frame) from an RTSP, using FFMPEG ?
4 mars 2023, par spacemanI recently purchased a Security Camera,

and it provides an RTSP URL withwhich you can view the video.

So If I run the command
VLC rtsp://<ip>/etc</ip>
for example,

then I am successfully able to watch the stream from the camera.

My question is :

Does FFMPEG provide some command line operation for Saving one Image from an RTSP Stream to disk ?

That way I can run this command, and have a .PNG or .JPG file created on disk.