
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (67)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)
Sur d’autres sites (3815)
-
how to resolve pixel jittering in javacv generated video
16 septembre 2024, par VikramI am trying to generate video using images, where image have some overlays text and png icons. I am using javacv library for this.
Final output video seems pixelated, i don't understand what is it since i do not have video processing domain knowledge, i am beginner to this.
I know that video bitrate and choice of video encoder are important factor which contributes to video quality and there are many more factors too.


I am providing you two output for comparison, one of them is generated using javacv and another one is from moviepy library


Please watch it in full screen since the problem i am talking about only gets highlighted in full screen, you will see the pixel dancing in javacv generated video, but python output seems stable


https://imgur.com/a/aowNnKg - javacv generated


https://imgur.com/a/eiLXrbk - Moviepy generated


I am using same encoder in both of the implementation


Encoder - libx264
bitrate - 
 800 Kbps for javacv 
 500 Kbps for moviepy

frame rate - 24fps for both of them

output video size -> 
 7MB (javacv)
 5MB (Moviepy)





generated output size from javacv is bigger then moviepy generated video.


here is my java configuration for FFmpegFrameRecorder


FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(this.outputPath, 
 this.screensizeX, this.screensizeY);
 if(this.videoCodecName!=null && "libx264".equals(this.videoCodecName)) {
 recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
 }
 recorder.setFormat("mp4"); 
 recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420);
 recorder.setVideoBitrate(800000);
 recorder.setImageWidth(this.screensizeX);
 recorder.setFrameRate(24);




and here is python configuration for writing video file


Full_final_clip.write_videofile(
 f"{video_folder_path}/{FILE_ID}_INTERMEDIATE.mp4",
 codec="libx264",
 audio_codec="aac",
 temp_audiofile=f"{FILE_ID}_INTER_temp-audio.m4a",
 remove_temp=True,
 fps=24,
 )




as you can see i am not specifying bitrate in python, but i checked that bitrate of final output is around 500 kbps, which is lower then what i specified in java, yet java generated video quality seems poor.


I have tried setting crf value also , but it seems it does not have any impact when used.


increasing bitrate improve quality somewhat but at the cost of file size, still generated output seems pixelated.


Can someone please highlight what might be the issue, and how python is generating better quality video, when both of the libraries use ffmpeg at the backend.


Edit 1 : also, I am adding code which is being used to make zoom animation for continuous frames, As somewhere i read that this might be the cause for pixel jitter, please see and let me know if there is any improvement we can do to remove pixel jittering


private Mat applyZoomEffect(Mat frame, int currentFrame, long effectFrames, int width, int height, String mode, String position, double speed) {
 long totalFrames = effectFrames;
 double i = currentFrame;
 if ("out".equals(mode)) {
 i = totalFrames - i;
 }
 double zoom = 1 + (i * ((0.1 * speed) / totalFrames));

 double originalCenterX = width/2.0;
 double originalCenterY = height/2.0;
 

 // Resize image
 //opencv_imgproc.resize(frame, resizedMat, new Size(newWidth, newHeight));

 // Determine crop region based on position
 double x = 0, y = 0;
 switch (position.toLowerCase()) {
 case "center":
 // Adjusting for center zoom
 x = originalCenterX - originalCenterX * zoom;
 y = originalCenterY - originalCenterY * zoom;
 
 x= (width-(width*zoom))/2.0;
 y= (height-(height*zoom))/2.0;
 break;
 }

 double[][] rowData = {{zoom, 0, x},{0,zoom,y}};

 double[] flatData = flattenArray(rowData);

 // Create a DoublePointer from the flattened array
 DoublePointer doublePointer = new DoublePointer(flatData);

 // Create a Mat object with two rows and three columns
 Mat mat = new Mat(2, 3, org.bytedeco.opencv.global.opencv_core.CV_64F); // CV_64F is for double type

 // Put the data into the Mat object
 mat.data().put(doublePointer);
 Mat transformedFrame = new Mat();
 opencv_imgproc.warpAffine(frame, transformedFrame, mat, new Size(frame.cols(), frame.rows()),opencv_imgproc.INTER_LANCZOS4,0,new Scalar(0,0,0,0));
 return transformedFrame;
 }



-
How to get video pixel location from screen pixel location ?
22 février 2024, par AmLearningWall of Text so I tried breaking it up into sections to make it better sorry in advance


The problem


I have some video files that I am reading with ffmpeg to get the colors at specific pixels, and all seems well, but I just ran into a problem with finding the right pixel to input. I realized (or mistakingly believe) that the pixel location (x,y) on the screen will be different than the local pixel location so to speak of the video (ie. If I want to get pixel 50,0 of the video that will be different than my screen's pixel 50,0 because the resolutions don't match). I was trying to think of a way to convert my screen's pixel location into the "local pixel location", and I have two ideas but I am not sure if any of them is any good. Note I am currently using cmd+shift+4 on macos to get the screen coordinates and the video is playing fullscreen like in the screenshot below.


Ideas


- 

-
If I manually measure and account for this vertical offset, would it effectively convert the screen coordinate into the "local" one ?


-
If I instead adjust my
SwsContext
to put the destination height and width as that of my screen, will it effectively replace the need to convert screen coordinates to the video coordinates ?







Problems with the Ideas


The problems I see with the first solution are that I am assuming there is no hidden horizontal offset (or conversely that all of the width of the video is actually renderable on the screen). Additionally, this solution would only get an approximate result as I would need to manually measure the offsets, screen width, and screen height using the method I currently am using to get the screen coordinates.


With the second solution, aside from the question of if it will even work, the problem becomes that I can no longer measure what the screen coordinates I want are because I can't seem to get rid of those black bars in VLC.


Some Testing I did


Given that if the black bars are part of the video itself, my entire problem would be fixed (maybe ?) I tried seeing if the black bars were part of the video, and when I looked at the frame data's first pixel, it was black. The problem then is that if the black bars are entirely part of the video, then why are the colors I get for some pixels slightly off (I am checking with ColorSync Utility). These colors aren't just slightly off as in wrong but it seems more that they belong to a slightly offset region of the video.


However, this may be somewhat explained if ffmpeg reads right to left. When I put the top left corner of the video into the program and looked again at the pixel data in the frame for that location (location again was calculated by assuming the video location would be the same as the screen location) instead of getting white, I got a bluish color much like the glove in the top right corner.


The Watered Down Code


struct SwsContext *rescaler = NULL;
 rescaler = sws_getContext(codec_context->width, codec_context->height, codec_context->pix_fmt, codec_context->width, codec_context->height, AV_PIX_FMT_RGB0, SWS_FAST_BILINEAR, NULL, NULL, 0);

// Get Packets (containers for frames but not guaranteed to have a full frame) and Frames
 while (av_read_frame(avformatcontext, packet) >= 0)
 {
 
 // determine if packet is video packet
 if (packet->stream_index != video_index)
 {
 continue;
 }
 
 // send packet to decoder
 if (avcodec_send_packet(codec_context, packet) < 0)
 {
 perror("Failed to decode packet");
 }
 
 // get frame from decoder
 int response = avcodec_receive_frame(codec_context, frame);
 if (response == AVERROR(EAGAIN))
 {
 continue;
 }
 else if (response < 0)
 {
 perror("Failed to get frame");
 }
 
 // convert frame to RGB0 colorspace 4 bytes per pixel 1 per channel
 response = sws_scale_frame(rescaler, scaled_frame, frame);
 if(response < 0){
 perror("Failed to change colorspace");
 }
 // get data and write it
 int pixel_number = y*(scaled_frame->linesize[0]/4)+x; // divide by four gets pixel linesize (4 byte per pixel)
 int byte_number = 4*(pixel_number-1); // position of pixel in array
 // start of debugging things
 int temp = scaled_frame->data[0][byte_number]; // R
 int one_after = scaled_frame->data[0][byte_number+1]; // G
 int two_after = scaled_frame->data[0][byte_number+2]; // B
 int als; // where i put the breakpoint
 // end of debugging things
 }



In Summary


I have no idea what is happening.


I take the data for a pixel and compare it to what colorsync utility says should be there, but it is always slightly off as though the pixel I was actually reading was offset from what I thought I was reading. Therefore, I want to find a way to get the pixel location in a video given a screen coordinate when the video is in fullscreen, but I have no idea how to (aside from a few ideas that are probably bad at best).


Also does FFMPEG put the frame data right to left ?


A Video Better Showing My Problem


https://www.youtube.com/watch?v=NSEErs2lC3A


-
-
AR.Drone 2, ffmpeg avcodec_decode_video2( ) segmentation fault
21 avril 2014, par mechanicalmanbI have been trying to decode the video stream from an AR.Drone 2.0 (http://ardrone2.parrot.com/) for a while now with no success. Despite several examples that I have been following closely (I’d paste links, but I am not allowed) I cannot escape a segmentation fault inside of the ffmpeg libavcodec library. I thought that perhaps I was making some kind of mistake in the multi-threaded structure I was building, so I cut out everything except the bare minimum you need to connect to the drone, collect a frame from the drone, and send it to ffmpeg’s avcodec_decode_video2() function.
I compiled the ffmpeg source (I’ve actually tried three different releases !) and can get the ffplay utility to display the drone’s video TCP stream. The video lags significantly, but at least I know the drone isn’t sending me complete gibberish.
Has anyone encountered a problem like this before ? What could be causing this segmentation fault, and what can I do about it ? Is there a way to isolate a test on ffmpeg so that I can be sure it is the library and not something I’ve been doing this entire time ?
Thanks for your time.
A pastebin with my code :
http://pastebin.com/NYTf0NeTSome details on my ffmpeg and compiler set up :
ffmpeg version 2.2.git Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 3 2014 18:05:42 with gcc 4.8 (Ubuntu 4.8.1-2ubuntu1~12.04)
configuration:
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100The output of my code and a backtrace at the segmentation fault :
*********************** START ***********************
booting...
[h264 @ 0x604040] err{or,}_recognition separate: 1; 1
[h264 @ 0x604040] err{or,}_recognition combined: 1; 1
[h264 @ 0x604040] Unsupported bit depth: 0
asked for 40000 bytes, received packet of 1448 bytes
PaVE synchronized. YIPEEEEEEEEEEEEEEEEEEEEEEEE
---------------------------
Codec : H264
StreamID : 1
Timestamp : 1031517 ms
Encoded dims : 640 x 368
Display dims : 640 x 360
Header size : 76
Payload size : 17583
Size of SPS inside payload : 14
Size of PPS inside payload : 10
Slices in the frame : 1
Frame Type / Number : IDR-Frame : 31467 : slide 1/1
---------------------------
gathering payload...
asked for 16211 bytes, received packet of 1448 bytes
gathering payload...
asked for 14763 bytes, received packet of 1448 bytes
gathering payload...
asked for 13315 bytes, received packet of 1448 bytes
gathering payload...
asked for 11867 bytes, received packet of 1448 bytes
gathering payload...
asked for 10419 bytes, received packet of 1448 bytes
gathering payload...
asked for 8971 bytes, received packet of 1448 bytes
gathering payload...
asked for 7523 bytes, received packet of 1448 bytes
gathering payload...
asked for 6075 bytes, received packet of 1448 bytes
gathering payload...
asked for 4627 bytes, received packet of 1448 bytes
gathering payload...
asked for 3179 bytes, received packet of 1448 bytes
gathering payload...
asked for 1731 bytes, received packet of 1448 bytes
gathering payload...
asked for 283 bytes, received packet of 283 bytes
payload complete, attempting to decode frame
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff73fccba in ?? () from /usr/lib/x86_64-linux-gnu/libavcodec.so.53
(gdb) bt
#0 0x00007ffff73fccba in ?? () from /usr/lib/x86_64-linux-gnu/libavcodec.so.53
#1 0x00007ffff73fd8f5 in avcodec_decode_video2 () from /usr/lib/x86_64-linux-gnu/libavcodec.so.53
#2 0x000000000040159f in fetch_and_decode(int, parrot_video_encapsulation_t, AVCodecContext*, AVFrame*)
()
#3 0x00000000004019c6 in main ()EDIT : I used Valgrind to try and get a better picture of the seg fault, and received the following :
==4730== Invalid read of size 1
==4730== at 0x5265CBA: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
==4730== by 0x52668F4: avcodec_decode_video2 (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
==4730== by 0x40140E: fetch_and_decode(int, AVCodecContext*, AVFrame*) (main.cpp:176)
==4730== by 0x401757: main (main.cpp:273)
==4730== Address 0x280056c46f9 is not stack'd, malloc'd or (recently) free'd
==4730==
==4730==
==4730== Process terminating with default action of signal 11 (SIGSEGV)
==4730== Access not within mapped region at address 0x280056C46F9
==4730== at 0x5265CBA: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
==4730== by 0x52668F4: avcodec_decode_video2 (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
==4730== by 0x40140E: fetch_and_decode(int, AVCodecContext*, AVFrame*) (main.cpp:176)
==4730== by 0x401757: main (main.cpp:273)"Invalid read size of 1" refers to trying to access a byte outside the bounds of an array. Does this mean that the library is trying to access something outside the bounds of an array I’m giving it ? I’ve checked the AVPkt, and that seems fine. I’m still stumped !