
Recherche avancée
Autres articles (53)
-
MediaSPIP en mode privé (Intranet)
17 septembre 2013, parÀ partir de la version 0.3, un canal de MediaSPIP peut devenir privé, bloqué à toute personne non identifiée grâce au plugin "Intranet/extranet".
Le plugin Intranet/extranet, lorsqu’il est activé, permet de bloquer l’accès au canal à tout visiteur non identifié, l’empêchant d’accéder au contenu en le redirigeant systématiquement vers le formulaire d’identification.
Ce système peut être particulièrement utile pour certaines utilisations comme : Atelier de travail avec des enfants dont le contenu ne doit pas (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
Sur d’autres sites (4161)
-
Create new synced streaming from 2 inputs using FFMPEG library in C++ [libavformat]
23 janvier 2021, par blacksmithI wrote this program that connects to two RTMP streamings that are running in my machine.


Stream 1 has audio and video.


Stream 2 has only video.


When I print their timestamps i get different values for each stream, and every time i run the program, the difference between those 2 values changes. (I also attach the output)


I would like to create a 3rd streaming that mixes audio from the first streaming and video from the second one while syncing their timestamps.


I believe I should buffer the first stream and "wait" for the second stream to reach the same timestamp as the first one. Or maybe I'm wrong and I don't understand any of this. How should approach this problem ?


#include 
#include<iostream>
using namespace std;

extern "C"
{
 #include "libavcodec\avcodec.h"
 #include "libavformat\avformat.h"
}

int main() {

 // STREAM 1
 AVFormatContext* context1 = avformat_alloc_context();
 AVPacket packet1;
 AVFrame* frame1;
 int width1 = -1;
 int height1 = -1;
 int video_stream_index1 = -1;


 // STREAM 2
 AVFormatContext* context2 = avformat_alloc_context();
 AVPacket packet2;
 AVFrame* frame2;
 int width2 = -1;
 int height2 = -1;
 int video_stream_index2 = -1;

 avformat_network_init();

 // Opening Stream 1
 if (avformat_open_input(&context1, "rtmp://localhost/live/STREAM_NAME.flv", NULL, NULL) != 0)
 {
 avformat_close_input(&context1);
 return 0;
 }


 // Opening Stream 2
 if (avformat_open_input(&context2, "rtmp://localhost/live/STREAM_NAME2.flv", NULL, NULL) != 0)
 {
 avformat_close_input(&context2);
 return 0;
 }

 // Obtain info from Stream 1
 if (avformat_find_stream_info(context1, NULL) < 0)
 {
 avformat_close_input(&context1);
 return 0;
 }

 // Obtain info from Stream 2
 if (avformat_find_stream_info(context2, NULL) < 0)
 {
 avformat_close_input(&context2);
 return 0;
 }
 cout << "CONTEXT 1 NUMBER OF STREAMS DETECTED: " << context1->nb_streams << "\n";
 cout << "CONTEXT 2 NUMBER OF STREAMS DETECTED: " << context2->nb_streams << "\n";

 //Width and Height Stream 1
 for (int i = 0; i < context1->nb_streams; i++) {
 if (context1->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 video_stream_index1 = i;
 width1 = context1->streams[i]->codecpar->width;
 height1 = context1->streams[i]->codecpar->height;
 }
 }
 //Width and Height Stream 2
 for (int i = 0; i < context2->nb_streams; i++) {
 if (context2->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 video_stream_index2 = i;
 width2 = context2->streams[i]->codecpar->width;
 height2 = context2->streams[i]->codecpar->height;
 }
 }

 cout << "START TIME STREAM 1:" << context1->start_time << "\n";
 cout << "START TIME STREAM 2:" << context2->start_time << "\n";

 while (true) {
 if (av_read_frame(context1, &packet1) >= 0) {
 if (packet1.stream_index == video_stream_index1) {
 cout << "TS STREAM 1:" << packet1.dts << "\n";
 }
 } 
 if (av_read_frame(context2, &packet2) >= 0) {
 if (packet2.stream_index == video_stream_index2) {
 cout << "TS STREAM 2:" <code></iostream>


Output :


CONTEXT 1 NUMBER OF STREAMS DETECTED: 3
CONTEXT 2 NUMBER OF STREAMS DETECTED: 2
START TIME STREAM 1:10799753000
START TIME STREAM 2:158654000
TS STREAM 1:10799746
TS STREAM 2:158654
TS STREAM 2:158673
TS STREAM 2:158692
TS STREAM 1:10799788
TS STREAM 2:158712
TS STREAM 2:158731
TS STREAM 2:158750
TS STREAM 1:10799830
TS STREAM 2:158769
TS STREAM 2:158788
TS STREAM 2:158808
TS STREAM 1:10799872
TS STREAM 2:158827
TS STREAM 2:158846
TS STREAM 1:10799913
TS STREAM 2:158865
TS STREAM 2:158885
TS STREAM 2:158904
TS STREAM 1:10799955
TS STREAM 2:158923
TS STREAM 2:158942
TS STREAM 2:158962
TS STREAM 1:10799997
TS STREAM 2:158981
TS STREAM 2:159000
...



-
Revert "mpeg4videodec : raise an error if sprite_trajectory.table is NULL"
23 janvier 2021, par Andreas RheinhardtRevert "mpeg4videodec : raise an error if sprite_trajectory.table is NULL"
This reverts commit 6ac0e7818399a57e4684202bac79f35b3561ad1e.
The mpeg4video parser can reach code that presumes that a certain VLC
has been initialized ; yet Libav did not ensure this and Libav bug #1012
[1] is about an ensuing crash.Instead of fixing the root cause a simple check for whether said VLC
has already been initialized was added ; said check is inherently racy.The proper fix is of course to ensure that the VLC is initialized and
commit 7c76eaeca2791261d3f4f5c98c95f44abdbd879a already ensured this,
so there was no need to merge 6ac0e7818399a57e4684202bac79f35b3561ad1e
at all. This commit therefore reverts said commit.[1] : https://bugzilla.libav.org/show_bug.cgi?id=1012
Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-
avcodec/frame_thread_encoder : Avoid allocations of AVFrames
7 février 2021, par Andreas Rheinhardtavcodec/frame_thread_encoder : Avoid allocations of AVFrames
Up until now, when using frame threaded encoding, an AVFrame would be
allocated for every frame to be encoded. These AVFrames would reach the
worker threads via a FIFO of tasks, a structure which contained the
AVFrame as well as an index into an array which gives the place where
the worker thread shall put the returned packet ; in addition to that,
said structure also contained several unused fields.This commit changes this : The AVFrames are now allocated during init in
the array that is up until now only used to return the packets. The
contents to be encoded are put into the AVFrame in the same array
element that is also used to return the packets.Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>