#!/bin/bash

target_folder="/app/video/lihan"

find "$target_folder" -type f -name "*.mp4" | while read -r file; do
    echo "Processing file: $file"
    filename=$(basename "$file")
    directory=$(dirname "$file")
    filename="${filename%.*}"
    echo "filename is :$filename"
    new_filename="/app/video/lihan/${filename}_tmp.mp4"
    ffmpeg -i "/app/video/lihan/${filename}.mp4" -c:v copy -c:a copy "$new_filename"
    wait
    rm "/app/video/lihan/${filename}.mp4"
    mv "$new_filename" "/app/video/lihan/${filename}.mp4"
    echo "File replaced: $file"
done

echo "Conversion complete!"
