
Recherche avancée
Médias (10)
-
Demon Seed
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Demon seed (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
The four of us are dying (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Corona radiata (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Lights in the sky (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Head down (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (48)
-
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 (...) -
Mise à disposition des fichiers
14 avril 2011, parPar défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...) -
Installation en mode ferme
4 février 2011, parLe mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
C’est la méthode que nous utilisons sur cette même plateforme.
L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)
Sur d’autres sites (8584)
-
How to change resolution without compromising video quality using ffmpeg ?
20 mars 2024, par blake bankerI'm trying to develop a simple video transcoding system.
When you upload a video,
After extracting the video and audio separately,
I want to encode them at 360, 720, and 1080p resolutions respectively and then merge them to create three final mp4 files.
At this time, I have two questions.


- 

-
Is there a big difference between encoding the video and audio separately in the original video file and encoding the original video file as is ? In a related book, it is said that a system is created by separating video and audio, and I am curious as to why.


-
I want to change the resolution without compromising the original image quality. At this time, the resolution of the uploaded file can be known at the time of upload. As a test, I created files according to each resolution, and found that the image quality was damaged. If I want to change only the resolution while keeping the original image quality, I would like to know how to adjust each ffmpeg option. We plan to change it to 360, 720, and 1080p.








-
-
Setting up multiple resolution value in Fast API for transcoding uploaded video files
23 janvier 2024, par Sanji VinsmokeI created an API for transcoding video files like adaptive bit rate of youtube. I used Fast API. Currently, I am trying to set resolution values for each file. But whenever I am adding multiple resolutions, I am recieving "422 unprocessible entity" error in the Swagger.


Here is my code :


async def transcode_video(input_path, output_folder, res, unique_id, total_files, pbar):
 # Use asyncio for command execution with progress bar
 output_path = os.path.join(output_folder, f"{res}p.m3u8")

 # Calculate the target size
 target_size = calculate_target_size(input_path)

 cmd_duration = f"ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {input_path}"
 total_duration = float(subprocess.check_output(cmd_duration, shell=True, text=True).strip())

 cmd = (
 f"ffmpeg -i {input_path} -vf scale=-2:{res} -c:a aac -b:a 128k "
 f"-g 50 -hls_time 1 -hls_list_size 0 "
 f"-crf 23 -b:v 100k -fs {target_size} "
 f"-hls_segment_filename \"{output_path.replace('.m3u8', '_%03d.ts')}\" "
 f"{output_path}"
 )

 process = await asyncio.create_subprocess_shell(
 cmd,
 stdout=asyncio.subprocess.PIPE,
 stderr=asyncio.subprocess.PIPE
 )

 while True:
 line = await process.stderr.readline()
 if not line:
 break
 line = line.decode().strip()
 if "time=" in line:
 # Extracting the time progress from FFmpeg output
 time_str = line.split("time=")[1].split()[0]
 current_time = sum(x * float(t) for x, t in zip([3600, 60, 1], time_str.split(":")))
 progress = (current_time / total_duration) * 100
 pbar.update(progress - pbar.n)

 # Wait for the transcoding process to complete
 await process.wait()

 if process.returncode != 0:
 raise HTTPException(status_code=500, detail="Video transcoding failed.")
 pbar.close()

 # Increment the total number of transcoded files
 total_files[0] += 1

@app.post("/transcode/")
async def transcode_video_endpoint(files: List[UploadFile] = File(...), resolutions: List[int] = None):
 # Counters for transcoded videos
 total_files = [0]

 # Iterate over each file
 for file in files:
 # Check if the file is a valid video file based on its extension
 valid_video_extensions = {".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv"}
 if not any(file.filename.lower().endswith(ext) for ext in valid_video_extensions):
 print(f"Skipping non-video file: {file.filename}")
 continue

 # Assign a unique ID for each file
 unique_id = str(uuid.uuid4())

 # Log the filename and unique ID
 print(f"Processing file: {file.filename} with unique ID: {unique_id}")

 # Create a folder for the unique ID
 unique_id_folder = os.path.join(OUTPUT_FOLDER, unique_id)
 Path(unique_id_folder).mkdir(parents=True, exist_ok=True)

 # Save the uploaded file
 input_path = os.path.join(UPLOAD_FOLDER, file.filename)
 with open(input_path, "wb") as video_file:
 video_file.write(file.file.read())

 # Check if the file is a valid video file using ffprobe
 try:
 subprocess.run(
 ["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=codec_type", "-of", "csv=p=0", input_path],
 check=True, capture_output=True
 )
 except subprocess.CalledProcessError:
 print(f"Skipping non-video file: {file.filename}")
 continue

 # Determine the resolutions to transcode based on the provided or default resolution
 resolutions_to_transcode = [res for res in [240, 360, 480, 720] if resolutions is None or res in resolutions]

 # If resolutions is not exactly 360, 480, 720, or 1080, transcode to the nearest lower resolution
 if resolutions is not None:
 resolutions_to_transcode = [get_closest_lower_resolution(res) for res in resolutions]

 # Transcode the video into the specified resolutions
 for res in resolutions_to_transcode:
 output_folder = os.path.join(unique_id_folder, f"{res}p")
 Path(output_folder).mkdir(parents=True, exist_ok=True)

 # Call the transcode_video function with tqdm progress bar
 with tqdm(total=100, desc=f"Transcoding {res}p", position=0, leave=True) as pbar:
 await transcode_video(input_path, output_folder, res, unique_id, total_files, pbar)

 # Create index.m3u8 file after transcoding all resolutions
 create_index_m3u8(unique_id, resolutions_to_transcode)

 return JSONResponse(content={"message": f"{total_files[0]} videos transcoded."})



If I provide one resolution it works fine. But if I provide a list of resolutions for all the uploaded videos I am getting error 422.



Code Details
422 
Error: Unprocessable Entity

Response body
Download
{
 "detail": [
 {
 "loc": [
 "body",
 "resolutions",
 0
 ],
 "msg": "value is not a valid integer",
 "type": "type_error.integer"
 }
 ]
}



I used python 3.8.18. Can you help me please ? I tried with list, object but always getting the error.


-
How to enlarge a video without changing the resolution in python ? [closed]
18 janvier 2024, par Killian RakotonanaharyI'm trying to convert a youtube video into a 9 : 16 video. So I'm scaling the video to 1080x1920, and it's returns me a minimized video with two black borders at the bottom and at the top.


I would like to zoom into the video, so the video will be able to fill all the format, with ffmpeg, or opencv or moviepy.


I tryied to crop the video with ffmpeg but the video is cropped without the black borders, like if the black borders wasnt a part of the file,
I tryed to zoom with ffmpeg but the zoompan continuously zoom during all the video, and the black borders are not affected by the zoom,
I tryed to remove the edges where the pixel value is less than or equal to a given threshold, but the ratio is not kept, and its result to a strechted video.
I would like to do something like https://new.express.adobe.com/tools/resize-video


Enlarge the video without affecting the resolution, so it's just result to a zoom effect.


The actual code is resizing the video to 9 : 16 with two black border at the bottom and on the top.


def divideWithCheckPoints(checkpointRanges):
 videoPath = 'assets/video.mp4'
 output_folder = 'assets/'

 video_clip = VideoFileClip(videoPath)
 
 for i, (start_time, end_time) in enumerate(checkpointRanges):
 output_file = f'{output_folder}video_part_{i+1}.mp4'
 command = [
 'ffmpeg',
 '-i', videoPath,
 '-ss', str(start_time),
 '-to', str(end_time),
 '-vf', "scale=1080:1920", # resize video
 '-c:a', 'aac',
 '-b:v', '1M', 
 output_file
 ]
 subprocess.run(command, check=True)
 
 last_start_time = checkpointRanges[-1][1]
 last_end_time = video_clip.duration 
 last_output_file = f'{output_folder}video_part_{len(checkpointRanges)+1}.mp4'
 command = [
 'ffmpeg',
 '-i', videoPath,
 '-ss', str(last_start_time),
 '-to', str(last_end_time),
 '-vf', "scale=1080:1920", # resize video
 '-c:a', 'aac', 
 last_output_file
 ]
 subprocess.run(command)



Output :




Expected :