Recherche avancée

Médias (1)

Mot : - Tags -/wave

Autres articles (48)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

Sur d’autres sites (7652)

  • React Native Expo File System : open failed : ENOENT (No such file or directory)

    9 février 2023, par coloraday

    I'm getting this error in a bare React Native project :

    


    Possible Unhandled Promise Rejection (id: 123):
Error: /data/user/0/com.filsufius.VisionishAItest/files/image-new-♥d.jpg: open failed: ENOENT (No such file or directory)


    


    The same code was saving to File System with no problem yesterday, but today as you can see I am getting an ENOENT error, plus I am getting these funny heart shapes ♥d in the path. Any pointers as to what might be causing this, please ? I use npx expo run:android to builld app locally and expo start —dev-client to run on a physical Android device connected through USB.

    


    import { Image, View, Text, StyleSheet } from "react-native";&#xA;import * as FileSystem from "expo-file-system";&#xA;import RNFFmpeg from "react-native-ffmpeg";&#xA;import * as tf from "@tensorflow/tfjs";&#xA;import * as cocossd from "@tensorflow-models/coco-ssd";&#xA;import { decodeJpeg, bundleResourceIO } from "@tensorflow/tfjs-react-native";&#xA;&#xA;const Record = () => {&#xA;  const [frames, setFrames] = useState([]);&#xA;  const [currentFrame, setCurrentFrame] = useState(0);&#xA;  const [model, setModel] = useState(null);&#xA;  const [detections, setDetections] = useState([]);&#xA;&#xA;  useEffect(() => {&#xA;    const fileName = "image-new-%03d.jpg";&#xA;    const outputPath = FileSystem.documentDirectory &#x2B; fileName;&#xA;    RNFFmpeg.execute(&#xA;      "-y -i https://res.cloudinary.com/dannykeane/video/upload/sp_full_hd/q_80:qmax_90,ac_none/v1/dk-memoji-dark.m3u8 -vf fps=25 -f mjpeg " &#x2B;&#xA;        outputPath&#xA;    )&#xA;      .then((result) => {&#xA;        console.log("Extraction succeeded:", result);&#xA;        FileSystem.readDirectoryAsync(FileSystem.documentDirectory).then(&#xA;          (files) => {&#xA;            setFrames(&#xA;              files&#xA;                .filter((file) => file.endsWith(".jpg"))&#xA;                .sort((a, b) => {&#xA;                  const aNum = parseInt(a.split("-")[2].split(".")[0]);&#xA;                  const bNum = parseInt(b.split("-")[2].split(".")[0]);&#xA;                  return aNum - bNum;&#xA;                })&#xA;            );&#xA;          }&#xA;        );&#xA;      })&#xA;      .catch((error) => {&#xA;        console.error("Extraction failed:", error);&#xA;      });&#xA;  }, []);&#xA;&#xA;  useEffect(() => {&#xA;    tf.ready().then(() => cocossd.load().then((model) => setModel(model)));&#xA;  }, []);&#xA;  useEffect(() => {&#xA;    if (frames.length &amp;&amp; model) {&#xA;      const intervalId = setInterval(async () => {&#xA;        setCurrentFrame((currentFrame) =>&#xA;          currentFrame === frames.length - 1 ? 0 : currentFrame &#x2B; 1&#xA;        );&#xA;        const path = FileSystem.documentDirectory &#x2B; frames[currentFrame];&#xA;        const imageAssetPath = await FileSystem.readAsStringAsync(path, {&#xA;          encoding: FileSystem.EncodingType.Base64,&#xA;        });&#xA;        const imgBuffer = tf.util.encodeString(imageAssetPath, "base64").buffer;&#xA;        const imageData = new Uint8Array(imgBuffer);&#xA;        const imageTensor = decodeJpeg(imageData, 3);&#xA;        console.log("after decodeJpeg.");&#xA;        const detections = await model.detect(imageTensor);&#xA;        console.log(detections);&#xA;        setDetections(detections);&#xA;      }, 100);&#xA;      return () => clearInterval(intervalId);&#xA;    }&#xA;  }, [frames, model]);&#xA;&#xA;  &#xA;  return (&#xA;    <view style="{styles.container}">&#xA;      &#xA;      <view style="{styles.predictions}">&#xA;        {detections.map((p, i) => (&#xA;          <text key="{i}" style="{styles.text}">&#xA;            {p.class}: {(p.score * 100).toFixed(2)}%&#xA;          </text>&#xA;        ))}&#xA;      </view>&#xA;    </view>&#xA;  );&#xA;};&#xA;&#xA;const styles = StyleSheet.create({&#xA;  container: {&#xA;    flex: 1,&#xA;    alignItems: "center",&#xA;    justifyContent: "center",&#xA;  },&#xA;  image: {&#xA;    width: 300,&#xA;    height: 300,&#xA;    resizeMode: "contain",&#xA;  },&#xA;  predictions: {&#xA;    width: 300,&#xA;    height: 100,&#xA;    marginTop: 20,&#xA;  },&#xA;  text: {&#xA;    fontSize: 14,&#xA;    textAlign: "center",&#xA;  },&#xA;});&#xA;&#xA;export default Record;```&#xA;

    &#xA;

  • ffprobe different results video duration using pipe and reading a file from the file system

    5 février 2024, par alex

    I have a method to convert a video file, after processing the file I use pipe to pass bytes to a method to get meta information about the file using pipe. But in this case I get wrong duration of video file, 8.22, but if I save the file on file system and read it to get meta information I get result 15.85. Why is this happening ?

    &#xA;

    Video Convert method :

    &#xA;

    // ConvertVideoWithPath converts a video file specified by its path using FFmpeg.&#xA;// It returns the converted video data and any error that occurred during conversion.&#xA;func (f *FFmpeg) ConvertVideoWithPath(filePath string) (bytes []byte, err error) {&#xA;    if filePath == "" {&#xA;        return nil, ErrEmptyPath&#xA;    }&#xA;&#xA;    // Create a CmdRunner instance for executing FFmpeg.&#xA;    commander := &amp;CmdRunner{}&#xA;    commander.Command = "ffmpeg"&#xA;    args := []string{&#xA;        "-loglevel", "fatal",&#xA;        "-i", filePath,&#xA;        "-y",&#xA;        "-filter:v", "crop=trunc(iw/2)*2:trunc(ih/2)*2",&#xA;        "-c:v", f.videoCodec, // libx264&#xA;        "-c:a", f.audioCodec, // aac&#xA;        "-pix_fmt", "yuv420p",&#xA;        "-movflags", "frag_keyframe&#x2B;faststart",&#xA;        "-map_metadata", "-1",&#xA;        "-crf", "5",&#xA;        "-vsync", "2",&#xA;        "-bufsize", "15000000",&#xA;        "-maxrate", "5000000",&#xA;        "-preset", "medium",&#xA;        "-f", "mp4",&#xA;        "pipe:1",&#xA;    }&#xA;    commander.Args = args&#xA;&#xA;    // Initialize output pipe.&#xA;    reader := commander.InitStdOutPipe()&#xA;&#xA;    // Use WaitGroup to synchronize goroutines.&#xA;    wg := &amp;sync.WaitGroup{}&#xA;    wg.Add(1)&#xA;&#xA;    // Goroutine for reading data from the output pipe.&#xA;    go func() {&#xA;        defer reader.Close()&#xA;        defer wg.Done()&#xA;&#xA;        // Read data from the output pipe.&#xA;        data, _ := io.ReadAll(reader)&#xA;        // Safely update the &#x27;bytes&#x27; variable.&#xA;        f.mutex.Lock()&#xA;        bytes = data&#xA;        f.mutex.Unlock()&#xA;    }()&#xA;&#xA;    // Run the FFmpeg command with pipes and wait for completion.&#xA;    err = &lt;-commander.RunWithPipe()&#xA;    wg.Wait()&#xA;&#xA;    return&#xA;}&#xA;

    &#xA;

    // MetadataWithReader retrieves metadata from media data provided by an io.Reader using FFprobe.&#xA;// It returns the metadata and any error that occurred during metadata retrieval.&#xA;func (f *FFmpeg) MetadataWithReader(fileBytes io.Reader) (*Metadata, error) {&#xA;    if fileBytes == nil {&#xA;        return nil, ErrInvalidArgument&#xA;    }&#xA;&#xA;    // Create a CmdRunner instance for executing FFprobe.&#xA;    commander := &amp;CmdRunner{}&#xA;    commander.Command = "ffprobe"&#xA;    args := []string{&#xA;        "-loglevel", "fatal",&#xA;        "-i", "pipe:0",&#xA;        "-print_format", "json",&#xA;        "-show_format", "-show_streams",&#xA;        "-show_error",&#xA;    }&#xA;    commander.Args = args&#xA;&#xA;    // Get output data from FFprobe with pipes.&#xA;    err := commander.GetOutputWithPipe(fileBytes)&#xA;    if err != nil {&#xA;        return nil, err&#xA;    }&#xA;&#xA;    // Unmarshal JSON output into a Metadata struct.&#xA;    output := &amp;Metadata{}&#xA;    err = json.Unmarshal(commander.GetOutput(), output)&#xA;    if err != nil {&#xA;        return nil, err&#xA;    }&#xA;&#xA;    return output, err&#xA;}&#xA;

    &#xA;

    // MetadataWithPath extracts metadata of a file using FFprobe.&#xA;// It returns a Metadata struct or an error if the operation fails.&#xA;func (f *FFmpeg) MetadataWithPath(filePath string) (*Metadata, error) {&#xA;    if filePath == "" {&#xA;        return nil, ErrEmptyPath&#xA;    }&#xA;&#xA;    // Create a CmdRunner instance for executing FFprobe.&#xA;    commander := &amp;CmdRunner{}&#xA;    commander.Command = "ffprobe"&#xA;    args := []string{&#xA;        "-loglevel", "fatal",&#xA;        "-i", filePath,&#xA;        "-loglevel",&#xA;        "fatal",&#xA;        "-print_format", "json",&#xA;        "-show_format", "-show_streams", "-show_error",&#xA;    }&#xA;    commander.Args = args&#xA;    buffer := bytes.NewBuffer([]byte{})&#xA;    commander.StdOutWriter = buffer&#xA;&#xA;    err := commander.Run()&#xA;    if err != nil {&#xA;        return nil, err&#xA;    }&#xA;&#xA;    // Unmarshal JSON output into a Metadata struct.&#xA;    output := &amp;Metadata{}&#xA;    err = json.Unmarshal(buffer.Bytes(), output)&#xA;    if err != nil {&#xA;        return nil, err&#xA;    }&#xA;&#xA;    return output, nil&#xA;}&#xA;

    &#xA;

    The source code of the CmdRunner biblio library can be found here link , so as not to overload the question with a large piece of code.

    &#xA;

    Unit test code

    &#xA;

    t.Run("convert video", func(t *testing.T) {&#xA;        ffmpeg := NewFFmpeg("aac", "libx264", "24M", "12M")&#xA;&#xA;        filePath := "../../test/testdata/input_video_ts.mp4"&#xA;        firstMeta, err := ffmpeg.MetadataWithPath(filePath)&#xA;        assert.NoError(t, err)&#xA;        fmt.Print("first meta duration: ", firstMeta.Format.DurationSeconds) // 15.75&#xA;&#xA;        outFile := "../../test/testdata/output_mp4.mp4"&#xA;        newVideoOut, err := ffmpeg.ConvertVideoWithPath(filePath)&#xA;        assert.NoError(t, err)&#xA;        assert.NotEmpty(t, newVideoOut)&#xA;&#xA;        meta, err := ffmpeg.MetadataWithReader(bytes.NewBuffer(newVideoOut))&#xA;        assert.NoError(t, err)&#xA;        assert.NotEmpty(t, meta)&#xA;&#xA;        err = os.WriteFile(outFile, newVideoOut, 0644)&#xA;        assert.NoError(t, err)&#xA;        assert.FileExists(t, outFile)&#xA;&#xA;        fmt.Print("meta duration: ", meta.Format.DurationSeconds) // 8.22&#xA;&#xA;        secondMeta, err := ffmpeg.MetadataWithPath(outFile)&#xA;        assert.NoError(t, err)&#xA;        fmt.Print("second meta duration: ", secondMeta.Format.DurationSeconds) //15.85&#xA;&#xA;        err = os.Remove(outFile)&#xA;        assert.NoError(t, err)&#xA;    })&#xA;

    &#xA;

  • python [WinError 2] the System Cannot Find the File Specified

    15 août 2024, par user26831166

    Code cant create a certain file&#xA;The thing is code isn't mine a took it from a friend and my friend get it from another person&#xA;and this 2 person can run code without any problem&#xA;but i have.

    &#xA;

    import os&#xA;import random&#xA;import shutil&#xA;import subprocess&#xA;&#xA;# Путь к папке с видео&#xA;video_folder = r&#x27;D:\bots\ttvidads\VID\Videorez&#x27;&#xA;&#xA;# Путь к папке для сохранения результатов&#xA;output_folder = r&#x27;D:\bots\ttvidads\VID\ZAGOTOVKI\Videopod1&#x27;&#xA;&#xA;# Очищаем содержимое конечной папки перед сохранением&#xA;for file in os.listdir(output_folder):&#xA;    file_path = os.path.join(output_folder, file)&#xA;    try:&#xA;        if os.path.isfile(file_path):&#xA;            os.unlink(file_path)&#xA;    except Exception as e:&#xA;        print(f"Failed to delete {file_path}. Reason: {e}")&#xA;&#xA;# Получаем список видеофайлов&#xA;video_files = [os.path.join(video_folder, file) for file in os.listdir(video_folder) if file.endswith((&#x27;.mp4&#x27;, &#x27;.avi&#x27;))]&#xA;&#xA;# Выбираем случайное видео&#xA;random_video = random.choice(video_files)&#xA;&#xA;# Получаем длительность видео в секундах&#xA;video_duration_command = f&#x27;ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "{random_video}"&#x27;&#xA;video_duration_process = subprocess.Popen(video_duration_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)&#xA;video_duration_output, _ = video_duration_process.communicate()&#xA;video_duration = float(video_duration_output)&#xA;&#xA;# Выбираем случайное начальное время для вырезания&#xA;random_start = random.randrange(0, int(video_duration) - 19, 8)&#xA;&#xA;# Получаем ширину и высоту исходного видео&#xA;video_info_command = f&#x27;ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "{random_video}"&#x27;&#xA;video_info_process = subprocess.Popen(video_info_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)&#xA;video_info_output, _ = video_info_process.communicate()&#xA;video_width, video_height = map(int, video_info_output.strip().split(b&#x27;x&#x27;))&#xA;&#xA;# Вычисляем новые координаты x1 и x2 для обрезки&#xA;max_x1 = video_width - int(video_height * 9 / 16)&#xA;random_x1 = random.randint(0, max_x1)&#xA;random_x2 = random_x1 &#x2B; int(video_height * 9 / 16)&#xA;&#xA;# Формируем команду для FFmpeg для выборки случайного отрезка видео с соотношением 9:16&#xA;ffmpeg_command = f&#x27;ffmpeg -hwaccel cuda -ss {random_start} -i "{random_video}" -t 19 -vf "crop={random_x2-random_x1}:{video_height}:{random_x1}:0" -c:v h264_nvenc -preset default -an -c:a aac -b:a 128k "{output_folder}\\temp.mp4"&#x27;&#xA;&#xA;# Выполняем команду с помощью subprocess&#xA;subprocess.run(ffmpeg_command, shell=True)&#xA;&#xA;# Изменяем яркость, контрастность и размываем видео&#xA;brightness_factor = random.uniform(-0.18, -0.12)  # Случайный коэффициент яркости&#xA;contrast_factor = random.uniform(0.95, 1.05)  # Случайный коэффициент контрастности&#xA;blur_factor = random.uniform(4, 5)  # Случайный коэффициент размытия&#xA;&#xA;# Формируем команду для FFmpeg для изменения яркости, контрастности и размытия видео&#xA;ffmpeg_modify_command = f&#x27;ffmpeg -hwaccel cuda -i "{output_folder}\\temp.mp4" -vf "eq=brightness={brightness_factor}:contrast={contrast_factor},boxblur={blur_factor}:{blur_factor}" -c:v h264_nvenc -preset default -an -c:a aac -b:a 128k "{output_folder}\\temp_modify.mp4"&#x27;&#xA;&#xA;# Выполняем команду с помощью subprocess&#xA;subprocess.run(ffmpeg_modify_command, shell=True)&#xA;&#xA;# Растягиваем видео до нужного разрешения (1080x1920)&#xA;ffmpeg_stretch_command = f&#x27;ffmpeg -hwaccel cuda -i "{output_folder}\\temp_modify.mp4" -vf "scale=1080:1920" -c:v h264_nvenc -preset default -an -c:a aac -b:a 128k -r 30 "{output_folder}\\final_output.mp4"&#x27;&#xA;&#xA;# Выполняем команду с помощью subprocess&#xA;subprocess.run(ffmpeg_stretch_command, shell=True)&#xA;&#xA;# Удаляем временные файлы&#xA;os.remove(os.path.join(output_folder, &#x27;temp.mp4&#x27;))&#xA;os.remove(os.path.join(output_folder, &#x27;temp_modify.mp4&#x27;))&#xA;&#xA;print("Видеофайл успешно обработан и сохранен.")&#xA;

    &#xA;

    Error i got after run the code

    &#xA;

    = RESTART: D:\Bots\2vidpod.py&#xA;Traceback (most recent call last):&#xA;  File "D:\Bots\2vidpod.py", line 71, in <module>&#xA;    os.remove(os.path.join(output_folder, &#x27;temp.mp4&#x27;))&#xA;FileNotFoundError: [WinError 2] Не удается найти указанный файл: &#x27;D:\\bots\\ttvidads\\VID\\ZAGOTOVKI\\Videopod1\\temp.mp4&#x27;&#xA;</module>

    &#xA;

    so things i checked is&#xA;path is right&#xA;programs is installed FFMPEG and PYTHON all additional libraries downloaded&#xA;i pretty sure error caused by regular path and i wanna know if absolute path can do the thing

    &#xA;