
Recherche avancée
Autres articles (60)
-
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...) -
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
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
Sur d’autres sites (9546)
-
How can I create a side-by-side live video stream output from two separate live webcam feed using ffmpeg ? [duplicate]
10 août 2021, par shudfht85I would like to combine two live webcam feeds of same resolution (say 1280 X 1024) into one side-by-side live video feed output (2560X1024) using ffmpeg.
I found some code from here : https://ffmpeg.org/ffmpeg-filters.html#overlay


ffmpeg -i left.avi -i right.avi -filter_complex "
nullsrc=size=200x100 [background];
[0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
[1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
[background][left] overlay=shortest=1 [background+left];
[background+left][right] overlay=shortest=1:x=100 [left+right]
"



However, I do not know how I can change the input video from MP4 to a live webcam feed. Any help would be appreciated. Thanks.


-
OpenCV reading from live camera creates a short video that moves quickly
17 novembre 2022, par user19019404I am reading in a live vide stream from a CCTV camera. The camera is set to 5 fps, another is set to 25fps and another to 30fps. Irrespective of the FPS that the camera is set, I can record 5 minutes but end up with a 30 second recorded clip where everyone is running around the scene.


My code is the 'typical' read in video and write video code that you would find online such as (code below simplified for readability) :


import cv2

video = cv2.VideoCapture(live RTSP address of camera)

if (video.isOpened() == False):
 print("Error reading video file")
else:
 frame_width = video.get(cv2.CAP_PROP_FRAME_WIDTH)
 frame_height = video.get(cv2.CAP_PROP_FRAME_HEIGHT)
 frame_fps = video.get(cv2.CAP_PROP_FPS)
 size = (frame_width, frame_height)
 result = cv2.VideoWriter('filename.avi',cv2.VideoWriter_fourcc(*'MJPG'),frame_fps , size)

 while(True):
 ret, frame = video.read()
 if ret == True:
 result.write(frame)
 cv2.imshow('Frame', frame)
 if cv2.waitKey(1) & 0xFF == ord('s'):
 break
 else:
 break
 video.release()
 result.release()
 cv2.destroyAllWindows()
print("The video was successfully saved with new fps")



I have tried playing with the FPS by reading in the FPS from the live camera and using the same FPS in the video write, but all that results is a video that is a fraction of the real time and with people zooming around the scene. So watching a 5 minute smooth video results in a 20 second recorded video with everyone zooming around.


Is this something that I need to fix in the writing of the video or do I need a second pass with ffmpeg to readjust the video ?


Much appreciated


Update, corrected the code above and :
When printing the frames read and the frame written the numbers are the same, showing that each frame that is read is being written (so I am not losing frames along the way thereby writing half the amount of frames).


-
My C++ software uses ffmpeg in streaming mode, but I want to decode the data as quickly as possible, how do I do that ?
14 septembre 2022, par Alexis WilkeWhen I run ffmpeg in my command line to convert an m4a file to mp3, it says ×45 to ×55 for the speed at which is decodes the input data. In this case, the 45 minute audio file gets converter in 2 minutes.


When I run the same process through my C++ code, I stream the data. This is because my code accepts data coming from the network so often it will a little faster to do streaming (unfortunately, not with m4a data since the header is placed at the end of the file...)


However, there seems to be something in ffmpeg that makes it think that if I want to stream the data it needs to be done in realtime. In other words, the frames come through at a speed of ×1 instead of the possible average of ×50.


Is there a flag/setup that I need to turn ON or OFF so the streaming process goes ×50 or so ?



I allocate the context like so :


size_t const avio_buffer_size(4096);
unsigned char * avio_buffer(reinterpret_cast<unsigned char="char">(av_malloc(avio_buffer_size)));
AVIOContext * context(avio_alloc_context(
 avio_buffer
 , avio_buffer_size
 , 0 // write flag
 , this // opaque
 , decoder_read_static
 , nullptr // write func.
 , decoder_seek_static));
</unsigned>


To do the streaming, I use custom I/O in the context :


AVFormatContext * format_context(avformat_alloc_context());
format_context->pb = context;
format_context->flags |= AVFMT_FLAG_CUSTOM_IO;
avformat_open_input(
 &format_context
 , "input" // filename (unused)
 , nullptr // input format
 , nullptr); // options



Next I get the audio stream index :


avformat_find_stream_info(format_context, nullptr);
AVCodec * decoder_codec(nullptr);
int const index(av_find_best_stream(
 format_context
 , AVMEDIA_TYPE_AUDIO
 , -1 // wanted stream number
 , -1 // related stream
 , &decoder_codec
 , 0)); // flags



That has the side effect of telling us which decoder to use :


AVCodecContext * decoder_context = avcodec_alloc_context3(decoder_codec);
avcodec_parameters_to_context(
 decoder_context
 , format_context->streams[index]->codecpar);
avcodec_open2(
 decoder_context
 , decoder_codec
 , nullptr); // options



And finally, I loop through the frames :


AVFrame *frame(av_frame_alloc());
AVPacket av_packet;
av_init_packet(&av_packet);
for(;;)
{
 av_read_frame(format_context, &av_packet);
 if(end-detected)
 {
 break;
 }
 if(av_packet.stream_index != index) continue;
 avcodec_send_packet(decoder_context, &av_packet);
 for(;;)
 {
 avcodec_receive_frame(decoder_context, frame);
 if(end-detected)
 {
 break;
 }
 ...copy data from frame...
 av_frame_unref(frame);
 }
 av_packet_unref(&av_packet);
}



Note : I don't show all the error handling, use of RAII, etc. in an attempt to show the code in its simplest form.