
Recherche avancée
Autres articles (51)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...)
Sur d’autres sites (7479)
-
Variable fps (frame per second) in cv2
17 octobre 2022, par SepideI use
cv2
for creating videos from different frames that I have. When I create the video, I cannot change the fps (frame per second). I want the video be slow at the beginning but fast towards the end, meaning small fps at the beginning but large ones towards the end. However, when I instantiatecv2.VideoWriter
I cannot change the fps anymore. What should I do ?

Replicable code


import numpy as np
import cv2, os
import matplotlib

image_size = 200
def create_image_array(image_size):
 image_array = np.random.randn(image_size, image_size)
 row = np.random.randint(0, image_size)
 image_array[row, :] = 100
 return image_array

frame_numbers = 200
for i in range(frame_numbers):
 image_array = create_image_array(image_size)
 matplotlib.image.imsave(f'./shots/frame_{i:03d}.png', image_array)

def make_a_video(shots_folder, video_path):

 shots_folder = 'shots'
 fps = 25
 images = [img for img in os.listdir(shots_folder) if img.endswith(".png")]

 images = sorted(images)[:]
 frame = cv2.imread(os.path.join(shots_folder, images[0]))
 height, width, layers = frame.shape

 video = cv2.VideoWriter(video_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (width, height))

 for image in images:
 video.write(cv2.imread(os.path.join(shots_folder, image)))

 cv2.destroyAllWindows()
 video.release()

shots_folder = 'shots'
video_path = 'video.mp4' 
make_a_video(shots_folder, video_path)



-
How to create a local audio livestream server with ffmpeg and python ? [closed]
10 novembre 2024, par FenekhuSimply put, this is what I'm trying to accomplish :

I navigate to something likehttp://localhost:8080/
in my browser and the browser shows a built-in audio player playing whatever the ffmpeg process is streaming. (Not just serving a local audio file.) (Built-in here meaning the page looks the same as if you had opened an mp3 file with your browser.)

At first I thought it would be easy, as ffmpeg has the ability to stream through different protocols. I seem to have misunderstood though, because while I can stream something over rtp with it, I can't access that from my browser. Some stackoverflow questions I found seem to imply that you can do this with the output options
-f mpegts http://localhost:8080
, but when I try this, ffmpeg freezes for a second, then I get these errors :

[tcp @ 00000210f70b0700] Connection to tcp://localhost:8080 failed: Error number -138 occurred
[out#0/mpegts @ 00000210f7080ec0] Error opening output http://localhost:8080: Error number -138 occurred
Error opening output file http://localhost:8080.
Error opening output files: Error number -138 occurred



but I have no problem with
-f rtp rtp://localhost:8080
. (Like I said though, I can't access that through the browser).

So I suspect I need something else to "pick up" the rtp stream and put it on an http server, but I haven't been able to find anything on that, probably because I just don't know the right thing to search. It seems like something that should be easily doable in Python, and that would be my preferred language to do it in over javascript, if possible.


Can anyone point me in the right direction ? Or let me know if I'm misunderstanding something ? Thanks.


-
Understanding PTS and DTS in video frames
28 juin 2017, par theateistI had fps issues when transcoding from avi to mp4(x264). Eventually the problem was in PTS and DTS values, so lines 12-15 where added before av_interleaved_write_frame function :
1. AVFormatContext* outContainer = NULL;
2. avformat_alloc_output_context2(&outContainer, NULL, "mp4", "c:\\test.mp4";
3. AVCodec *encoder = avcodec_find_encoder(AV_CODEC_ID_H264);
4. AVStream *outStream = avformat_new_stream(outContainer, encoder);
5. // outStream->codec initiation
6. // ...
7. avformat_write_header(outContainer, NULL);
8. // reading and decoding packet
9. // ...
10. avcodec_encode_video2(outStream->codec, &encodedPacket, decodedFrame, &got_frame)
11.
12. if (encodedPacket.pts != AV_NOPTS_VALUE)
13. encodedPacket.pts = av_rescale_q(encodedPacket.pts, outStream->codec->time_base, outStream->time_base);
14. if (encodedPacket.dts != AV_NOPTS_VALUE)
15. encodedPacket.dts = av_rescale_q(encodedPacket.dts, outStream->codec->time_base, outStream->time_base);
16.
17. av_interleaved_write_frame(outContainer, &encodedPacket)After reading many posts I still do not understand :
outStream->codec->time_base
= 1/25 andoutStream->time_base
= 1/12800. The 1st one was set by me but I cannot figure out why and who set 12800 ? I noticed that before line (7)outStream->time_base
= 1/90000 and right after it it changes to 1/12800, why ?
When I transcode from avi to avi, meaning changing the line (2) toavformat_alloc_output_context2(&outContainer, NULL, "avi", "c:\\test.avi";
, so before and after line (7)outStream->time_base
remains always 1/25 and not like in mp4 case, why ?- What is the difference between time_base of
outStream->codec
andoutStream
? - To calc the pts
av_rescale_q
does : takes 2 time_base, multiplies their fractions in cross and then compute the pts. Why it does this in this way ? As I debugged, theencodedPacket.pts
has value incremental by 1, so why changing it if it does has value ? - At the beginning the dts value is -2 and after each rescaling it still has negative number, but despite this the video played correctly ! Shouldn’t it be positive ?