
Recherche avancée
Médias (2)
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
Autres articles (38)
-
Librairies et binaires spécifiques au traitement vidéo et sonore
31 janvier 2010, parLes logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
Binaires complémentaires et facultatifs flvtool2 : (...) -
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 (...) -
De l’upload à la vidéo finale [version standalone]
31 janvier 2010, parLe chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
Upload et récupération d’informations de la vidéo source
Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)
Sur d’autres sites (7308)
-
attempting to save FuncAnimation changes the animation
25 mars 2024, par pibionI am attempting to create and save an animation of a time-varying vector field using matplotlib's FuncAnimation. When I run the animation without attempting to save it, it updates smoothly as expected. However, when I try to save the animation, the vectors increase in length and the animation only appears to update a few times. I've been able to record the screen to get a video file, but I'd like to understand how to save the animation to a video in python.


Here is the code to create the vector field animation. I ran this in a local jupyter notebook using python 3.9.12 on Windows.


%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

x_min, x_max = -20, 20
y_min, y_max = 0, 25
wire_x = -4
wire_y = 17

# Define the vector field function (example: rotating vector field)
def vector_field(x, y, t):
 x = x - wire_x
 y = y - wire_y
 r = np.sin(t) / (x**2 + y**2)
 u = -r * y
 v = r * x
 return (u, v)

# Define grid
x = np.linspace(x_min, x_max, 20)
y = np.linspace(y_min, y_max, 20)
X, Y = np.meshgrid(x, y)

# Create animation
fig, ax = plt.subplots(1,1)
ax.set_aspect('equal')
ax.set_xlim(x_min, x_max)
ax.set_ylim(y_min, y_max)
ax.set_xlabel('X (m)')
ax.set_ylabel('Y (m)')

u, v = vector_field(X, Y, 1)

quiver = ax.quiver(X, Y, u, v)

time_arr = np.linspace(0,20,200)

plt.show()

def update_quiver(num):
 t = num * 0.1 # Time step
 u, v = vector_field(X, Y, t)
 quiver.set_UVC(u, v)

ani = animation.FuncAnimation(fig, update_quiver, frames=200, interval=50, repeat=False)



This produces an animation whose vectors smoothly vary in length on my computer.


However, when I try to save the animation by adding the lines


writervideo = animation.FFMpegWriter(fps=60) 
ani.save('field_leftWire.mp4', writer=writervideo) 



then the animation changes - the vectors are much longer and it appears to only update a few times throughout the animation.


I'll also note that I had to install ffmpeg and restart my computer as outlined in Installation of FFMPEG for Python in WIndows to get the last two lines to run without error.


-
Segmentation fault caused by FFMPEG / SFML on Macos
12 avril 2024, par Med ali Damergi ReTr0I'm trying to code a basic video player function to use it in a game it's supposed to get a sfml window and a video link as inputs and run the video :


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

#include <sfml></sfml>Graphics.hpp>
#include <iostream>

const AVCodec* pCodec = nullptr;


void lecteurVideo(const std::string& videoPath, sf::RenderWindow& window) {
 // Open the video file
 AVFormatContext* pFormatCtx = avformat_alloc_context();
 if (avformat_open_input(&pFormatCtx, videoPath.c_str(), nullptr, nullptr) != 0) {
 std::cerr << "Failed to open video file" << std::endl;
 return;
 }

 // Retrieve stream information
 if (avformat_find_stream_info(pFormatCtx, nullptr) < 0) {
 std::cerr << "Failed to retrieve stream information" << std::endl;
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Find the first video stream
 int videoStreamIndex = -1;
 for (unsigned int i = 0; i < pFormatCtx->nb_streams; i++) {
 if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 videoStreamIndex = i;
 break;
 }
 }
 if (videoStreamIndex == -1) {
 std::cerr << "Failed to find video stream" << std::endl;
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Get the codec parameters for the video stream
 AVCodecParameters* pCodecParams = pFormatCtx->streams[videoStreamIndex]->codecpar;

 // Find the decoder for the video stream
 const AVCodec* pCodec = avcodec_find_decoder(pCodecParams->codec_id);
 if (pCodec == nullptr) {
 std::cerr << "Failed to find video decoder" << std::endl;
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Allocate a codec context for the decoder
 AVCodecContext* pCodecCtx = avcodec_alloc_context3(pCodec);
 if (pCodecCtx == nullptr) {
 std::cerr << "Failed to allocate codec context" << std::endl;
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Initialize the codec context with the codec parameters
 if (avcodec_parameters_to_context(pCodecCtx, pCodecParams) < 0) {
 std::cerr << "Failed to initialize codec context" << std::endl;
 avcodec_free_context(&pCodecCtx);
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Open the codec
 if (avcodec_open2(pCodecCtx, pCodec, nullptr) < 0) {
 std::cerr << "Failed to open codec" << std::endl;
 avcodec_free_context(&pCodecCtx);
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Create a frame to hold the decoded video data
 AVFrame* pFrame = av_frame_alloc();
 if (pFrame == nullptr) {
 std::cerr << "Failed to allocate frame" << std::endl;
 avcodec_close(pCodecCtx);
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Create a packet for reading compressed video data
 AVPacket* pPacket = av_packet_alloc();
 if (pPacket == nullptr) {
 std::cerr << "Failed to allocate packet" << std::endl;
 av_frame_free(&pFrame);
 avcodec_close(pCodecCtx);
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Create a software scaler context for converting the video frame format
 SwsContext* pSwsCtx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt,
 pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_RGB24,
 SWS_BILINEAR, nullptr, nullptr, nullptr);
 if (pSwsCtx == nullptr) {
 std::cerr << "Failed to create software scaler context" << std::endl;
 av_packet_free(&pPacket);
 av_frame_free(&pFrame);
 avcodec_close(pCodecCtx);
 avformat_close_input(&pFormatCtx);
 return;
 }

 // Create an SFML texture and sprite for displaying the video frames
 sf::Texture texture;
 sf::Sprite sprite;

 // Read frames from the video file and display them in the SFML window
 while (av_read_frame(pFormatCtx, pPacket) >= 0) {
 if (pPacket->stream_index == videoStreamIndex) {
 // Decode the video packet into a frame
 if (avcodec_send_packet(pCodecCtx, pPacket) < 0) {
 std::cerr << "Failed to send packet to decoder" << std::endl;
 break;
 }
 if (avcodec_receive_frame(pCodecCtx, pFrame) < 0) {
 std::cerr << "Failed to receive frame from decoder" << std::endl;
 break;
 }

 // Convert the frame format to RGB24
 uint8_t* rgbBuffer = new uint8_t[pCodecCtx->width * pCodecCtx->height * 3];
 uint8_t* rgbPlanes[1] = { rgbBuffer };
 int rgbStrides[1] = { pCodecCtx->width * 3 };
 sws_scale(pSwsCtx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height,
 rgbPlanes, rgbStrides);

 // Update the SFML texture with the RGB24 data
 texture.create(pCodecCtx->width, pCodecCtx->height);
 texture.update(rgbBuffer);

 // Display the texture in the SFML window
 sprite.setTexture(texture);
 window.clear();
 window.draw(sprite);
 window.display();

 delete[] rgbBuffer;
 }

 av_packet_unref(pPacket);
 }

 // Clean up resources
 av_packet_free(&pPacket);
 av_frame_free(&pFrame);
 avcodec_close(pCodecCtx);
 avformat_close_input(&pFormatCtx);
 sws_freeContext(pSwsCtx);
}

int main() {
 sf::RenderWindow window(sf::VideoMode(800, 600), "Lecteur Video SFML");
 lecteurVideo("/Users/mac/cours/spaceRevolution/Videos/58e62585-c143-483a-9149-b401ebc01d02.mp4", window);
 return 0;
}
</iostream>


It works on my other computer running on ubuntu but not on my main laptop on macOS : It dosent open any window and instantly cause a segmentation fault.


I've tried tu run valgrind on it but valgrind dosent run well on macOS.


Could anybody help me with this ?


-
OpenEncodeSessionEx failed : no encode device (1) : (no details)
11 mai 2024, par Jayce LiI'm testing the ddagrab filter with this command line :


ffmpeg -f lavfi -i ddagrab -c:v h264_nvenc -cq 18 -v 40 -t 10 -y out.mp4


FFmpeg exits with this error message :
OpenEncodeSessionEx failed : no encode device (1) : (no details)


My laptop has Nvidia Geforce GTX 1050 Ti, Driver version 527.37. Windows 10 Home, Version 22H2, OS build 19045.4291. DirectX version 12.


This command works without problems :
ffmpeg -f gdigrab -i desktop -c:v h264_nvenc -t 10 -y out.mp4


I test these command on my other laptop with Nvidia Geforce RTX 2060, Driver version 512.78.Windows 10 Home, Version 22H2, OS build 19045.3693. DirectX version 12. They both work fine.


How to solve the problem. OpenEncodeSessionEx failed : no encode device (1) : (no details)