
Recherche avancée
Autres articles (84)
-
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, 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 (...) -
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
De l’upload à la vidéo finale [version standalone]
31 janvier 2010, parLe chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
Upload et récupération d’informations de la vidéo source
Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)
Sur d’autres sites (12270)
-
Compress multiple video at same time or single process using ffmepg python
3 janvier 2023, par Fraction AnalyticsI create python code to list all mp4 files in a current directory using below code


compress.py


import os
rootdir = 'SUBASH'
extensions = ('.mp4', '.avi', '.wmv')

for subdir, dirs, files in os.walk(rootdir):
 for file in files:
 ext = os.path.splitext(file)[-1].lower()
 print(ext)
 if ext in extensions:
 print (os.path.join(subdir, file))



After listing all
.mp4
files how to compress all file at a time using python andffmpeg


I tried :


ffmpeg -i input.mp4 -vcodec libx265 -acodec copy output.mp4


I tried this method to compress single video at a time but i want to do same thing for all .mp4 files in a current or specific directory


-
memory leak reading video frames to numpy array using ffmpeg as a python subprocess
19 novembre 2023, par paddygI can stream videos frame by frame to an OpenGL Texture2D OK in python (pi3d module, example in pi3d_demos/VideoWalk.py) but I've noticed that it gradually leaks memory. Below is a stripped down version of the code that shows the problem.


Can anyone see where I'm leaking ? The memory seems to be recovered when python stops. I've tried explicitly setting things to
None
or calling the garbage collector manually.

#!/usr/bin/python
import os
import numpy as np
import subprocess
import threading
import time
import json

def get_dimensions(video_path):
 probe_cmd = f'ffprobe -v error -show_entries stream=width,height,avg_frame_rate -of json "{video_path}"'
 probe_result = subprocess.check_output(probe_cmd, shell=True, text=True)
 video_info_list = [vinfo for vinfo in json.loads(probe_result)['streams'] if 'width' in vinfo]
 if len(video_info_list) > 0:
 video_info = video_info_list[0] # use first if more than one!
 return(video_info['width'], video_info['height'])
 else:
 return None

class VideoStreamer:
 def __init__(self, video_path):
 self.flag = False # use to signal new texture
 self.kill_thread = False
 self.command = [ 'ffmpeg', '-i', video_path, '-f', 'image2pipe',
 '-pix_fmt', 'rgb24', '-vcodec', 'rawvideo', '-']
 dimensions = get_dimensions(video_path)
 if dimensions is not None:
 (self.W, self.H) = dimensions
 self.P = 3
 self.image = np.zeros((self.H, self.W, self.P), dtype='uint8')
 self.t = threading.Thread(target=self.pipe_thread)
 self.t.start()
 else: # couldn't get dimensions for some reason - assume not able to read video
 self.W = 240
 self.H = 180
 self.P = 3
 self.image = np.zeros((self.H, self.W, self.P), dtype='uint8')
 self.t = None

 def pipe_thread(self):
 pipe = None
 while not self.kill_thread:
 st_tm = time.time()
 if pipe is None:
 pipe = subprocess.Popen(self.command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=-1)
 self.image = np.frombuffer(pipe.stdout.read(self.H * self.W * self.P), dtype='uint8') # overwrite array
 pipe.stdout.flush() # presumably nothing else has arrived since read()
 pipe.stderr.flush() # ffmpeg sends commentary to stderr
 if len(self.image) < self.H * self.W * self.P: # end of video, reload
 pipe.terminate()
 pipe = None
 else:
 self.image.shape = (self.H, self.W, self.P)
 self.flag = True
 step = time.time() - st_tm
 time.sleep(max(0.04 - step, 0.0)) # adding fps info to ffmpeg doesn't seem to have any effect
 if pipe is not None:
 pipe.terminate()
 pipe = None

 def kill(self):
 self.kill_thread = True
 if self.t is not None:
 self.t.join()

vs = None
try:
 while True:
 for (path, _, videos) in os.walk("/home/patrick/Pictures/videos"):
 for video in videos:
 print(video)
 os.system("free") # shows gradually declining memory available
 vs = VideoStreamer(os.path.join(path, video))
 for i in range(500):
 tries = 0
 while not vs.flag and tries < 5:
 time.sleep(0.001)
 tries += 1
 # at this point vs.image is a numpy array HxWxP bytes
 vs.flag = False
 vs.kill()
except KeyboardInterrupt:
 if vs is not None:
 vs.kill()


os.system("free")



-
Permission Issue with Bundled FFmpeg in Kotlin Jetpack Compose Desktop App
14 décembre 2023, par Farouk_AbichouI am developing a Kotlin Jetpack Compose Desktop application that utilizes FFmpeg for video processing. The FFmpeg and FFprobe binaries are included in my application resources. However, I am facing a permission issue where the FFmpeg does not have execution permissions when the application is distributed, even though it had the necessary permision


Error Message :


Error: Could not create instance for [Singleton:'record.video.domain.VideoRepository']




Relevant Code Snippets :


import java.io.File

object FFmpegUtils {
 val FFmpegPath: String by lazy {
 File(System.getProperty("compose.application.resources.dir"), "ffmpeg").path
 }

 val FFprobePath: String by lazy {
 File(System.getProperty("compose.application.resources.dir"), "ffprobe").path
 }
}



class VideoRepositoryImpl : VideoRepository {
 override fun getVideosByPath(filePath: String): List<video> {
 val videos = getFilesWithExtension(filePath, listOf("mp4", "mkv", "avi", "mov"))

 return videos.map { path ->
 Video(
 name = path.fileName.toString(),
 path = path.toString(),
 size = getFileSize(path),
 date = getFileDate(path),
 duration = getVideoDuration(path),
 thumbnail = getVideoThumbnail(path)
 )
 }
 }
}
</video>



object FileHelper {
 fun getFilesWithExtension(directoryPath: String, fileExtension: List<string>): List<path> {
 return Files.walk(Paths.get(directoryPath))
 .filter { fileExtension.any { extension ->
 it.fileName.toString().endsWith(extension)
 }
 }
 .collect(Collectors.toList())
 .toList()
 }
}
</path></string>


Attempted Solutions :


Manually changing file permissions post-installation.


Questions :


How can I programmatically set permissions for FFmpeg when my application is first installed or launched ?
Is there a common pattern or practice in Kotlin Jetpack Compose Desktop applications for handling bundled binaries and their permissions ?
Additional Context :


The application is intended to be cross-platform (Windows/macOS/Linux).
I am using the ffmpeg-cli-wrapper by bramp : [https://github.com/bramp/ffmpeg-cli-wrapper](enter image description here)
Any help or guidance from the community would be greatly appreciated.