
Recherche avancée
Autres articles (64)
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
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 ;
-
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
Sur d’autres sites (11728)
-
How to encode a HEVC video from YUV420 Mat data (from a hardware triggered camera) via FFmpeg in Python
4 juillet 2023, par QuantumRiverI am having problems encoding a HEVC video from a series of YUV420 Mat data via FFmpeg.


- 

- I am using python in Ubuntu-20.04 ;
- I am retrieving frame data from a hardware triggered camera (BASLER), using pypylon ;
- I want to write a video from that camera in HEVC codec, using my GPU-NVENC ;
- I guess I have to use FFmpeg to achieve these ;










What I have tried :


- 

- I find that FFmpeg supports encoding from a camera, but it seems to only support webcams, not the camera I use (hardware triggered BASLER cameras with pypylon APIs) ;
- I find that FFmpeg supports transfering a video from one codec to another, which is not my case ;
- I find that FFmpeg supports encoding a video from a series of jpeg images. But in my case, it will be inefficient if I first save each frame into a picture and then encode them into a video ;
- The frame data retrieved from camera can be converted to YUV420 (directly from pypylon), which is suitable for HEVC encoding ;
- I learnt that the basic unit in FFmpeg to encode a video is AVFrame. I guess I have to first turn my YUV420 data into AVFrame, then encode AVFrames into HEVC ;
- But I do not know how to achieve that in python.














My simplified and expected codes :


camera = pylon.InstantCamera(tlf.CreateFirstDevice())
converter = pylon.ImageFormatConverter()
converter.OutputPixelFormat = pylon.PixelType_YUV420
video_handle = xxxxxx # HEVC
while True:
 grabResult = camera.RetrieveResult(timeout, pylon.TimeoutHandling_ThrowException)
 image = converter.Convert(grabResult).GetArray()
 video_handle.write(frame) # encode into a hevc video via ffmpeg in NVENC



-
FFMPEG : Reversing only a segment of a video file
25 juillet 2019, par N. JohnsonI am writing a script that takes a piece of video and then reverses the same piece of video and then concats the two together so the final video plays forwards and then loops backwards. I should note that eventually I want to be able to pull an unequal length for the reverse part.
I can get the entire file to do this, but getting just a segment is not working as expected.
See code below
I’ve tried :
%1 = timecode to seek to (the video file is only 20 seconds and never any longer)
%2 = length of segment to pull out
%3 = usually the same as %2 but may be different if we want to only reverse 2 seconds instead of the full 5 for example.
ffmpeg -ss 00:00:%1 -an -i test.mp4 -t 00:00:%2 out.mp4
:: the above works as expected
:: this doesn't, no matter what I put into -ss. I've also tried moving -ss out front of the -i as suggested in the documentation? It gives me the right length of segment but never starts in the right place.
ffmpeg -an -i test.mp4 -ss 00:00:xx -t 00:00:%3 -vf reverse reversed2.mp4
:the below works fine
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4When I run this with say %1 = 05 and %2 = 05, I get a segment from 5 seconds in that lasts 5 seconds. Then I get a seemingly random starting point and 5 seconds of reversed video. I’ve tried a number of inputs in "XX" from 10 (which I think is right) to 0 to 19 and all of them produce output. But it’s all wrong.
-
Correct way to dump yuv values after avcodec_decode_video2
27 juin 2017, par PeterI am decoding H.265 raw data :
avcodec_decode_video2(decoderCtx, pictYUV, &gotPicture, &packet)
After the call, the value for
pictYUV->format
is AV_PIX_FMT_YUV420P as expected.I dump raw yuv values to a file as follows :
fwrite(pictYUV->data[0], 1, w*h, f);
fwrite(pictYUV->data[2], 1, w*h/4, f);
fwrite(pictYUV->data[1], 1, w*h/4, f);For an input size of 640x480, when the file is viewed (using ImageMagick display utility), the image is what was expected.
However, for an input size of 864x480, the image appears to be corrupted.
What is interesting is if I run pictYUV through sws_scale, and dump the resulting yuv output, the image appears to be fine.
sws_scale(swsCtx, pictYUV->data, pictYUV->linesize, 0, pictYUV->height,
pictNewYUV->data, pictNewYUV->linesize);All I need is yuv data. I am hoping I can avoid the extra call to sws_scale. Wondering what is it that I am missing. Regards.