Bot De Telegram Para Cambiar Caras En Videos 2021 File

La proliferación de bots en Telegram y otras plataformas contribuyó a una atmósfera de escepticismo hacia lo audiovisual. Esto tiene efectos colaterales: mientras algunos ciudadanos desarrollan pensamiento crítico, otros caen en cinismo paralizante —desestimando evidencia real como “fake”— con consecuencias para la rendición de cuentas democrática. Para medios y organismos, la respuesta implicó verificar rigorosamente fuentes y desarrollar estándares técnicos para autenticidad.

Una respuesta efectiva exige políticas multicapas:

swapper = None face_analyser = None

def load_models(): global swapper, face_analyser import insightface face_analyser = insightface.app.FaceAnalysis() face_analyser.prepare(ctx_id=0) swapper = insightface.model_zoo.get_model('inswapper_128.onnx') swapper.prepare(ctx_id=0)

def swap_faces_in_video(input_path, target_face_path, output_path): # 1. Extract target face embedding target_img = cv2.imread(target_face_path) target_faces = face_analyser.get(target_img) if len(target_faces) == 0: raise Exception("No face found in target image") target_embedding = target_faces[0] bot de telegram para cambiar caras en videos 2021

# 2. Process video frame by frame
cap = cv2.VideoCapture(input_path)
fps = int(cap.get(cv2.CAP_PROP_FPS))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
while True:
    ret, frame = cap.read()
    if not ret:
        break
    faces = face_analyser.get(frame)
    for face in faces:
        frame = swapper.get(frame, face, target_embedding, paste_back=True)
    out.write(frame)
cap.release()
out.release()

def handle_video(update, context): # Download user's video (max 20MB for Telegram bot in 2021) video_file = update.message.video.get_file() input_video = f"/tmp/uuid.uuid4().mp4" video_file.download(input_video)

# User must send a photo first as the target face
if 'target_face' not in context.user_data:
    update.message.reply_text("Please send a photo of the face you want to swap IN first.")
    context.user_data['awaiting_target_face'] = True
    return
target_face = context.user_data['target_face']
output_video = f"/tmp/uuid.uuid4()_swapped.mp4"
# Send "processing" message
msg = update.message.reply_text("🔄 Swapping faces... this may take 1-2 minutes.")
try:
    swap_faces_in_video(input_video, target_face, output_video)
    # Compress with FFmpeg for Telegram (max 50MB)
    compressed = f"/tmp/uuid.uuid4()_compressed.mp4"
    subprocess.run(f"ffmpeg -i output_video -c:v libx264 -crf 28 -preset fast compressed", shell=True)
with open(compressed, 'rb') as f:
        context.bot.send_video(chat_id=update.effective_chat.id, video=f, caption="✅ Face swap complete!")
except Exception as e:
    update.message.reply_text(f"Error: str(e)")
finally:
    # Cleanup
    for f in [input_video, output_video, compressed]:
        if os.path.exists(f): os.remove(f)

def handle_photo(update, context): if context.user_data.get('awaiting_target_face'): photo_file = update.message.photo[-1].get_file() target_path = f"/tmp/uuid.uuid4().jpg" photo_file.download(target_path) context.user_data['target_face'] = target_path context.user_data['awaiting_target_face'] = False update.message.reply_text("Target face saved! Now send a video to swap.") else: update.message.reply_text("Use /swap command first.") La proliferación de bots en Telegram y otras

def main(): load_models() updater = Updater("YOUR_BOT_TOKEN", use_context=True) dp = updater.dispatcher dp.add_handler(CommandHandler("start", lambda u,c: u.message.reply_text("Send me a video and a face photo to swap!"))) dp.add_handler(MessageHandler(filters.VIDEO, handle_video)) dp.add_handler(MessageHandler(filters.PHOTO, handle_photo)) updater.start_polling() updater.idle()

if name == "main": main()

InsightFace in 2021 provides the SwapModel – a practical choice for bots.

| Bot de Telegram | Especialidad | Límite de video | | :--- | :--- | :--- | | @Deepfake_bot | Alto realismo, pero lento | 10 segundos | | @Reface_tele_bot | Famoso por hacer bailar a fotos estáticas | 5 segundos | | @Swap_video_bot | Permitía intercambiar 2 caras dentro del mismo video | 15 segundos | def handle_photo(update, context): if context