Recherche avancée

Médias (91)

Autres articles (13)

  • 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 (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

Sur d’autres sites (3287)

  • The problem with the AudioDispatcher, the analysis in audioDispatcherFactory is not running, TarsosDSP

    4 février, par roman_gor_

    I'm making an application for sound analysis and spotlight control. The colors of the spotlight change to the beat of the music. I use the TarsosDSP library for this, additionally downloaded the FFmpeg-Kit library to convert audio to WAV format, PCM 16L to work with audioDispatcher.
The problem is that when audio is transmitted in the correct format, dispatcher starts and immediately ends. The boolean Process method is not executed, but the process Finished() method is executed. I found out that the stream starts, the file is not empty, it is converted to the correct format, BUT the getFrameLength() method, when interacting with the AudioStream to which I pass the filePath, returns the file path value -1, that is, in fact, it is not filled in. I've already searched through everything, and the github library code, and all the neural networks, I don't know how to solve this issue. The problem is with AudioDispatcher and AudioDispatcherFactory.from Pipe() ?

    


    private void playAndAnalyzeAudio(String filePath, Uri uri)
    {
        if (mediaPlayer != null)
            mediaPlayer.release();
        mediaPlayer = MediaPlayer.create(requireContext(), uri);

        new Thread(() -> {
            extractAudio(inputFilePath, outputFilePath);
            getActivity().runOnUiThread(() -> {
                mediaPlayer = MediaPlayer.create(requireContext(), uri);
                if (mediaPlayer != null) {
                    mediaPlayer.start(); // Start music after analyze
                    startSendingData(); // Start data sending
                }
            });
        }).start();
    }

    private void analyzeAudio(String filePath)
    {
        try {
            AudioDispatcher audioDispatcher = AudioDispatcherFactory.fromPipe(filePath, 44100, 1024, 0);
            MFCC mfcc = new MFCC(1024, 44100, 13, 50, 20, 10000);
            audioDispatcher.addAudioProcessor(mfcc);
            Log.d("AUDIO_ANALYSIS", "Начинаем анализ аудиофайла..." + audioDispatcher);
            audioDispatcher.addAudioProcessor(new AudioProcessor() {
                @Override
                public boolean process(AudioEvent audioEvent) {
                    Log.d("AUDIO_ANALYSIS", "Обрабатываем аудио...");

                    float[] amplitudes = audioEvent.getFloatBuffer();
                    Log.d("AUDIO_ANALYSIS", "Размер буфера: " + amplitudes.length);

                    float[] mfccs = mfcc.getMFCC();
                    if (mfccs == null) {
                        Log.e("AUDIO_ANALYSIS", "MFCC не сгенерировался!");
                        return true;
                    }

                    float currentBass = mfccs[0] + mfccs[1];
                    float totalEnergy = 0;
                    for (float amp : amplitudes) {
                        totalEnergy += Math.abs(amp);
                    }

                    Log.d("AUDIO_ANALYSIS", "Bass Energy: " + currentBass + ", Total Energy: " + totalEnergy);

                    if (currentBass > BASS_THRESHOLD || totalEnergy > ENERGY_THRESHOLD) {
                        changeColor();
                        Log.d("SONG", "Color wac changed on a : " + currentColor);
                        brightness = MAX_BRIGHTNESS;
                    } else {
                        brightness *= 0.9f;
                    }

                    return true;
                }

                @Override
                public void processingFinished() {
                    getActivity().runOnUiThread(() -> Toast.makeText(requireContext(), "Анализ завершён", Toast.LENGTH_SHORT).show());
                }
            });
            File file = new File(filePath);
            if (!file.exists() || file.length() == 0) {
                Log.e("AUDIO_ANALYSIS", "Error: file is empty! " + filePath);
                return;
            } else {
                Log.d("AUDIO_ANALYSIS", "File is, size: " + file.length() + " byte.");
            }
            Log.d("AUDIO_ANALYSIS", "Start of analyzing: " + filePath);
            File ffmpegFile = new File(getContext().getCacheDir(), "ffmpeg");
            if (!ffmpegFile.setExecutable(true)) {
                Log.e("AUDIO_ANALYSIS", "You don't have any roots for ffmpeg!");
            }
            else
                Log.e("AUDIO_ANALYSIS", "You have roots for ffmpeg!");

            new Thread(() -> {
                Log.d("AUDIO_ANALYSIS", "Start dispatcher...");
                audioDispatcher.run();
                Log.d("AUDIO_ANALYSIS", "Dispatcher end.");
            }).start();
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(requireContext(), "Error of analyzing", Toast.LENGTH_SHORT).show();
        }
    }
public void extractAudio(String inputFilePath, String outputFilePath) {
        File outputFile = new File(outputFilePath);
        if (outputFile.exists()) {
            outputFile.delete();  // Удаляем существующий файл
        }
        // Строим команду для извлечения аудио
        String command = "-i " + inputFilePath + " -vn -acodec pcm_s16le -ar 44100 -ac 2 " + outputFilePath;

        // Используем FFmpegKit для выполнения команды
        FFmpegKit.executeAsync(command, session -> {
            if (session.getReturnCode().isSuccess()) {
                Log.d("AUDIO_EXTRACT", "Аудио извлечено успешно: " + outputFilePath);
                analyzeAudio(outputFilePath);  // Продолжаем анализировать аудио
            } else {
                Log.e("AUDIO_EXTRACT", "Ошибка извлечения аудио: " + session.getFailStackTrace());
            }
        });
    }


    


    Sorry about the number of lines, i tried to describe the problem very detailed.
I tried to change AudioDispatcherFactory.fromPipe() on a AudioDispatcherFactory.fromFile(), but this method don't available in Android, only in Java, how i see the error "Javax.sound..., unexpected error, method don't available"
I tried to change String command in executeAudio() method, to change arguments of fromPipe() method, but in did not to bring success.
I want that my audio file will be correct analyze with audiodispatcher and then, that data from analyze will be transfered to arduino. Now in Logs I see "Color : null, value : 0.0.

    


  • Problem addig a thumbnail image to MP4 using FFMPEG CLI [closed]

    9 décembre 2023, par Albert67

    I have tried to add an image to a mp4 file generated from a video stream,

    


    It works with the following command :

    


    ffmpeg -i input_stream -i image.jpg -map 0:0 -map 0:1 -map 1 -c copy -disposition:v:1 attached_pic test.mp4

    


    but if I try the following :

    


    ffmpeg -i input_stream -i image.jpg -map 0 -map 1 -c copy -disposition:v:1 attached_pic test.mp4

    


    I get the following error :

    


    [mp4 @ 0x557be8b37f80] Could not find tag for codec timed_id3 in stream #2, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?) : Invalid argument
Error initializing output stream 0:6 —

    


    I was thinking that repalcing "-map 0:0 -map 0:1" that means get the first (video) and second (audio) of the first input stream , with "-map 0" (get all stream) should not make any difference.

    


    Any idea why ?
Regards
Albert

    


  • Problem decoding h264 over RTP TCP stream

    4 mai 2022, par Kamil.S

    I'm trying to receive RTP stream encoding h264 over TCP from my intercom Hikvision DS-KH8350-WTE1. By reverse engineering I was able to replicate how Hikvision original software Hik-Connect on iPhone and iVMS-4200 on MacOS connects and negotaties streaming. Now I'm getting the very same stream as original apps - verified through Wireshark. Now I need to "make sense" of the stream. I know it's RTP because I inspected how iVMS-4200 uses it using /usr/bin/sample on MacOS. Which yields :

    


      ! :               2 CStreamConvert::InputData(void*, int)  (in libOpenNetStream.dylib) + 52  [0x11ff7c7a6]
+     ! :                 2 SYSTRANS_InputData  (in libSystemTransform.dylib) + 153  [0x114f917f2]
+     ! :                   1 CRTPDemux::ProcessH264(unsigned char*, unsigned int, unsigned int, unsigned int)  (in libSystemTransform.dylib) + 302  [0x114fa2c04]
+     ! :                   | 1 CRTPDemux::AddAVCStartCode()  (in libSystemTransform.dylib) + 47  [0x114fa40f1]
+     ! :                   1 CRTPDemux::ProcessH264(unsigned char*, unsigned int, unsigned int, unsigned int)  (in libSystemTransform.dylib) + 476  [0x114fa2cb2]
+     ! :                     1 CRTPDemux::ProcessVideoFrame(unsigned char*, unsigned int, unsigned int)  (in libSystemTransform.dylib) + 1339  [0x114fa29b3]
+     ! :                       1 CMPEG2PSPack::InputData(unsigned char*, unsigned int, FRAME_INFO*)  (in libSystemTransform.dylib) + 228  [0x114f961d6]
+     ! :                         1 CMPEG2PSPack::PackH264Frame(unsigned char*, unsigned int, FRAME_INFO*)  (in libSystemTransform.dylib) + 238  [0x114f972fe]
+     ! :                           1 CMPEG2PSPack::FindAVCStartCode(unsigned char*, unsigned int)  (in libSystemTransform.dylib) + 23  [0x114f97561]`


    


    I can catch that with lldb and see the arriving packet data making sense as the format I'm describing.

    


    The packet signatures look following :

    


    


    0x24 0x02 0x05 0x85 0x80 0x60 0x01 0x57 0x00 0x00 0x00 0x02 0x00 0x00 0x27 0xde
0x0d 0x80 0x60 0x37 0x94 0x71 0xe3 0x97 0x10 0x77 0x20 0x2c 0x51 | 0x7c
0x85 0xb8 0x00 00 00 00 01 65 0xb8 0x0 0x0 0xa 0x35 ...

    


    0x24 0x02 0x05 0x85 0x80 0x60 0x01 0x58 0x00 0x00 0x00 0x02 0x00 0x00 0x27 0xde
0xd 0x80 0x60 0x37 0x95 0x71 0xe3 0x97 0x10 0x77 0x20 0x2c 0x51 | 0x7c 0x05 0x15 0xac ...

    


    0x24 0x02 0x5 0x85 0x80 0x60 0x01 0x59 0x00 0x0 0x00 0x02 0x00 00x0 0x27 0xde
0xd 0x80 0x60 0x37 0x96 0x71 0xe3 0x97 0x10 0x77 0x20 0x2c 0x51 | 0x7c 0x05 0x5d 0x00 ...

    


    


    By the means of reverse engineering the original software I was able to figure out that 0x7c85 indicates a key frame. 0x7c85 bytes in the genuine software processing do get replaced by h264 00 00 00 01 65 Key frame NALU . That's h264 appendix-B format.
The 0x7c05 packets always follow and are the remaining payload of the key frame. No NALU are added during their handling (the 0x7c05 is stripped away and rest of the bytes is copied). None of the bytes preceding 0x7cXX make it to a mp4 recording (that makes sense as it's the RTP protocol , albeit I'm not sure if it's entirely RTP standard or there's something custom from Hikvision).

    


    If you pay close attention in the Header there are 2 separate bytes indicating order which always match, so I'm sure no packet loss is occurring.

    


    I also observed nonkey frames arriving as 0x7c81 and converted to 00 00 00 01 61 NALU but I want to focus solely on the single key frame for now. Mostly because if I record a movie with the original software it will always begin with 00 00 00 01 65 Key frame (that obviously makes sense).

    


    To get a working mp4 I decided to copy paste a mp4 header of a genuine iVMS-4200 recording (in this sense that's every byte preceding 1st frame NALU 00 00 00 01 65 in the mp4 file). I know that the resolution will match the actual camera footage. With the strategy of waiting for a keyframe , replacing 0x7c85 with 00 00 00 01 65 NALU and appending the remaining bytes, or only appending bytes in the 0x7c05 case I do seem to get something that eventually could work.
When I attempt to ffplay the custom crafted mp4 result I do get something (with a little stretch of imagination that's actually the camera fisheye image forming), but clearly there is a problem.

    


    enter image description here

    


    It seems around 3-4th 0x7c05 packet (as the failing packet differs on every run), when I copy bytes eventually the h264 stream is incorrect. Just by eye-inspecting the bytes I don't see anything unusual.

    


    This is the failing packet around offset 750 decimal, (I know it's around this place because I keep stripping bytes away to see if there's still same amount frame arriving before it breaks).
enter image description here
More over I did dump those bytes from original software using lldb taking out my own python implementation out of equation. And I run into very same problem with the original packets.

    


    The mp4 header I use should work (since it does for original recordings even if I manipulate number of frames and leave just the first keyframe).
Correct me if I'm wrong but the phase of converting this to MPEG2-PS (which iVMS-4200 does and I don't) should be entirely optional and should not be related to my problem.

    


    Update :
I went the path of setting up recording and only then dumping the original iVMS-4200 packets. I edited the recorded movie to only contain keyframe of interest and it works. I found differences but I cannot explain where they are there yet :
enter image description here
Somehow 00 00 01 E0  13 FA 88 00 02 FF FF is inserted in the genuine recording (that's 4th packet), but I have no idea how this byte string was generated and what is its purpose.
When I fixed the first difference the next one is :
enter image description here
The pattern is striking. But what00 00 01 E0  13 FA 88 00 02 FF FF actually is ? And why is it inserted after 18 03 25 10 & 2F F4 80 FC
    
The 00 00 01 E0 signature would suggest those are Packetized Elementary Stream (PES) headers