
Recherche avancée
Médias (1)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
Autres articles (77)
-
Pas question de marché, de cloud etc...
10 avril 2011Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
sur le web 2.0 et dans les entreprises qui en vivent.
Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...) -
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (9300)
-
udpsrc doesn't work on 2 NIC & Port mirror linux setup (gstreamer/vlc/ffmpeg)
28 janvier 2021, par kepittoI've tried a lot of stuff, but I can't seem to get it to work. (Same problem exists with ffmpeg/vlc)


Basically, I can't get the UDP Stream directly into a videotool. I can verify the data coming in through tcpdump/wireshark etc. and i can also create the videofiles through gstreamer/ffmpeg afterwards, but I can't use the udp source as input.


The current setup is the following :
The camera streams MJPEG through UDP to a fixed address & port. I port mirrored the data from the camera, so that I can verify the data coming in through wireshark on a 3rd device.


The reason behind doing this is that multicast is not supported, so I need a way to get the data on 2 devices through unicast. Port mirroring seemed like a viable solution.


Am I missing something here ? What do I need to do to get this working ?
I thought maybe it's due to the two networkinterface setup as I use 1x usb to ethernet for the port mirror and 1x ethernet for the web, but disconnecting the other shows no difference.
The routing seems correct too : "ip route get camera.ip" returns that the routing is through the usb to ethernet on my static ip.


Example of an attempt :


Gst-launch-1.0 udpsrc port=streamingport(confirmed through wireshark) ! jpegdec ! videorate ! video/x-raw,framerate=30/1 ! autovideosink (does not work)


Gst-launch-1.0 filesrc location=hexdumpfile.txt ! jpegdec ! videorate ! video/x-raw,framerate=30/1 ! autovideosink (does work)


-
How would I send x264 encoded frames correctly over a network using UDP ?
5 avril 2020, par Eoin McBennettI'm trying to send the encoded h264 frames I have over a network as I get them, currently I'm only streaming the nal units I get from each frame as it is encoded, is this the correct approach ?



I wrote a receiver application on a different computer to get the nals and wrote them all to a file sequentially, when played with vlc I didn't get any video and instead just got a screeching noise. I'm not sure exactly where the problem would lie here. I have included the result of the FFmpeg -I command on the file created.



Encoder and sender code




 //Udp initialisation
 struct sockaddr_in broadcastAddr;
 int sock;
 int yes = 1;
 int addr_len;
 int count;
 fd_set readfd;
 char buffer[1024];
 int i;

 sock = socket(AF_INET, SOCK_DGRAM,0);

 if(sock < 0){
 std::cout << "Failed to initialise socket!" << std::endl;
 }

 int ret = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&yes, sizeof(yes));
 if(ret < 0){
 std::cout << "setsockopt error!" </ the size of the address

 memset((void*)&broadcastAddr,0,addr_len); //0 out the address bits

 broadcastAddr.sin_family = AF_INET;
 broadcastAddr.sin_addr.s_addr = INADDR_BROADCAST;
 broadcastAddr.sin_port = PORT;



 //Set the encoder parameters
 x264_param_t param;
 x264_param_default_preset(&param,"veryfast","zerolatency");
 param.i_threads = 1;
 param.i_width = camera.getWidth();
 param.i_height = camera.getHeight();
 param.i_fps_num = 30;
 param.i_fps_den = 1;
// Intra refres:
 param.i_keyint_max = 30;
 param.b_intra_refresh = 1;
//Rate control:
 param.rc.i_rc_method = X264_RC_CRF;
 param.rc.f_rf_constant = 25;
 param.rc.f_rf_constant_max = 35;
//For streaming:
 param.b_repeat_headers = 1;
 param.b_annexb = 1;
 x264_param_apply_profile(&param, "baseline");

 x264_t *encoder = x264_encoder_open(&param); //H.264 encoder object
 x264_picture_t pic_in, pic_out;
 x264_picture_alloc(&pic_in, X264_CSP_I420,camera.getWidth(), camera.getHeight());

 //Network abstraction layer units for broadcast
 x264_nal_t *nals;
 int i_nals;

 while(true){

 //If there is valid data in the processing queue
 if(!encoderQueue.empty()){

 //File the x264 input data structure with the file data
 fillImage(encoderQueue.front(),camera.getWidth(),camera.getHeight(),&pic_in);

 //Encode and send
 int frame_size = x264_encoder_encode(encoder, &nals, &i_nals, &pic_in, &pic_out);
 if (frame_size >= 0) {
 //The frame is ready to be sent over UDP!
 for(int i = 0; i < i_nals; i++){
 ret = sendto(sock, &nals[0].p_payload, frame_size,0,(struct sockaddr*)&broadcastAddr,addr_len);
 if(ret > 0){
 std::cout << "Streamed frame nal unit " << i << std::endl;
 } else{
 std::cout << "Failed to stream nal unit " << i << std::endl;
 }
 }
 }
 else{
 std::cout<<"Failed to encode h264 frame!" << std::endl;
 }
 //Finsihed with the current frame, pop it off the queue and remove any nals to do with it
 encoderQueue.pop();
 frame_size = 0;
 nals = nullptr;
 i_nals = 0;
 }


 }




Receiver application



#include <iostream>
#include 
#include <network></network>Network.h>
#include <netinet></netinet>in.h>
#include <arpa></arpa>inet.h>
#include <sys></sys>types.h>
#include <sys></sys>socket.h>
#include <queue>


#define BUFFER_LEN 10000
#define PORT_NO 3879



int main(int argc, const char * argv[]) {


 FILE *file; //File to write the h264 nals too

 //Declare the address memory space
 struct sockaddr_in sockAddr , bcAddr;
 socklen_t bcAddr_len = sizeof(&bcAddr); //Store the length of the broadcast address structure
 //0 out the assigned memory
 memset(&sockAddr, 0, sizeof(sockAddr));
 memset(&bcAddr, 0 ,sizeof(bcAddr));

 //Set the address parameters to look for incoming IpV4/UDP data
 sockAddr.sin_family = AF_INET;
 sockAddr.sin_port = htons(PORT_NO);
 sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);

 bcAddr.sin_family = AF_INET;
 bcAddr.sin_port = PORT_NO;
 inet_aton("255.255.255.255",&bcAddr.sin_addr);

 //Initialise a udp socket to read broadcast bytes
 int soc = socket(AF_INET, SOCK_DGRAM,0);

 //Check socket init
 if(soc < 0){
 std::cout << "Failed to initialise UDP socket!" << std::endl;
 return -1;
 }

 //Bind the address details to the socket, check for errors
 if(bind(soc, (struct sockaddr*)&sockAddr, sizeof(sockAddr)) < 0){
 std::cout << "Failed to bind address structure to socket!" << std::endl;
 return -2;
 }

 file = fopen("stream.h264","wb"); // Open the file for writing

 unsigned char buffer[BUFFER_LEN];

 while(true){


 memset(&buffer, 0, sizeof(unsigned char) * BUFFER_LEN);

 int recv_len = recvfrom(soc, buffer, BUFFER_LEN, 0, (struct sockaddr *)&bcAddr, &bcAddr_len);

 std::cout<< "Received " << recv_len << "bytes on broadcast address" << std::endl;

 fwrite(&buffer, sizeof(unsigned char), recv_len, file);
 }

 return 0;
}
</queue></iostream>



FFMPEG -I output






Any help would be greatly appreciated.


-
How would I send x264 encoded frames correctly over a network using UDP ?
5 avril 2020, par Eoin McBennettI'm trying to send the encoded h264 frames I have over a network as I get them, currently I'm only streaming the nal units I get from each frame as it is encoded, is this the correct approach ?



I wrote a receiver application on a different computer to get the nals and wrote them all to a file sequentially, when played with vlc I didn't get any video and instead just got a screeching noise. I'm not sure exactly where the problem would lie here. I have included the result of the FFmpeg -I command on the file created.



Encoder and sender code




 //Udp initialisation
 struct sockaddr_in broadcastAddr;
 int sock;
 int yes = 1;
 int addr_len;
 int count;
 fd_set readfd;
 char buffer[1024];
 int i;

 sock = socket(AF_INET, SOCK_DGRAM,0);

 if(sock < 0){
 std::cout << "Failed to initialise socket!" << std::endl;
 }

 int ret = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&yes, sizeof(yes));
 if(ret < 0){
 std::cout << "setsockopt error!" </ the size of the address

 memset((void*)&broadcastAddr,0,addr_len); //0 out the address bits

 broadcastAddr.sin_family = AF_INET;
 broadcastAddr.sin_addr.s_addr = INADDR_BROADCAST;
 broadcastAddr.sin_port = PORT;



 //Set the encoder parameters
 x264_param_t param;
 x264_param_default_preset(&param,"veryfast","zerolatency");
 param.i_threads = 1;
 param.i_width = camera.getWidth();
 param.i_height = camera.getHeight();
 param.i_fps_num = 30;
 param.i_fps_den = 1;
// Intra refres:
 param.i_keyint_max = 30;
 param.b_intra_refresh = 1;
//Rate control:
 param.rc.i_rc_method = X264_RC_CRF;
 param.rc.f_rf_constant = 25;
 param.rc.f_rf_constant_max = 35;
//For streaming:
 param.b_repeat_headers = 1;
 param.b_annexb = 1;
 x264_param_apply_profile(&param, "baseline");

 x264_t *encoder = x264_encoder_open(&param); //H.264 encoder object
 x264_picture_t pic_in, pic_out;
 x264_picture_alloc(&pic_in, X264_CSP_I420,camera.getWidth(), camera.getHeight());

 //Network abstraction layer units for broadcast
 x264_nal_t *nals;
 int i_nals;

 while(true){

 //If there is valid data in the processing queue
 if(!encoderQueue.empty()){

 //File the x264 input data structure with the file data
 fillImage(encoderQueue.front(),camera.getWidth(),camera.getHeight(),&pic_in);

 //Encode and send
 int frame_size = x264_encoder_encode(encoder, &nals, &i_nals, &pic_in, &pic_out);
 if (frame_size >= 0) {
 //The frame is ready to be sent over UDP!
 for(int i = 0; i < i_nals; i++){
 ret = sendto(sock, &nals[0].p_payload, frame_size,0,(struct sockaddr*)&broadcastAddr,addr_len);
 if(ret > 0){
 std::cout << "Streamed frame nal unit " << i << std::endl;
 } else{
 std::cout << "Failed to stream nal unit " << i << std::endl;
 }
 }
 }
 else{
 std::cout<<"Failed to encode h264 frame!" << std::endl;
 }
 //Finsihed with the current frame, pop it off the queue and remove any nals to do with it
 encoderQueue.pop();
 frame_size = 0;
 nals = nullptr;
 i_nals = 0;
 }


 }




Receiver application



#include <iostream>
#include 
#include <network></network>Network.h>
#include <netinet></netinet>in.h>
#include <arpa></arpa>inet.h>
#include <sys></sys>types.h>
#include <sys></sys>socket.h>
#include <queue>


#define BUFFER_LEN 10000
#define PORT_NO 3879



int main(int argc, const char * argv[]) {


 FILE *file; //File to write the h264 nals too

 //Declare the address memory space
 struct sockaddr_in sockAddr , bcAddr;
 socklen_t bcAddr_len = sizeof(&bcAddr); //Store the length of the broadcast address structure
 //0 out the assigned memory
 memset(&sockAddr, 0, sizeof(sockAddr));
 memset(&bcAddr, 0 ,sizeof(bcAddr));

 //Set the address parameters to look for incoming IpV4/UDP data
 sockAddr.sin_family = AF_INET;
 sockAddr.sin_port = htons(PORT_NO);
 sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);

 bcAddr.sin_family = AF_INET;
 bcAddr.sin_port = PORT_NO;
 inet_aton("255.255.255.255",&bcAddr.sin_addr);

 //Initialise a udp socket to read broadcast bytes
 int soc = socket(AF_INET, SOCK_DGRAM,0);

 //Check socket init
 if(soc < 0){
 std::cout << "Failed to initialise UDP socket!" << std::endl;
 return -1;
 }

 //Bind the address details to the socket, check for errors
 if(bind(soc, (struct sockaddr*)&sockAddr, sizeof(sockAddr)) < 0){
 std::cout << "Failed to bind address structure to socket!" << std::endl;
 return -2;
 }

 file = fopen("stream.h264","wb"); // Open the file for writing

 unsigned char buffer[BUFFER_LEN];

 while(true){


 memset(&buffer, 0, sizeof(unsigned char) * BUFFER_LEN);

 int recv_len = recvfrom(soc, buffer, BUFFER_LEN, 0, (struct sockaddr *)&bcAddr, &bcAddr_len);

 std::cout<< "Received " << recv_len << "bytes on broadcast address" << std::endl;

 fwrite(&buffer, sizeof(unsigned char), recv_len, file);
 }

 return 0;
}
</queue></iostream>



FFMPEG -I output






Any help would be greatly appreciated.