
Recherche avancée
Médias (2)
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (6)
-
Selection of projects using MediaSPIP
2 mai 2011, parThe examples below are representative elements of MediaSPIP specific uses for specific projects.
MediaSPIP farm @ Infini
The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...) -
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...) -
Sélection de projets utilisant MediaSPIP
29 avril 2011, parLes exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
Ferme MediaSPIP @ Infini
L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)
Sur d’autres sites (2681)
-
MAINTAINERS : Split project server admin list
6 août 2022, par Michael NiedermayerMAINTAINERS : Split project server admin list
This updates the list closer to reality.
Iam not a professional server admin, iam happy to help maintain the box as i have
done in the past. But iam not qualified nor volunteering to fix sudden problems
nor do i do major upgrades (i lack the experience to recover the box remotely if
something goes wrong) and also iam not maintaining backups ATM (our backup system
had a RAID-5 failure, raz is working on setting a new one up)Maybe this should be signaled in a different way than spliting the lines but ATM
people ping me if something is wrong and what i do is mainly mail/ping raz
and try to find another root admin so raz is not the only active & professional
admin on the team. It would be more efficient if people contact raz and others
directly instead of depending on my waking up and forwarding a "ffmpeg.org" is down noteSigned-off-by : Michael Niedermayer <michael@niedermayer.cc>
-
Video Frame-by-Frame Deraining with MFDNet in Python
28 octobre 2024, par JimmyHuAs this CodeReview question mentioned, I am trying to modify the code to process frame-by-frame rain streaks removal in a video. FFmpeg package is used in this code.


import argparse
import os
import time

import cv2
import ffmpeg
import numpy as np
import torch
from skimage import img_as_ubyte
from torch.utils.data import DataLoader
from tqdm import tqdm

import utils
from data_RGB import get_test_data
from MFDNet import HPCNet as mfdnet


def process_video_frame_by_frame(input_file, output_file, model_restoration):
 """
 Decodes a video frame by frame, processes each frame,
 and re-encodes to a new video.

 Args:
 input_file: Path to the input video file.
 output_file: Path to the output video file.
 """
 try:
 # Probe for video information
 probe = ffmpeg.probe(input_file)
 video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None)
 width = int(video_stream['width'])
 height = int(video_stream['height'])

 # Input
 process1 = (
 ffmpeg
 .input(input_file)
 .output('pipe:', format='rawvideo', pix_fmt='rgb24')
 .run_async(pipe_stdout=True)
 )

 # Output
 process2 = (
 ffmpeg
 .input('pipe:', format='rawvideo', pix_fmt='rgb24', s='{}x{}'.format(width, height))
 .output(output_file, vcodec='libx264', pix_fmt='yuv420p')
 .overwrite_output()
 .run_async(pipe_stdin=True)
 )

 # Process frame (deraining processing)
 while in_bytes := process1.stdout.read(width * height * 3):
 in_frame = torch.frombuffer(in_bytes, dtype=torch.uint8).float().reshape((1, 3, width, height))
 restored = model_restoration(torch.div(in_frame, 255).to(device='cuda'))
 restored = torch.clamp(restored[0], 0, 1)
 restored = restored.cpu().detach().numpy()
 restored *= 255
 out_frame = restored
 np.reshape(out_frame, (3, width, height))

 # Encode and write the frame
 process2.stdin.write(
 out_frame
 .astype(np.uint8)
 .tobytes()
 )
 
 # Close streams
 process1.stdout.close()
 process2.stdin.close()
 process1.wait()
 process2.wait()

 except ffmpeg.Error as e:
 print('stdout:', e.stdout.decode('utf8'))
 print('stderr:', e.stderr.decode('utf8'))

if __name__ == '__main__':
 parser = argparse.ArgumentParser(description='Image Deraining using MPRNet')

 parser.add_argument('--weights', default='./checkpoints/checkpoints_mfd.pth', type=str,
 help='Path to weights')
 parser.add_argument('--gpus', default='0', type=str, help='CUDA_VISIBLE_DEVICES')

 args = parser.parse_args()

 os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
 os.environ["CUDA_VISIBLE_DEVICES"] = args.gpus

 model_restoration = mfdnet()
 utils.load_checkpoint(model_restoration, args.weights)
 print("===>Testing using weights: ", args.weights)

 model_restoration.eval().cuda()
 
 input_video = "Input_video.mp4"
 output_video = 'output_video.mp4'

 process_video_frame_by_frame(input_video, output_video, model_restoration)



Let's focus on the
while
loop part :

The version of the code snippet above can be executed without error. In the next step, I am trying to follow 301_Moved_Permanently's answer to make the usage of
torch.save
. Therefore, the contents ofwhile
loop comes as the following code :

# Process frame (deraining processing)
 while in_bytes := process1.stdout.read(width * height * 3):
 in_frame = torch.frombuffer(in_bytes, dtype=torch.uint8).float().reshape((1, 3, width, height))
 restored = model_restoration(torch.div(in_frame, 255).to(device='cuda'))
 restored = torch.clamp(restored[0], 0, 1)
 out_frame = torch.mul(restored.cpu().detach(), 255).reshape(3, width, height).byte()
 torch.save(out_frame, process2.stdin)



Out of memory error happened with the following message :




torch.OutOfMemoryError : CUDA out of memory. Tried to allocate 676.00 MiB. GPU 0 has a total capacity of 23.99 GiB of which 0 bytes is free. Of the allocated memory 84.09 GiB is allocated by PyTorch, and 1.21 GiB is reserved by PyTorch but unallocated.




To diagnostics the error, I removed the last two lines of code :


# Process frame (deraining processing)
 while in_bytes := process1.stdout.read(width * height * 3):
 in_frame = torch.frombuffer(in_bytes, dtype=torch.uint8).float().reshape((1, 3, width, height))
 restored = model_restoration(torch.div(in_frame, 255).to(device='cuda'))
 restored = torch.clamp(restored[0], 0, 1)



The out of memory error still happened. This is weird to me. My understanding of the executable version code, the line
restored = restored.cpu().detach().numpy()
is to transfer therestored
data in GPU memory to main memory and then convert it to numpy format. Why I remove this line of code then out of memory error happened ?

The hardware and software specification I used is as follows :


- 

-
CPU : 12th Gen Intel(R) Core(TM) i9-12900K 3.20 GHz


-
RAM : 128 GB (128 GB usable)


-
Graphic card : NVIDIA GeForce RTX 4090


-
OS : Windows 11 Pro 22H2, OS build : 22621.4317


-
Pytorch version :


> python -c "import torch; print(torch.__version__)"
2.5.0+cu124















-
-
Why does File upload for moving image and Audio to tmp PHP folder work on Windows but only image upload portion works on Mac using MAMP ?
31 mai 2021, par YazdanSo according to my colleague who tested this on Windows says it works perfectly fine , but in my case when I use it on a Mac with MAMP for Moodle , the image files get uploaded to the correct destination folder without an issue whereas the audio files don't move from the tmp folder to the actual destination folder and to check if this was the case ... I just changed and gave a fixed path instead of
$fileTmpLoc
and the file made it to the correct destination. Sorry I know the first half of the code isn't the main issue but I still wanted to post the whole code so one could understand it easily, moreover I am just beginning to code so please "have a bit of patience with me" . Thanks in advance


// this file contains upload function 
// checks if the file exists in server
include("../db/database.php");
require_once(dirname(__FILE__) . '/../../../config.php');
global $IP;

$ajaxdata = $_POST['mediaUpload'];

$FILENAME = $ajaxdata[1];
$IMAGE=$ajaxdata[0];
// an array to check which category the media belongs too
$animal= array("bird","cat","dog","horse","sheep","cow","elephant","bear","giraffe","zebra");
$allowedExts = array("mp3","wav");
$temp = explode(".", $_FILES["audio"]["name"]);
$extension = end($temp);



$test = $_FILES["audio"]["type"]; 


if (
 $_FILES["audio"]["type"] == "audio/wav"||
 $_FILES["audio"]["type"] == "audio/mp3"||
 $_FILES["audio"]["type"] == "audio/mpeg"
 &&
 in_array($extension, $allowedExts)
 )
 {

 // if the name detected by object detection is present in the animal array
 // then initialize target path to animal database or to others
 if (in_array($FILENAME, $animal)) 
 { 
 $image_target_dir = "image_dir/";
 $audio_target_dir = "audio_dir/";
 } 
 else
 { 
 $image_target_dir = "other_image_dir/";
 $audio_target_dir = "other_audio_dir/";
 } 
 // Get file path
 
 $img = $IMAGE;
 // decode base64 image
 $img = str_replace('data:image/png;base64,', '', $img);
 $img = str_replace(' ', '+', $img);
 $image_data = base64_decode($img);

 //$extension = pathinfo( $_FILES["fileUpload"]["name"], PATHINFO_EXTENSION ); // jpg
 $image_extension = "png";
 $image_target_file =$image_target_dir . basename($FILENAME . "." . $image_extension);
 $image_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$image_target_file;
 
 
 $audio_extension ="mp3";
 $audio_target_file= $audio_target_dir . basename($FILENAME. "." . $audio_extension) ;
 $audio_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$audio_target_file;

 // file size limit
 if(($_FILES["audio"]["size"])<=51242880)
 {

 $fileName = $_FILES["audio"]["name"]; // The file name
 $fileTmpLoc = $_FILES["audio"]["tmp_name"]; // File in the PHP tmp folder
 $fileType = $_FILES["audio"]["type"]; // The type of file it is
 $fileSize = $_FILES["audio"]["size"]; // File size in bytes
 $fileErrorMsg = $_FILES["audio"]["error"]; // 0 for false... and 1 for true
 
 if (in_array($FILENAME, $animal)) 
 { 
 $sql = "INSERT INTO mdl_media_animal (animal_image_path,animal_name,animal_audio_path) VALUES ('$image_file_upload','$FILENAME','$audio_file_upload')";
 } else {
 $sql = "INSERT INTO mdl_media_others (others_image_path,others_name,others_audio_path) VALUES ('$image_file_upload','$FILENAME','$audio_file_upload')";
 }

 // if file exists
 if (file_exists($audio_target_file) || file_exists($image_target_file)) {
 echo "alert";
 } else {
 // write image file
 if (file_put_contents($image_target_file, $image_data) ) {
 // ffmpeg to write audio file
 $output = shell_exec("ffmpeg -i $fileTmpLoc -ab 160k -ac 2 -ar 44100 -vn $audio_target_file");
 echo $output;
 
 // $stmt = $conn->prepare($sql);
 $db = mysqli_connect("localhost", "root", "root", "moodle310"); 
 // echo $sql;
 if (!$db) {
 echo "nodb";
 die("Connection failed: " . mysqli_connect_error());
 }
 // echo"sucess";
 if(mysqli_query($db, $sql)){
 // if($stmt->execute()){
 echo $fileTmpLoc;
 echo "sucess"; 
 echo $output;
 }
 else {
 // echo "Error: " . $sql . "<br />" . mysqli_error($conn);
 echo "failed";
 }

 }else {
 echo "failed";
 }

 
 
 
 }
 
 // $test = "ffmpeg -i $outputfile -ab 160k -ac 2 -ar 44100 -vn bub.wav";
 } else
 {
 echo "File size exceeds 5 MB! Please try again!";
 }
}
else
{
 echo "PHP! Not a video! ";//.$extension." ".$_FILES["uploadimage"]["type"];
 }

?>



I am a student learning frontend but a project of mine requires a fair bit of backend. So forgive me if my question sounds silly.


What I meant by manually overriding it was creating another folder and a index.php file with
echo "hello"; $output = shell_exec("ffmpeg -i Elephant.mp3 -ab 160k -ac 2 -ar 44100 -vn bub.mp3"); echo $output;
so only yes in this caseElephant.mp3
was changed as the initial tmp path so in this case as suggested by Mr.CBroe the permissons shouldn't be an issue.

Okay I checked my
Apache_error.log
only to find out ffmpeg is indeed the culprit ... I had installedffmpeg
globally so I am not sure if it is an access problem but here is a snippet of the log

I checked my php logs and found out that
FFmpeg
is the culprit.
Attached is a short log file

[Mon May 31 18:11:33 2021] [notice] caught SIGTERM, shutting down
[Mon May 31 18:11:40 2021] [notice] Digest: generating secret for digest authentication ...
[Mon May 31 18:11:40 2021] [notice] Digest: done
[Mon May 31 18:11:40 2021] [notice] Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/1.0.2o PHP/7.2.10 configured -- resuming normal operations
sh: ffmpeg: command not found
sh: ffmpeg: command not found
sh: ffmpeg: command not found