
Recherche avancée
Médias (2)
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (99)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (13281)
-
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 ?


-
How do i gain access to subproccess.py ?
15 décembre 2023, par Kronik71So, my bot for some reason wants to access a folder in
\WindowsApps\PythonSoftwareFoundation.Python.bunch_of_numbers\Lib
calledsubproccess.py
but it always gives the error :PermissionError: [WinError 5] Access is denied
. I think it has to do with ffmpeg.

Here's the full traceback (kinda long) :


Traceback (most recent call last):
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\client\client.py", line 1900, in __dispatch_interaction
 response = await callback
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\client\client.py", line 1771, in _run_slash_command
 return await command(ctx, **ctx.kwargs)
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\models\internal\command.py", line 132, in __call__
 await self.call_callback(self.callback, context)
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\models\internal\application_commands.py", line 802, in call_callback
 return await self.call_with_binding(callback, ctx)
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\models\internal\callback.py", line 43, in call_with_binding
 return await callback(*args, **kwargs)
 File "C:\Users\myuser\OneDrive\Desktop\button.py", line 38, in press
 voice_client.play(discord.FFmpegPCMAudio(executable=r"C:\Users\myuser\OneDrive\Desktop\ffmpeg-6.1-essentials_build\bin", source=audiosource))
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.Bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\discord\player.py", line 290, in __init__
 super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\discord\player.py", line 166, in __init__
 self._process = self._spawn_process(args, **kwargs)
 File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\discord\player.py", line 180, in _spawn_process
 process = subprocess.Popen(args, creationflags=CREATE_NO_WINDOW, **subprocess_kwargs)
 File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.bunch_of_numbers\lib\subprocess.py", line 971, in __init__
 self._execute_child(args, executable, preexec_fn, close_fds,
 File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.bunch_of_numbers\lib\subprocess.py", line 1456, in _execute_child
 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied



heres my code :


import interactions
import discord
from discord import FFmpegPCMAudio
import tracemalloc

ffmpegexec = r"C:\Users\myuser\OneDrive\Desktop\ffmpeg-6.1-essentials_build\bin\ffmpeg.exe"

audiosource = r"C:\Users\myuser\Downloads\seatbelt-online-audio-converter.mp3"

source = discord.FFmpegPCMAudio(audiosource)

token = "my_token"

bot = interactions.Client(token=token)

tracemalloc.start()

@interactions.slash_command(
 name="joinvc",
 description="starts the game"
)

async def joinvc(ctx: interactions.ComponentContext):
 await ctx.send("Joining vc. Please make sure you are currently in a vc!")
 vc = ctx.author.voice.channel
 await vc.connect()

@interactions.slash_command(
 name="press",
 description="Press the button"
)

async def press(ctx: interactions.ComponentContext):
 await ctx.send(f"{ctx.author.mention} has pressed the button")
 vc = ctx.author.voice.channel
 voice_client = await vc.connect() # Connect to the voice channel

voice_client.play(discord.FFmpegPCMAudio(executable=r"C:\Users\myuser\OneDrive\Desktop\ffmpeg-6.1-essentials_build\bin", source=audiosource))


bot.start(token)



All of my code is above. I'm not exactly good at writing python, might just be something I'm misunderstanding. I just want it to play a noise in a discord voice chat when the /press command is used.


-
avcodec/sanm : codec37 : reimplement comp4
11 mars, par Manuel Laussavcodec/sanm : codec37 : reimplement comp4
Compression 4 code 0 means copy from delta buffer without mv,
AND start of a skip run. This gets rid of the extra case and column
index manipulation and implements this as it is implemented in the
original game exe, i.e. as a special case for after mv copy.Signed-off-by : Manuel Lauss <manuel.lauss@gmail.com>