
Recherche avancée
Médias (91)
-
Valkaama DVD Cover Outside
4 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Valkaama DVD Cover Inside
4 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
1,000,000
27 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Demon Seed
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Four of Us are Dying
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (39)
-
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Submit enhancements and plugins
13 avril 2011If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.
Sur d’autres sites (5856)
-
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()




-
Fintech Content Marketing : 10 Best Practices & Growth Strategies
24 juillet 2024, par Erin -
av_bitstream_filter_filter memory leak
27 novembre 2018, par Tom MettamI’m attempting to use ffmpeg to decode and convert an h264 bitstream.
My code works, but it’s leaking quite badly on the call to
av_bitstream_filter_filter
.I can’t see what I’m doing wrong - could this be an ffmpeg internal bug ? Am I handling some resource incorrectly ?
Edit : The return value of av_bitstream_filter_filter is always 1.
extern "C" {
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
}
#include <string>
AVBitStreamFilterContext *annexb = nullptr;
int videoStreamIdx = -1;
AVFormatContext *fmt_ctx = nullptr;
AVPacket pkt;
AVPacket pkt2;
main(int argc, char *argv[])
{
av_register_all();
avformat_network_init();
annexb = av_bitstream_filter_init("h264_mp4toannexb");
std::string fn = "epicloop.mp4";
int err = avformat_open_input(&fmt_ctx, fn.c_str(), nullptr, nullptr);
if (err < 0)
{
printf("Unable to open stream hex: %x", err);
return -1;
}
if (avformat_find_stream_info(fmt_ctx, nullptr) < 0)
{
printf("Unable to retrieve stream info");
return -2;
}
for (unsigned int i = 0; i < fmt_ctx->nb_streams; i++)
{
AVStream * pStream = fmt_ctx->streams[i];
switch (pStream->codec->codec_type)
{
case AVMEDIA_TYPE_VIDEO:
videoStreamIdx = i;
break;
}
}
if (videoStreamIdx == -1)
{
printf("Unable to find video stream");
return -3;
}
av_init_packet(&pkt);
av_init_packet(&pkt2);
pkt.data = nullptr;
pkt.size = 0;
pkt2.data = nullptr;
pkt2.size = 0;
int result = 0;
while(true)
{
if (pkt.data != nullptr)
{
av_free_packet(&pkt);
pkt.data = nullptr;
pkt.size = 0;
}
if (pkt2.data != nullptr)
{
av_free_packet(&pkt2);
pkt2.data = nullptr;
pkt2.size = 0;
}
result = av_read_frame(fmt_ctx, &pkt);
if (result < 0)
{
printf("Failed to read frame. EOS?");
result = av_seek_frame(fmt_ctx, -1, 0, AVSEEK_FLAG_BACKWARD);
if (result < 0)
{
printf("Failed to seek");
return result;
}
else
{
result = av_read_frame(fmt_ctx, &pkt);
if (result < 0)
{
printf("Failed to read frame after seek");
return result;
}
}
}
if (pkt.stream_index == videoStreamIdx)
{
int a = av_bitstream_filter_filter(annexb,
fmt_ctx->streams[pkt.stream_index]->codec,
NULL,
&pkt2.data,
&pkt2.size,
pkt.data,
pkt.size,
pkt.flags & AV_PKT_FLAG_KEY);
av_free_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
/* HANDLE VIDEO IN PKT2 */
printf(".");
fflush(stdout);
}
}
}
</string>Here’s what Valgrind has to say :
=19276== Process terminating with default action of signal 2 (SIGINT)
==19276== at 0x734B363: read (in /lib64/libc-2.26.so)
==19276== by 0x656BED6: ??? (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x65508F3: ??? (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x655276B: avio_read (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x664DBBF: ??? (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x65BA94E: ??? (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x6651A69: ??? (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x665228B: ??? (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x6653017: av_read_frame (in /usr/lib64/libavformat.so.57.71.100)
==19276== by 0x109188: main (in /root/a.out)
==19276==
==19276== HEAP SUMMARY:
==19276== in use at exit: 2,643,751,020 bytes in 51,065 blocks
==19276== total heap usage: 707,985 allocs, 656,920 frees, 8,060,126,970 bytes allocated
==19276==
==19276== 8,303,769 bytes in 81 blocks are possibly lost in loss record 67 of 68
==19276== at 0x4C2F216: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19276== by 0x4C2F331: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19276== by 0x62B5CF2: av_malloc (in /usr/lib64/libavutil.so.55.58.100)
==19276== by 0x4F7BFB9: av_bitstream_filter_filter (in /usr/lib64/libavcodec.so.57.89.100)
==19276== by 0x109293: main (in /root/a.out)
==19276==
==19276== 2,635,145,556 bytes in 50,896 blocks are definitely lost in loss record 68 of 68
==19276== at 0x4C2F216: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19276== by 0x4C2F331: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19276== by 0x62B5CF2: av_malloc (in /usr/lib64/libavutil.so.55.58.100)
==19276== by 0x4F7BFB9: av_bitstream_filter_filter (in /usr/lib64/libavcodec.so.57.89.100)
==19276== by 0x109293: main (in /root/a.out)
==19276==
==19276== LEAK SUMMARY:
==19276== definitely lost: 2,635,145,556 bytes in 50,896 blocks
==19276== indirectly lost: 0 bytes in 0 blocks
==19276== possibly lost: 8,303,769 bytes in 81 blocks
==19276== still reachable: 301,695 bytes in 88 blocks
==19276== suppressed: 0 bytes in 0 blocks
==19276== Reachable blocks (those to which a pointer was found) are not shown.
==19276== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==19276==
==19276== For counts of detected and suppressed errors, rerun with: -v
==19276== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)