
Recherche avancée
Autres articles (41)
-
Qu’est ce qu’un masque de formulaire
13 juin 2013, parUn masque de formulaire consiste en la personnalisation du formulaire de mise en ligne des médias, rubriques, actualités, éditoriaux et liens vers des sites.
Chaque formulaire de publication d’objet peut donc être personnalisé.
Pour accéder à la personnalisation des champs de formulaires, il est nécessaire d’aller dans l’administration de votre MediaSPIP puis de sélectionner "Configuration des masques de formulaires".
Sélectionnez ensuite le formulaire à modifier en cliquant sur sont type d’objet. (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
Sur d’autres sites (10417)
-
Java - Stream OpenGL Display to Android
24 octobre 2016, par IntektorI tried to solve this problem for days now, but I couldn’t find a working solution. I am trying to stream my game screen (lwjgl) to my android smartphone(I have a frame buffer with the texture), and I already built a fully working packet system and all that stuff. But there are several problem I have no idea how to solve them, first of all, I don’t know in which format I should send the frame buffer, e.g I can’t send it as a Buffered Image, because it doesn’t exist on android. I tried using the jcodec library, but there is no documentation for it, and I didn’t find any examples that fit my case. I think I have to encode and decode it with h264 to make it a realtime live stream(that’s very important). I also heard about ffmpeg (and I found a java library for it : https://github.com/bramp/ffmpeg-cli-wrapper) but there is again no documentation for how to use it to stream it to my mobile. Also I have the problem, that when would get the frames to my smartphone, how can I make them load by the graphics card
Here is what I have done so far :
My packet :public class ImagePacketToClient implements Packet {
public byte[] jpgInfo;
public int width;
public int height;
BufferedImage image;
public ImagePacketToClient() {
}
public ImagePacketToClient(BufferedImage image, int width, int height) {
this.image = image;
this.width = width;
this.height = height;
}
@Override
public void write(DataOutputStream out) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos);
baos.flush();
byte[] bytes = baos.toByteArray();
baos.close();
out.writeInt(bytes.length);
for (byte aByte : bytes) {
out.writeInt(aByte);
}
}
@Override
public void read(DataInputStream in) throws IOException {
int length = in.readInt();
jpgInfo = new byte[length];
for (int i = 0; i < length; i++) {
jpgInfo[i] = in.readByte();
}
}The code that gets called after the rendering has finished : mc.framebuffer is the frame buffer I can use :
ScaledResolution resolution = new ScaledResolution(mc);
BufferedImage screenshot = ScreenShotHelper.createScreenshot(resolution.getScaledWidth(), resolution.getScaledHeight(), mc.getFramebuffer());
ImagePacketToClient packet = new ImagePacketToClient(screenshot, screenshot.getWidth(), screenshot.getHeight());
PacketHelper.sendPacket(packet, CardboardMod.communicator.connectedSocket);
screenshot.flush();
public static BufferedImage createScreenshot(int width, int height, Framebuffer framebufferIn)
{
if (OpenGlHelper.isFramebufferEnabled())
{
width = framebufferIn.framebufferTextureWidth;
height = framebufferIn.framebufferTextureHeight;
}
int i = width * height;
if (pixelBuffer == null || pixelBuffer.capacity() < i)
{
pixelBuffer = BufferUtils.createIntBuffer(i);
pixelValues = new int[i];
}
GlStateManager.glPixelStorei(3333, 1);
GlStateManager.glPixelStorei(3317, 1);
pixelBuffer.clear();
if (OpenGlHelper.isFramebufferEnabled())
{
GlStateManager.bindTexture(framebufferIn.framebufferTexture);
GlStateManager.glGetTexImage(3553, 0, 32993, 33639, pixelBuffer);
}
else
{
GlStateManager.glReadPixels(0, 0, width, height, 32993, 33639, pixelBuffer);
}
pixelBuffer.get(pixelValues);
TextureUtil.processPixelValues(pixelValues, width, height);
BufferedImage bufferedimage;
if (OpenGlHelper.isFramebufferEnabled())
{
bufferedimage = new BufferedImage(framebufferIn.framebufferWidth, framebufferIn.framebufferHeight, 1);
int j = framebufferIn.framebufferTextureHeight - framebufferIn.framebufferHeight;
for (int k = j; k < framebufferIn.framebufferTextureHeight; ++k)
{
for (int l = 0; l < framebufferIn.framebufferWidth; ++l)
{
bufferedimage.setRGB(l, k - j, pixelValues[k * framebufferIn.framebufferTextureWidth + l]);
}
}
}
else
{
bufferedimage = new BufferedImage(width, height, 1);
bufferedimage.setRGB(0, 0, width, height, pixelValues, 0, width);
}
return bufferedimage;
}Honestly I don’t want to use this Buffered Image Stuff, because it halfs my framerate, and that’s not good.
And I don’t have any code for my android application yet, because I couldn’t figure out how I could get this image recreated on Android, and how to load it after that.
I hope you understand my problem and I am happy about every tip you can give to me :) -
html display video file binary buffer
15 mai 2022, par MartinI am working on an example of ffmpeg-wasm which will accept 3 files as input [song1.mp3, song2.mp3, image.png] and combine them into a video file [cool-output-video.mkv] which I want to be displayed as a playable video for the user in the html webpage.


https://github.com/MartinBarker/ffmpeg-wasm-node


My code is hosted in the above repo, right now I have a placeholder video element, which I want to change to the finished video after the user uploads the 3 files and clicks the render button.




inside server.js, I have the route
app.post('/render'
, which will render the video using ffmpeg, and return the video using the lineres.end(Buffer.from(outputData, 'binary'));


outputData = ffmpeg.FS('readFile', outputFileName);
 ffmpeg.FS('unlink', outputFileName);

 res.writeHead(200, {
 'Content-Type': 'image/png',
 'Content-Disposition': `attachment;filename=${outputFileName}`,
 'Content-Length': outputData.length
 });
 //res.end(btoa(Buffer.from(outputData, 'binary')));
 //res.end(outputData)
 res.end(Buffer.from(outputData, 'binary'));



I can see in my node server console log that the ffmpeg command finished and successfully renders the mkv video file




and inside client.js is where my code recieves the binary buffer for my outputted video file, and tries to make it appear on the webpage by changing the src attribute for the html video element, but no matter what code I try, I cant get the video file to appear on the html page


<video width="320" height="240" controls="controls">
 <source src="" type="video/mp4">
 Your browser does not support the video tag.
 </source></video>
...

const mp4source = document.querySelector('#mp4source')

...

 console.log('call renderVideo()')
 const renderResult = await renderVideo(files);
 console.log('renderVideo() finished. renderResult=',renderResult)
 mp4source.src = renderResult



I can see in my html file in my chrome webpage devtools console, that data is being returned and gets printed out, I'm just not sure how to handle this string data for my video file to make it appear on the webpage :


renderVideo() finished. renderResult= data:image/png;base64,GkXfo6NChoEBQveBAULygQRC84EIQoKIbWF0cm9za2FCh4EEQoWBAhhTgGcBAAAAC0APWxFNm3TCv4T+wiwATbuLU6uEFUmpZlOsgaFNu4tTq4QWVK5rU6yB8U27jFOrhBJUw2dTrIIB1E27jlOrhBxTu2tTrIQLQA797AEAAAAAAABRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFUmpZsu/hLA0O5Qq17GDD0JATYCNTGF2ZjU4LjQ1LjEwMFdBjUxhdmY1OC40NS4xMDBzpJAgTn1WHXX52GUlw+lW90wkRImIQRzeoAAAAAAWVK5rQN2/hEsGuLSuAQAAAAAAAD3XgQFzxYjtk28iSHTlJJyBACK1nIN1bmSGj............. long text was truncated etc





EDIT changed my ffmpeg command to export an mp4 video, changed header to be video/mp4, and verified it is getting added to the html src element but the video still does not appear




-
How can I display the video on sdl converted to emscripten ?
3 février 2021, par pleasehelpI am trying to view video in a browser using ffmpeg's decoder.


So, I made the decoder into a js file using emscripten.


By the way, the decoder seems to work, but only the last scene is displayed.


How can a video come out from start to finish ?


Here is my code



#include 
#include 
#include 

#include <libavcodec></libavcodec>avcodec.h>

#include <sdl2></sdl2>SDL.h>

#define INBUF_SIZE 128

static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,
 const char *filename,
 SDL_Window * screen, SDL_Renderer * renderer, SDL_Texture * texture)
{
 char buf[1024];
 int ret;

 ret = avcodec_send_packet(dec_ctx, pkt);
 if (ret < 0) {
 fprintf(stderr, "Error sending a packet for decoding\n");
 exit(1);
 }

 while (ret >= 0) {
 ret = avcodec_receive_frame(dec_ctx, frame);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 return;
 else if (ret < 0) {
 fprintf(stderr, "Error during decoding\n");
 exit(1);
 }

 printf("saving frame %3d\n", dec_ctx->frame_number);
 fflush(stdout);

 SDL_Rect rect;
 rect.x = 0;
 rect.y = 0;
 rect.w = dec_ctx->width;
 rect.h = dec_ctx->height;

 SDL_UpdateYUVTexture(
 texture, // the texture to update
 &rect, // a pointer to the rectangle of pixels to update, or NULL to update the entire texture
 frame->data[0], // the raw pixel data for the Y plane
 frame->linesize[0], // the number of bytes between rows of pixel data for the Y plane
 frame->data[1], // the raw pixel data for the U plane
 frame->linesize[1], // the number of bytes between rows of pixel data for the U plane
 frame->data[2], // the raw pixel data for the V plane
 frame->linesize[2] // the number of bytes between rows of pixel data for the V plane
 );

 SDL_RenderClear(renderer);

 SDL_RenderCopy(
 renderer, // the rendering context
 texture, // the source texture
 NULL, // the source SDL_Rect structure or NULL for the entire texture
 NULL // the destination SDL_Rect structure or NULL for the entire rendering
 // target; the texture will be stretched to fill the given rectangle
 );

 SDL_RenderPresent(renderer);
 SDL_UpdateWindowSurface(screen);
 }
}

int main(int argc, char **argv)
{
 const char *filename, *outfilename;
 const AVCodec *codec;
 AVCodecParserContext *parser;
 AVCodecContext *c= NULL;
 FILE *f;
 AVFrame *frame;
 uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
 uint8_t *data;
 size_t data_size;
 int ret;
 AVPacket *pkt;

 if (argc <= 2) {
 fprintf(stderr, "Usage: %s <input file="file" /> <output file="file">\n"
 "And check your input file is encoded by mpeg1video please.\n", argv[0]);
 exit(0);
 }
 filename = argv[1];
 outfilename = argv[2];

 pkt = av_packet_alloc();
 if (!pkt)
 exit(1);

 /* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
 memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);

 ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER); // [1]
 if (ret != 0)
 {
 // error while initializing SDL
 printf("Could not initialize SDL - %s\n.", SDL_GetError());

 // exit with error
 // return -1;
 }

 /* find the MPEG-1 video decoder */
 codec = avcodec_find_decoder(AV_CODEC_ID_H265);
 if (!codec) {
 fprintf(stderr, "Codec not found\n");
 exit(1);
 }

 parser = av_parser_init(codec->id);
 if (!parser) {
 fprintf(stderr, "parser not found\n");
 exit(1);
 }

 c = avcodec_alloc_context3(codec);
 if (!c) {
 fprintf(stderr, "Could not allocate video codec context\n");
 exit(1);
 }

 /* open it */
 if (avcodec_open2(c, codec, NULL) < 0) {
 fprintf(stderr, "Could not open codec\n");
 exit(1);
 }

 f = fopen(filename, "rb");
 if (!f) {
 fprintf(stderr, "Could not open %s\n", filename);
 exit(1);
 }

 frame = av_frame_alloc();
 if (!frame) {
 fprintf(stderr, "Could not allocate video frame\n");
 exit(1);
 }

 // Create a window with the specified position, dimensions, and flags.
 SDL_Window * screen = SDL_CreateWindow( // [2]
 "SDL Video Player",
 SDL_WINDOWPOS_UNDEFINED,
 SDL_WINDOWPOS_UNDEFINED,
 640,
 360,
 SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI
 );

 if (!screen)
 {
 // could not set video mode
 printf("SDL: could not set video mode - exiting.\n");

 // exit with Error
 // return -1;
 }

 // //
 // SDL_GL_SetSwapInterval(1);

 // A structure that contains a rendering state.
 SDL_Renderer * renderer = NULL;

 // Use this function to create a 2D rendering context for a window.
 renderer = SDL_CreateRenderer(screen, -1, SDL_RENDERER_ACCELERATED); // [3]

 // A structure that contains an efficient, driver-specific representation
 // of pixel data.
 SDL_Texture * texture = NULL;

 // Use this function to create a texture for a rendering context.
 texture = SDL_CreateTexture( // [4]
 renderer,
 SDL_PIXELFORMAT_YV12,
 SDL_TEXTUREACCESS_STREAMING,
 640,
 360
 );

 while (!feof(f)) {
 /* read raw data from the input file */
 data_size = fread(inbuf, 1, INBUF_SIZE, f);
 if (!data_size)
 break;

 /* use the parser to split the data into frames */
 data = inbuf;
 while (data_size > 0) {
 ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size,
 data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
 if (ret < 0) {
 fprintf(stderr, "Error while parsing\n");
 exit(1);
 }
 data += ret;
 data_size -= ret;

 if (pkt->size)
 decode(c, frame, pkt, outfilename, screen, renderer, texture);
 }
 }

 /* flush the decoder */
 decode(c, frame, NULL, outfilename, screen, renderer, texture);

 fclose(f);

 av_parser_close(parser);
 avcodec_free_context(&c);
 av_frame_free(&frame);
 av_packet_free(&pkt);

 return 0;
}

</output>


Is it possible to continuously play sdl in a browser ?