
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (83)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
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 (4291)
-
Queue in Python processing more than one video at a time ? [closed]
12 novembre 2024, par Mateus CoelhoI have an raspberry pi, that i proccess videos, rotate and put 4 water marks, but, when i run into the raspberry pi, it uses 100% of 4CPUS threads and it reboots. I solved this using -threads 1, to prevent the usage of just one of the 4 CPUS cores, it worked.


I made a Queue to procces one at a time, because i have 4 buttons that trigger the videos. But, when i send more then 3 videos to the Queue, the rasp still reboots, and im monitoring the CPU usage, is 100% for only one of the four CPUS



But, if i send 4 or 5 videos to the thread folder, it completly reboots, and the most awkward, its after the reboot, it made its way to proceed all the videos.



import os
import time
import subprocess
from google.cloud import storage
import shutil

QUEUE_DIR = "/home/abidu/Desktop/ApertaiRemoteClone"
ERROR_VIDEOS_DIR = "/home/abidu/Desktop/ApertaiRemoteClone/ErrorVideos"
CREDENTIALS_PATH = "/home/abidu/Desktop/keys.json"
BUCKET_NAME = "videos-283812"

def is_valid_video(file_path):
 try:
 result = subprocess.run(
 ['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1', file_path],
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE
 )
 return result.returncode == 0
 except Exception as e:
 print(f"Erro ao verificar o vídeo: {e}")
 return False

def overlay_images_on_video(input_file, image_files, output_file, positions, image_size=(100, 100), opacity=0.7):
 inputs = ['-i', input_file]
 for image in image_files:
 if image:
 inputs += ['-i', image]
 filter_complex = "[0:v]transpose=2[rotated];"
 current_stream = "[rotated]"
 for i, (x_offset, y_offset) in enumerate(positions):
 filter_complex += f"[{i+1}:v]scale={image_size[0]}:{image_size[1]},format=rgba,colorchannelmixer=aa={opacity}[img{i}];"
 filter_complex += f"{current_stream}[img{i}]overlay={x_offset}:{y_offset}"
 if i < len(positions) - 1:
 filter_complex += f"[tmp{i}];"
 current_stream = f"[tmp{i}]"
 else:
 filter_complex += ""
 command = ['ffmpeg', '-y', '-threads', '1'] + inputs + ['-filter_complex', filter_complex, '-threads', '1', output_file]

 try:
 result = subprocess.run(command, check=True)
 result.check_returncode() # Verifica se o comando foi executado com sucesso
 print(f"Vídeo processado com sucesso: {output_file}")
 except subprocess.CalledProcessError as e:
 print(f"Erro ao processar o vídeo: {e}")
 if "moov atom not found" in str(e):
 print("Vídeo corrompido ou sem o moov atom. Pulando o arquivo.")
 raise # Relança a exceção para ser tratada no nível superior

def process_and_upload_video():
 client = storage.Client.from_service_account_json(CREDENTIALS_PATH)
 bucket = client.bucket(BUCKET_NAME)
 
 while True:
 # Aguarda 10 segundos antes de verificar novos vídeos
 time.sleep(10)

 # Verifica se há arquivos no diretório de fila
 queue_files = [f for f in os.listdir(QUEUE_DIR) if f.endswith(".mp4")]
 
 if queue_files:
 video_file = os.path.join(QUEUE_DIR, queue_files[0]) # Pega o primeiro vídeo na fila
 
 # Define o caminho de saída após o processamento com o mesmo nome do arquivo de entrada
 output_file = os.path.join(QUEUE_DIR, "processed_" + os.path.basename(video_file))
 if not is_valid_video(video_file):
 print(f"Arquivo de vídeo inválido ou corrompido: {video_file}. Pulando.")
 os.remove(video_file) # Remove arquivo corrompido
 continue

 # Processa o vídeo com a função overlay_images_on_video
 try:
 overlay_images_on_video(
 video_file,
 ["/home/abidu/Desktop/ApertaiRemoteClone/Sponsor/image1.png", 
 "/home/abidu/Desktop/ApertaiRemoteClone/Sponsor/image2.png", 
 "/home/abidu/Desktop/ApertaiRemoteClone/Sponsor/image3.png", 
 "/home/abidu/Desktop/ApertaiRemoteClone/Sponsor/image4.png"],
 output_file,
 [(10, 10), (35, 1630), (800, 1630), (790, 15)],
 image_size=(250, 250),
 opacity=0.8
 )
 
 if os.path.exists(output_file):
 blob = bucket.blob(os.path.basename(video_file).replace("-", "/"))
 blob.upload_from_filename(output_file, content_type='application/octet-stream')
 print(f"Uploaded {output_file} to {BUCKET_NAME}")
 os.remove(video_file)
 os.remove(output_file)
 print(f"Processed and deleted {video_file} and {output_file}.")
 
 except subprocess.CalledProcessError as e:
 print(f"Erro ao processar {video_file}: {e}")
 
 move_error_video_to_error_directory(video_file)

 continue # Move para o próximo vídeo na fila após erro

def move_error_video_to_error_directory(video_file):
 print(f"Movendo arquivo de vídeo com erro {video_file} para {ERROR_VIDEOS_DIR}")

 if not os.path.exists(ERROR_VIDEOS_DIR):
 os.makedirs(ERROR_VIDEOS_DIR)
 
 shutil.move(video_file, ERROR_VIDEOS_DIR)

if __name__ == "__main__":
 process_and_upload_video()




-
Why is ffmpeg trying to produce both h.264 as well as h.265 ?
7 mars 2018, par hydra3333I think I only ask for h.265 output, but the output loge below seems to indicate it is trying to produce 2 video streams as output.
"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\built_for_generic_opencl\x64_8bit\ffmpeg.exe" -hide_banner -v verbose -threads 0 -i "G:\HDTV\0nvencc\test-mp4-03\ABC HD interlaced.aac.mp4" -t 15 -threads 0 -an -sws_flags lanczos+accurate_rnd+full_chroma_int+full_chroma_inp -filter_complex "[0:v]yadif=0:0:0" -pixel_format yuv420p -pix_fmt yuv420p -strict -1 -f yuv4mpegpipe - 2> .\zzz1.h265.txt
| "C:\SOFTWARE\ffmpeg\0-homebuilt-x64\built_for_generic_opencl\x64_8bit\ffmpeg.exe" -strict -1 -hide_banner -v verbose -threads 0 -i - -strict -1 -c:v:0 libx265 -crf 28 output.mp4 -an -y .\zzz.h265.mp4 2> .\zzz2.h265.txt
-----------------------------
<snip to="to" make="make" code="code" block="block" smaller="smaller">
Stream mapping:
Stream #0:0 (h264) -> yadif
yadif -> Stream #0:0 (wrapped_avframe)
Press [q] to stop, [?] for help
[h264 @ 000001b78ca87c00] Reinit context to 1920x1088, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 000001b78ca264c0] w:1920 h:1080 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:1/1 sws_param:flags=2
</snip>Output file #0 (pipe:):
Output stream #0:0 (video): 2 frames encoded; 2 packets muxed (1072 bytes);
Total: 2 packets (1072 bytes) muxed
Conversion failed!
-----------------------------
Routing option strict to both codec and muxer layer
Last message repeated 1 times
Input #0, yuv4mpegpipe, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p(progressive, left), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libx265))
Stream #0:0 -> #1:0 (rawvideo (native) -> h264 (libx264))
[graph 0 input from stream 0:0 @ 0000027f5ebefa00] w:1920 h:1080 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2
x265 [info]: HEVC encoder version 2.7613d9f443769
x265 [info]: build info [Windows][GCC 7.3.0][64 bit] 8bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 8 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 3 / wpp(17 rows)
----------------------------- -
Converting DVD image with subtitles to MKV using avconv
16 janvier 2016, par Carlos Eugenio Thompson PinzónThis is the procedure I know to convert a DVD image to another videoformat (v.g. MP4) :
- concatenate the
VTS_01_
n.VOB
files insideVIDEO_TS
folder (for n >= 0) into a single VOB file. - use
avconv
orffmpeg
in order to convert that VOB into another format.
So far so good, however now I want to convert the DVD image with the subtitles. As far as I know the MKV format supports subtitles, so it seems an obvious choice. Alternatively I might use any other format with hard subtitles (subtitles as part of the video image).
However, the subtitle encoding in the DVD image is
dvdsub
and I get the following errorOnly SUBTITLE_ASS type supported.
Subtitle encoding failedHowever, when running
avconv -codecs
I get :...
DES dvdsub DVD subtitles
...And the
-c:s copy
switch, while it prevents the command to fail, it does not seem to produce a subtitle that the player can understand.So, how can I create
ass
subtitles fromdvdsub
usingavconv
?My VOB file has eight subtitle channels and two audio channels. The Ubuntu video app does not show any subtitles, and only the first audio channel seems to be working, do the DVD image might be broken.
Another file, for a double-layer DVD, displays the Subtitle encoding error, however when using the
-c:s copy
switch it further displays :Application provided invalid, non monotonically increasing dts to muxer in stream 2: 49 >= 49
av_interleaved_write_frame(): Invalid argumentThank you in advance for any ideas on how to solve these problems.
(I am using Ubuntu where
ffmpeg
is an alias foravconv
. I know it is possible to install the real ffmpeg but so far I have not done so.)
update : commands and console outputs :
commands
cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB > ~/temp/mymovie.VOB
cd ~/temp
avconv -i mymovie.VOBoutput
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0x1a64d40] max_analyze_duration reached
Input #0, mpeg, from 'mymovie.VOB':
Duration: 00:00:01.95, start: 0.280633, bitrate: -2147483 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
At least one output file must be specifiedcommand
avconv -i mymovie.VOB mymovie.mkv
output
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0x1cdad40] max_analyze_duration reached
Input #0, mpeg, from 'mymovie.VOB':
Duration: 00:00:01.95, start: 0.280633, bitrate: -2147483 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
File 'mymovie.mkv' already exists. Overwrite ? [y/N] y
[buffer @ 0x1ce23c0] w:720 h:480 pixfmt:yuv420p
Output #0, matroska, to 'mymovie.mkv':
Metadata:
encoder : Lavf53.21.1
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 29.97 tbc
Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
Stream #0.2: Subtitle: ass, 200 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
Stream #0:9 -> #0:1 (ac3 -> libvorbis)
Stream #0:1 -> #0:2 (dvdsub -> ass)
Press ctrl-c to stop encoding
[ass @ 0x1ce0140] Only SUBTITLE_ASS type supported.
Subtitle encoding failedcommand
avconv -i mymovie.VOB -c:s copy mymovie.mkv
output omitted.
command
avconv -i mymovie.mkv
output
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[matroska,webm @ 0xbc1d40] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from 'mymovie.mkv':
Metadata:
ENCODER : Lavf53.21.1
Duration: 01:05:09.47, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn, 30k tbc (default)
Stream #0.1: Audio: vorbis, 48000 Hz, 5.1, s16 (default)
Stream #0.2: Subtitle: dvdsub (default)
At least one output file must be specifiedNow, for the double-layer :
commandscat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB VTS_01_6.VOB VTS_01_7.VOB VTS_01_8.VOB > ~/temp/mylongmovie.VOB
cd ~/temp
avconv -i mylongmovie.VOB mylongmovie.mkvoutput
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0x13c2d40] max_analyze_duration reached
Input #0, mpeg, from 'Cosmos-0203.VOB':
Duration: 00:00:30.24, start: 0.280633, bitrate: 2103365 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 8000 kb/s, 27.46 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
File 'mylongmovie.mkv' already exists. Overwrite ? [y/N] y
[buffer @ 0x13ca3c0] w:720 h:480 pixfmt:yuv420p
Output #0, matroska, to 'mylongmovie.mkv':
Metadata:
encoder : Lavf53.21.1
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 59.94 tbc
Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
Stream #0.2: Subtitle: ass, 200 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
Stream #0:9 -> #0:1 (ac3 -> libvorbis)
Stream #0:1 -> #0:2 (dvdsub -> ass)
Press ctrl-c to stop encoding
[ass @ 0x13d19c0] Only SUBTITLE_ASS type supported.
Subtitle encoding failedcommand
avconv -i mylongmovie.VOB -c:s copy mylongmovie.mkv
output
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0xce1d40] max_analyze_duration reached
Input #0, mpeg, from 'mylongmovie.VOB':
Duration: 00:00:30.24, start: 0.280633, bitrate: 2103365 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 8000 kb/s, 27.46 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
File 'mylongmovie.mkv' already exists. Overwrite ? [y/N] y
[buffer @ 0xce93c0] w:720 h:480 pixfmt:yuv420p
Output #0, matroska, to 'mylongmovie.mkv':
Metadata:
encoder : Lavf53.21.1
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 59.94 tbc
Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
Stream #0.2: Subtitle: dvdsub
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
Stream #0:9 -> #0:1 (ac3 -> libvorbis)
Stream #0:1 -> #0:2 (copy)
Press ctrl-c to stop encoding
[matroska @ 0xce4b40] Application provided invalid, non monotonically increasing dts to muxer in stream 2: 49 >= 49
av_interleaved_write_frame(): Invalid argument - concatenate the