
Recherche avancée
Médias (1)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
Autres articles (85)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Librairies et logiciels spécifiques aux médias
10 décembre 2010, parPour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...) -
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 (...)
Sur d’autres sites (6489)
-
Why is this ffmpeg conversion turning up trash ?
12 octobre 2015, par DigitalJedi805So, the company I work for still archives some of our data in Windows Media format.
I’ve written a C# application that loops through all of our WMVs, and in the event that a corresponding MP4 doesn’t exist, it fires off ffmpeg to convert the file.
What I’m running into, is a combination of problems.
When I run the following into ffmpeg ( rough C# ) :
"-i " + File.FullName + " -vf scale=720:480 -b:v 512k -bufsize 512k -vcodec libx264 -acodec aac -strict experimental " + OutputPath
I end up with a file that cannot play in our browser based player ( JWPlayer ), and cannot play on my local system in Windows Media Player.
Additionally, the file is larger than my WMV, and is larger than the file I output with [roughly] the same parameters in AVS Video Converter.
Furthermore, the file details don’t show any values for the video properties - as in, when I right click and go to properties->details, under ’video’, there is a list of length, height, width, frame rate, and bitrate - they are all empty - when I would very much expect some data normally.
Does anyone have any idea how I can make the conversion more straightforward, or what might be creating the problem in the first place ?
I’ve tried running this without scaling or bitrate parameters, and added them as an attempt to resolve the more core problem - obviously to no avail.
For everyone’s appeasement...
FFMPEG Output :
video:537604kB audio:158748kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 1.159483%
[libx264 @ 0453d000] frame I:1234 Avg QP:19.98 size: 33645
[libx264 @ 0453d000] frame P:94430 Avg QP:22.92 size: 3984
[libx264 @ 0453d000] frame B:208152 Avg QP:30.67 size: 638
[libx264 @ 0453d000] consecutive B-frames: 7.6% 1.8% 4.0% 86.6%
[libx264 @ 0453d000] mb I I16..4: 10.5% 61.2% 28.2%
[libx264 @ 0453d000] mb P I16..4: 0.4% 1.4% 0.3% P16..4: 26.8% 9.3% 4.8%
0.0% 0.0% skip:57.0%
[libx264 @ 0453d000] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 21.6% 1.1% 0.2%
direct: 0.4% skip:76.6% L0:42.6% L1:55.1% BI: 2.3%
[libx264 @ 0453d000] 8x8 transform intra:65.1% inter:71.9%
[libx264 @ 0453d000] coded y,uvDC,uvAC intra: 61.6% 59.3% 30.9% inter: 6.0% 6.7%
1.7%
[libx264 @ 0453d000] i16 v,h,dc,p: 34% 52% 7% 7%
[libx264 @ 0453d000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 27% 24% 3% 4% 4% 5%
4% 7%
[libx264 @ 0453d000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 38% 10% 3% 5% 4% 6%
3% 5%
[libx264 @ 0453d000] i8c dc,h,v,p: 47% 35% 14% 4%
[libx264 @ 0453d000] Weighted P-Frames: Y:0.2% UV:0.1%
[libx264 @ 0453d000] ref P L0: 67.8% 12.3% 14.3% 5.6% 0.0%
[libx264 @ 0453d000] ref B L0: 88.7% 9.7% 1.6%
[libx264 @ 0453d000] ref B L1: 92.6% 7.4%
[libx264 @ 0453d000] kb/s:434.44I’ll make the video files available shortly.
-
ffmpeg drop frames on purpose to lower filesize
20 octobre 2014, par maxOur security system records and archives our IP cameras streams with
ffmpeg -use_wallclock_as_timestamps 1 -i rtsp://192.168.x.x:554/mpeg4 -c copy -t 60 my_input_video.avi
I run it with crontab every minute so it creates videos of 60 seconds ( 15Mb) for each camera every minute. When an intrusion occurs, the camera sends a picture through FTP and a script called by incrontab :
1- forwards immediately the picture by email
2- selects the video covering the minute the intrusion occured, compress it with h264 (to 2,6Mb) and sends it by email
It is working really well but if a thief crosses the path of various cameras, the connection to the SMTP server is not fast enough so video emails are delayed. I’d like to compress the videos even more to avoid that. I could lower the resolution (640x480 to 320x240 for example) but sometimes 640x480 is handy to zoom on something which looks to be moving...
So my idea is to drop frames in the video in order to lower the filesize. I don’t care if the thief is walking like a "stop motion Lego" on the video, the most important is I know there is someone so I can act.
mediainfo my_input_video.avi
says Frame rate = 600.000 fps but it is of course wrong. FPS sent by IP cameras are always false because it varies with the network quality ; this is why i use "-use_wallclock_as_timestamps 1" in my command to record the streams.with
ffmpeg -i my_input_video.avi -vcodec h264 -preset ultrafast -crf 28 -acodec mp3 -q:a 5 -r 8 output.avi
the video is OK but filesize is higher (3Mb)with
ffmpeg -i my_input_video.avi -vcodec h264 -preset ultrafast -crf 28 -acodec mp3 -q:a 5 -r 2 output.avi
the filesize is lower (2,2Mb) but the video doesn’t work (it is blocked at the first frame).Creating a mjpeg video (mjpeg = not interlaced frames) in the middle of the process (first exporting to mjpeg with less frames and then exporting to h264) creates same results.
Do you know how I can get my thief to walk like a "stop motion Lego" to lower the filesize to a minimum ?
Thanks for any help
-
How to gracefully terminate ffmpeg process alongside with ffprobe process ?
26 mars 2023, par duruburakI was able to terminate ffmpeg process gracefully when it's the only ongoing process. Now I also have ffprobe process alongside with ffmpeg process that tracks the progress of the ffmpeg process. It throws the following exception when I try to cancel the process. I tried to put the statements inside try & except blocks but I don't think it's a good solution. What's the proper way to achieve this job ?


P.S. The code might be a bit confusing, but I tried to create a small executable form out of my actual code, sorry about that.


import subprocess as sp
import shlex
import json
import time
import threading

def start_ffmpeg_thread(audio_part, video_part, path):

 global ffmpeg_process
 if (ffmpeg_process is None) or ffmpeg_process.poll():
 data = sp.run(shlex.split(f'ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 -of json "{video_part}"'), stdout=sp.PIPE).stdout
 dict = json.loads(data)
 tot_n_frames = float(dict['streams'][0]['nb_read_packets'])

 ffmpeg_process = sp.Popen(shlex.split(f'ffmpeg -y -loglevel error -i "{video_part}" -i "{audio_part}" -progress pipe:1 "{path}"'), stdout=sp.PIPE, stdin=sp.PIPE)

 q = [0]

 ffmpeg_progress_reader_thread = threading.Thread(target=ffmpeg_progress_reader, args=(ffmpeg_process, q))
 ffmpeg_progress_reader_thread.start()

 while True:
 if ffmpeg_process.poll() is not None:
 break

 n_frame = q[0]
 progress_percent = (n_frame/tot_n_frames)*100
 print(f"Progress: [%] {progress_percent}", end="\r")
 ffmpeg_progress_reader_thread.join()

def ffmpeg_progress_reader(procs, q):

 while True:
 if procs.poll() is not None:
 break

 progress_text = procs.stdout.readline()
 progress_text = progress_text.decode("utf-8")
 if progress_text.startswith("frame="):
 frame = int(progress_text.partition('=')[-1])
 q[0] = frame

def cancel_ffmpeg():

 time.sleep(10)
 global ffmpeg_process
 if (ffmpeg_process is not None) and (ffmpeg_process.poll() is None):
 ffmpeg_process.stdin.write('q'.encode("GBK"))
 ffmpeg_process.communicate()
 ffmpeg_process.wait()
 ffmpeg_process = None


ffmpeg_process = None

threading.Thread(target=cancel_ffmpeg).start()
start_ffmpeg_thread(<>, <>, <>)



Exception in thread Thread-2 (ffmpeg_progress_reader):
Traceback (most recent call last):
 File "D:\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
 self.run()9.354796147248976
 File "D:\Python311\Lib\threading.py", line 975, in run
 self._target(*self._args, **self._kwargs)
 File "d:\Python Projects\main.py", line 82, in ffmpeg_progress_reader
 progress_text = procs.stdout.readline()
 ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL
Traceback (most recent call last):
 File "d:\Python Projects\main.py", line 101, in <module>
 start_ffmpeg_thread("aud.mp3", "vid.mp4", "output.mp4")
 File "d:\Python Projects\main.py", line 69, in start_ffmpeg_thread
 if ffmpeg_process.poll() is not None:
 ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'poll'
</module>