
Recherche avancée
Médias (1)
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
Autres articles (12)
-
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...) -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
Sur d’autres sites (3094)
-
How to extract motion vectors from h264 without a full decode on the CPU
25 septembre 2020, par Adrian MayI'm trying to use my nose as a pointing device. The plan is to encode the video stream from a webcam pointed at my face as h264 or the like, get the motion vectors, cook the numbers a bit and chuck them into /dev/uinput to make the mouse pointer move about. The uinput bit was easy.


This has to work with zero discernable latency. This, for instance :


#!/bin/bash
[ -p pipe.mkv ] || mkfifo pipe.mkv
ffmpeg -y -rtbufsize 1M -s 640x360 -vcodec mjpeg -i /dev/video0 -c h264_nvenc pipe.mkv &
ffplay -flags2 +export_mvs -vf codecview=mv=pf+bf+bb pipe.mkv



shows that the vectors are there but with a latency of several seconds which is unusable in a mouse. I know that the first ffmpeg step is working very fast by using the GPU, so either the pipe or the h264 decode in the second step is introducing the latency.


I tried MV Tractus (same as mpegflow I think) in a similar pipe arrangement and it was also very slow. They do a full h264 decode on the CPU and I think that's the problem cos I can see them imposing a lot of load on one CPU. If the pipe had caused the delay by buffering badly then the CPU wouldn't have been loaded. I guess ffplay also did the decoding on the CPU and I couldn't persuade it not to, but it only wants to draw arrows which are no use to me.


I think there are several approaches, and I'd like advice on which would be best, or if there's something even better I don't know about. I could :


- 

- Decode in hardware and get the motion vectors. So far this has failed. I tried combining ffmpeg's
extract_mvs.c
andhw_decode.c
samples but no motion vectors turn up. vdpau is the only decoder I got working on my linux box. I have a nvidia gpu. - Do a minimal parse of the h264 to fish out the motion vectors only, ignoring all the other data. I think this would mean putting some kind of "motion only" option in libav's parser, but I'm not at all familiar with that code.
- Find some other h264 parsing library that has said option and also unpacks the container.
- Forget about hardware accelerated encoding and use a stripped down encoder to make only the motion vectors on either CPU or GPU. I suspect this would be slow cos I think calculating the motion vectors is the hardest part of the algorithm.










I'm tending towards the second option but I need some help figuring out where in the libav code to do it.


- Decode in hardware and get the motion vectors. So far this has failed. I tried combining ffmpeg's
-
Extracting frames from a video does not work correctly [closed]
13 avril 2024, par Al TilmidhUsing the libraries (libav) and (ffmpeg), I try to extract frames as
.jpg
files from avideo.mp4
, the problem is that my program crashes when I use theCV_8UC3
parameter, but by changing this parameter toCV_8UC1
, the extracted images end up without color (grayscale), I don't really know what I missed, here is a minimal code to reproduce the two situations :

#include <opencv2></opencv2>opencv.hpp>

extern "C"
{
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
}

int main()
{
 AVFormatContext *formatContext = nullptr;

 if (avformat_open_input(&formatContext, "video.mp4", nullptr, nullptr) != 0)
 {
 return -1;
 }

 if (avformat_find_stream_info(formatContext, nullptr) < 0)
 {
 return -1;
 }

 AVPacket packet;
 const AVCodec *codec = nullptr;
 AVCodecContext *codecContext = nullptr;

 int videoStreamIndex = av_find_best_stream(formatContext, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0);
 if (videoStreamIndex < 0)
 {
 return -1;
 }

 codecContext = avcodec_alloc_context3(codec);
 avcodec_parameters_to_context(codecContext, formatContext->streams[videoStreamIndex]->codecpar);

 if (avcodec_open2(codecContext, codec, nullptr) < 0)
 {
 return -1;
 }

 AVFrame *frame = av_frame_alloc();

 while (av_read_frame(formatContext, &packet) >= 0)
 {
 if (packet.stream_index == videoStreamIndex)
 {
 int response = avcodec_send_packet(codecContext, &packet);
 
 if (response < 0)
 {
 break;
 }

 while (response >= 0)
 {
 response = avcodec_receive_frame(codecContext, frame);
 if (response == AVERROR(EAGAIN))
 {
 // NO FRAMES
 break;
 }

 else if (response == AVERROR_EOF)
 {
 // END OF FILE
 break;
 }

 else if (response < 0)
 {
 break;
 }

 //cv::Mat frameMat(frame->height, frame->width, CV_8UC3, frame->data[0]); // CV_8UC3 → THE PROGRAM CRASHES
 cv::Mat frameMat(frame->height, frame->width, CV_8UC1, frame->data[0]); // CV_8UC1 → WORK BUT IMAGES ARE IN GRAYSCALE
 cv::imwrite("frame_" + std::to_string(frame->pts) + ".jpg", frameMat);
 }
 }

 av_packet_unref(&packet);
 }

 av_frame_free(&frame);
 avcodec_free_context(&codecContext);
 avformat_close_input(&formatContext);

 return 0;
}



-
Fast movie creation using MATLAB and ffmpeg
24 février 2018, par hyiltizI have some time series data that I would like to create into movies. The data could be 2D (about 500x10000) or 3D (500x500x10000). For 2D data, the movie frames are simply line plot using
plot
, and for 3D data, we can usesurf
,imagesc
,contour
etc. Then we create a video file using these frames in MATLAB, then compress the video file usingffmpeg
.To do it fast, one would try not to render all the images to display, nor save the data to disk then read it back again during the process. Usually, one would use
getframe
orVideoWriter
to create movie in MATLAB, but they seem to easily get tricky if one tries not to display the figures to screen. Some even suggest plotting in hidden figures, then saving them as images to disk as.png
files, then compress them usingffmpeg
(e.g. withx265
encoder into.mp4
). However, saving the output ofimagesc
in my iMac took 3.5s the first time, then 0.5s after. I also find it not fast enough to save so many files to disk only to askffmpeg
to read them again. One couldhardcopy
the data as this suggests, but I am not sure whether it works regardless of the plotting method (e.g.plot
,surf
etc.), and how one would transfer data over toffmpeg
with minimal disk access.This is similiar to this, but
immovie
is too slow. This post 3 is similar, but advocates writing images to disk then reading them (slow IO).