Recherche avancée

Médias (91)

Autres articles (54)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

Sur d’autres sites (9586)

  • Integrating FFMPEG using cmake : undefined reference when linking libraries

    21 novembre 2018, par Hamed Momeni

    I’ve been trying to cross-compile ffmpeg for different Android cpu archs for couple of days now and I have finally succeeded in the task. But now that I need to integrate these pre-built .so files in my project I’m facing errors which have me baffled.

    This is the CMakeLists.txt which I’m using :

    cmake_minimum_required(VERSION 3.4.1)

    # convert SDK path to forward slashes on Windows
    file(TO_CMAKE_PATH ${PATH_TO_SUPERPOWERED} PATH_TO_SUPERPOWERED)

    set(CMAKE_VERBOSE_MAKEFILE on)

    include_directories(src/main/cpp)
    include_directories(${PATH_TO_SUPERPOWERED})
    include_directories(${PATH_TO_FFMPEG}/${ANDROID_ABI}/include)

    add_library(
           avutil
           SHARED
           ${PATH_TO_FFMPEG}/${ANDROID_ABI}/lib/libavutil.so
    )
    set_target_properties(avutil PROPERTIES LINKER_LANGUAGE CXX)

    add_library(
           avformat
           SHARED
           ${PATH_TO_FFMPEG}/${ANDROID_ABI}/lib/libavformat.so
    )
    set_target_properties(avformat PROPERTIES LINKER_LANGUAGE CXX)

    add_library(
           avcodec
           SHARED
           ${PATH_TO_FFMPEG}/${ANDROID_ABI}/lib/libavcodec.so
    )
    set_target_properties(avcodec PROPERTIES LINKER_LANGUAGE CXX)



    add_library(
           Canto
           SHARED
           src/main/cpp/Dubsmash.cpp
           src/main/cpp/Karaoke.cpp
           src/main/cpp/Singing.cpp
           src/main/cpp/EditDubsmash.cpp
           ${PATH_TO_SUPERPOWERED}/AndroidIO/SuperpoweredAndroidAudioIO.cpp
    )

    # link the native library against the following libraries
    target_link_libraries(
           Canto
           avutil
           avformat
           avcodec
           ${PATH_TO_SUPERPOWERED}/libSuperpoweredAndroid${ANDROID_ABI}.a
           OpenSLES
           log
           android
    )

    And this is the source of the file I’m getting errors on :

    #include
    #include <android></android>log.h>
    #include <string>
    // unrelated includes
    #include <libavformat></libavformat>avformat.h>
    #include <libavutil></libavutil>dict.h>

    #define log_write __android_log_write
    #define log_print __android_log_print

    // unrelated code parts

    int print_file_data(const char *filePath) {
       AVFormatContext *fmt_ctx = NULL;
       AVDictionaryEntry *tag = NULL;
       int ret;

       if ((ret = avformat_open_input(&amp;fmt_ctx, filePath, NULL, NULL)))
           return ret;

       while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
           log_print(ANDROID_LOG_DEBUG, "%s=%s\n", tag->key, tag->value);

       avformat_close_input(&amp;fmt_ctx);
       return 0;
    }
    </string>

    And finally the errors themselves :

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:externalNativeBuildDebug'.
    > Build command failed.
     Error while executing process /home/hamed/dev/android-tools/android-sdk-linux/cmake/3.6.4111459/bin/cmake with arguments {--build /home/hamed/dev/projects/canto/Canto/app/.externalNativeBuild/cmake/debug/x86 --target Canto}
     [1/1] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/x86/libCanto.so
     FAILED: : &amp;&amp; /home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=i686-none-linux-android16 --gcc-toolchain=/home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=/home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/sysroot -fPIC -isystem /home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/sysroot/usr/include/i686-linux-android -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -fsigned-char -I/home/hamed/dev/projects/canto/Canto/app/../Superpowered -I/home/hamed/dev/projects/canto/Canto/app/../ffmpeg -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot /home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/platforms/android-16/arch-x86 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -L/home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libCanto.so -o ../../../../build/intermediates/cmake/debug/obj/x86/libCanto.so CMakeFiles/Canto.dir/src/main/cpp/Dubsmash.cpp.o CMakeFiles/Canto.dir/src/main/cpp/Karaoke.cpp.o CMakeFiles/Canto.dir/src/main/cpp/Singing.cpp.o CMakeFiles/Canto.dir/src/main/cpp/EditDubsmash.cpp.o CMakeFiles/Canto.dir/home/hamed/dev/projects/canto/Canto/Superpowered/AndroidIO/SuperpoweredAndroidAudioIO.cpp.o  ../../../../build/intermediates/cmake/debug/obj/x86/libavutil.so ../../../../build/intermediates/cmake/debug/obj/x86/libavformat.so ../../../../../Superpowered/libSuperpoweredAndroidx86.a -lOpenSLES -llog -landroid -latomic -lm "/home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86/libc++_static.a" "/home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86/libc++abi.a" "/home/hamed/dev/android-tools/android-sdk-linux/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86/libandroid_support.a" &amp;&amp; :
     /home/hamed/dev/projects/canto/Canto/app/src/main/cpp/Dubsmash.cpp:295: error: undefined reference to 'avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)'
     /home/hamed/dev/projects/canto/Canto/app/src/main/cpp/Dubsmash.cpp:298: error: undefined reference to 'av_dict_get(AVDictionary const*, char const*, AVDictionaryEntry const*, int)'
     /home/hamed/dev/projects/canto/Canto/app/src/main/cpp/Dubsmash.cpp:301: error: undefined reference to 'avformat_close_input(AVFormatContext**)'
     clang++: error: linker command failed with exit code 1 (use -v to see invocation)
     ninja: build stopped: subcommand failed.

    Obviously the linker can not find the needed libraries, but why ?!

    UPDATE
    This is the result of running nm on libavutil.so :

    0000000000000510 t atexit
    0000000000000500 t __atexit_handler_wrapper
    0000000000002008 A __bss_start
                    U __cxa_atexit
                    U __cxa_finalize
    0000000000002000 d __dso_handle
    0000000000001dd8 d _DYNAMIC
    0000000000002008 A _edata
    00000000000004e0 t __emutls_unregister_key
    0000000000002008 A _end
    00000000000005e8 r __FRAME_END__
    0000000000001fd8 d _GLOBAL_OFFSET_TABLE_
    0000000000000258 r ndk_build_number
    0000000000000218 r ndk_version
    0000000000000200 r note_android_ident
    0000000000000214 r note_data
    0000000000000298 r note_end
    000000000000020c r note_name
    00000000000004d0 t __on_dlclose
    00000000000004f0 t __on_dlclose_late

    and on libavformat :

    0000000000000520 t atexit
    0000000000000510 t __atexit_handler_wrapper
    0000000000002008 A __bss_start
                    U __cxa_atexit
                    U __cxa_finalize
    0000000000002000 d __dso_handle
    0000000000001dd8 d _DYNAMIC
    0000000000002008 A _edata
    00000000000004f0 t __emutls_unregister_key
    0000000000002008 A _end
    00000000000005f8 r __FRAME_END__
    0000000000001fd8 d _GLOBAL_OFFSET_TABLE_
    0000000000000258 r ndk_build_number
    0000000000000218 r ndk_version
    0000000000000200 r note_android_ident
    0000000000000214 r note_data
    0000000000000298 r note_end
    000000000000020c r note_name
    00000000000004e0 t __on_dlclose
    0000000000000500 t __on_dlclose_late

    UPDATE 2
    I applied @szatmary suggestion and finally managed to to build the apk file but upon reaching the System.loadLibrary call an exception occurs indicating that the linker can not find libavutil.so.56. I tried changing the address of the library in the cmake file to actually contain the version numbered lib file to no avail :

    java.lang.UnsatisfiedLinkError: dlopen failed: library "libavutil.so.56" not found
           at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
           at java.lang.System.loadLibrary(System.java:1657)
           at com.hmomeni.canto.activities.EditActivity.<init>(EditActivity.kt:26)
           at java.lang.Class.newInstance(Native Method)
           at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
           at android.app.ActivityThread.-wrap11(Unknown Source:0)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
           at android.os.Handler.dispatchMessage(Handler.java:106)
           at android.os.Looper.loop(Looper.java:164)
           at android.app.ActivityThread.main(ActivityThread.java:6494)
           at java.lang.reflect.Method.invoke(Native Method)
           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    </init>
  • How to use ffmpeg build libraries in Android studio ?

    16 octobre 2018, par Dilchun Dev

    I have build ffmpeg libs for Android using tutorial provided by
    https://medium.com/@karthikcodes1999/cross-compiling-ffmpeg-4-0-for-android-b988326f16f2

    But I don’t know how to use the libraries in my Android project.

    Everything done according to above mentioned example getting error when trying to build project/gradle
    enter image description here

    enter image description here

    Cmakelists.txt file : enter image description here

    UPDATE :
    new error message while building saying :

    Build command failed.
    Error while executing process /root/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/home/mrx/tester/app -B/home/mrx/tester/app/.externalNativeBuild/cmake/debug/armeabi -DANDROID_ABI=armeabi -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/mrx/tester/app/build/intermediates/cmake/debug/obj/armeabi -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=/root/Android/Sdk/ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=/root/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/root/Android/Sdk/cmake/3.6.4111459/bin/ninja -GAndroid Gradle - Ninja}
    CMake Error at CMakeLists.txt:56 (set_target_properties):
     set_target_properties Can not find target to add properties to: swscale-5


    -- Configuring incomplete, errors occurred!
    See also "/home/mrx/tester/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeOutput.log".

    Update :
    everything working fine but only error i am getting is

    org.gradle.internal.UncheckedException: Build command failed.

    Error while executing process /root/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments —build /home/mrx/tester/app/.externalNativeBuild/cmake/debug/armeabi —target native-lib
    ninja : error : ’../../../../src/main/jniLibs/armeabi/libavcodec-58.so’, needed by ’../../../../build/intermediates/cmake/debug/obj/armeabi/libnative-lib.so’, missing and no known rule to make it

    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:63)
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:788)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:755)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
    at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)

    Caused by : Build command failed.
    Error while executing process /root/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments —build /home/mrx/tester/app/.externalNativeBuild/cmake/debug/armeabi —target native-lib
    ninja : error : ’../../../../src/main/jniLibs/armeabi/libavcodec-58.so’, needed by ’../../../../build/intermediates/cmake/debug/obj/armeabi/libnative-lib.so’, missing and no known rule to make it

    at com.android.build.gradle.tasks.ExternalNativeBuildTaskUtils.executeBuildProcessAndLogError(ExternalNativeBuildTaskUtils.java:245)
    at com.android.build.gradle.tasks.ExternalNativeBuildTask.executeProcessBatch(ExternalNativeBuildTask.java:307)
    at com.android.build.gradle.tasks.ExternalNativeBuildTask.build(ExternalNativeBuildTask.java:185)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    ... 45 more
  • Play video using mse (media source extension) in google chrome

    23 août 2019, par liyuqihxc

    I’m working on a project that convert rtsp stream (ffmpeg) and play it on the web page (signalr + mse).

    So far it works pretty much as I expected on the latest version of edge and firefox, but not chrome.

    here’s the code

    public class WebmMediaStreamContext
    {
       private Process _ffProcess;
       private readonly string _cmd;
       private byte[] _initSegment;
       private Task _readMediaStreamTask;
       private CancellationTokenSource _cancellationTokenSource;

       private const string _CmdTemplate = "-i {0} -c:v libvpx -tile-columns 4 -frame-parallel 1 -keyint_min 90 -g 90 -f webm -dash 1 pipe:";

       public static readonly byte[] ClusterStart = { 0x1F, 0x43, 0xB6, 0x75, 0x01, 0x00, 0x00, 0x00 };

       public event EventHandler<clusterreadyeventargs> ClusterReadyEvent;

       public WebmMediaStreamContext(string rtspFeed)
       {
           _cmd = string.Format(_CmdTemplate, rtspFeed);
       }

       public async Task StartConverting()
       {
           if (_ffProcess != null)
               throw new InvalidOperationException();

           _ffProcess = new Process();
           _ffProcess.StartInfo = new ProcessStartInfo
           {
               FileName = "ffmpeg/ffmpeg.exe",
               Arguments = _cmd,
               UseShellExecute = false,
               CreateNoWindow = true,
               RedirectStandardOutput = true
           };
           _ffProcess.Start();

           _initSegment = await ParseInitSegmentAndStartReadMediaStream();
       }

       public byte[] GetInitSegment()
       {
           return _initSegment;
       }

       // Find the first cluster, and everything before it is the InitSegment
       private async Task ParseInitSegmentAndStartReadMediaStream()
       {
           Memory<byte> buffer = new byte[10 * 1024];
           int length = 0;
           while (length != buffer.Length)
           {
               length += await _ffProcess.StandardOutput.BaseStream.ReadAsync(buffer.Slice(length));
               int cluster = buffer.Span.IndexOf(ClusterStart);
               if (cluster >= 0)
               {
                   _cancellationTokenSource = new CancellationTokenSource();
                   _readMediaStreamTask = new Task(() => ReadMediaStreamProc(buffer.Slice(cluster, length - cluster).ToArray(), _cancellationTokenSource.Token), _cancellationTokenSource.Token, TaskCreationOptions.LongRunning);
                   _readMediaStreamTask.Start();
                   return buffer.Slice(0, cluster).ToArray();
               }
           }

           throw new InvalidOperationException();
       }

       private void ReadMoreBytes(Span<byte> buffer)
       {
           int size = buffer.Length;
           while (size > 0)
           {
               int len = _ffProcess.StandardOutput.BaseStream.Read(buffer.Slice(buffer.Length - size));
               size -= len;
           }
       }

       // Parse every single cluster and fire ClusterReadyEvent
       private void ReadMediaStreamProc(byte[] bytesRead, CancellationToken cancel)
       {
           Span<byte> buffer = new byte[5 * 1024 * 1024];
           bytesRead.CopyTo(buffer);
           int bufferEmptyIndex = bytesRead.Length;

           do
           {
               if (bufferEmptyIndex &lt; ClusterStart.Length + 4)
               {
                   ReadMoreBytes(buffer.Slice(bufferEmptyIndex, 1024));
                   bufferEmptyIndex += 1024;
               }

               int clusterDataSize = BitConverter.ToInt32(
                   buffer.Slice(ClusterStart.Length, 4)
                   .ToArray()
                   .Reverse()
                   .ToArray()
               );
               int clusterSize = ClusterStart.Length + 4 + clusterDataSize;
               if (clusterSize > buffer.Length)
               {
                   byte[] newBuffer = new byte[clusterSize];
                   buffer.Slice(0, bufferEmptyIndex).CopyTo(newBuffer);
                   buffer = newBuffer;
               }

               if (bufferEmptyIndex &lt; clusterSize)
               {
                   ReadMoreBytes(buffer.Slice(bufferEmptyIndex, clusterSize - bufferEmptyIndex));
                   bufferEmptyIndex = clusterSize;
               }

               ClusterReadyEvent?.Invoke(this, new ClusterReadyEventArgs(buffer.Slice(0, bufferEmptyIndex).ToArray()));

               bufferEmptyIndex = 0;
           } while (!cancel.IsCancellationRequested);
       }
    }
    </byte></byte></byte></clusterreadyeventargs>

    I use ffmpeg to convert the rtsp stream to vp8 WEBM byte stream and parse it to "Init Segment" (ebml head、info、tracks...) and "Media Segment" (cluster), then send it to browser via signalR

    $(function () {

       var mediaSource = new MediaSource();
       var mimeCodec = 'video/webm; codecs="vp8"';

       var video = document.getElementById('video');

       mediaSource.addEventListener('sourceopen', callback, false);
       function callback(e) {
           var sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
           var queue = [];

           sourceBuffer.addEventListener('updateend', function () {
               if (queue.length === 0) {
                   return;
               }

               var base64 = queue[0];
               if (base64.length === 0) {
                   mediaSource.endOfStream();
                   queue.shift();
                   return;
               } else {
                   var buffer = new Uint8Array(atob(base64).split("").map(function (c) {
                       return c.charCodeAt(0);
                   }));
                   sourceBuffer.appendBuffer(buffer);
                   queue.shift();
               }
           }, false);

           var connection = new signalR.HubConnectionBuilder()
               .withUrl("/signalr-video")
               .configureLogging(signalR.LogLevel.Information)
               .build();
           connection.start().then(function () {
               connection.stream("InitVideoReceive")
                   .subscribe({
                       next: function(item) {
                           if (queue.length === 0 &amp;&amp; !!!sourceBuffer.updating) {
                               var buffer = new Uint8Array(atob(item).split("").map(function (c) {
                                   return c.charCodeAt(0);
                               }));
                               sourceBuffer.appendBuffer(buffer);
                               console.log(blockindex++ + " : " + buffer.byteLength);
                           } else {
                               queue.push(item);
                           }
                       },
                       complete: function () {
                           queue.push('');
                       },
                       error: function (err) {
                           console.error(err);
                       }
                   });
           });
       }
       video.src = window.URL.createObjectURL(mediaSource);
    })

    chrome just play the video for 3 5 seconds and then stop for buffering, even though there are plenty of cluster transfered and inserted into SourceBuffer.

    here’s the information in chrome ://media-internals/

    Player Properties :

    render_id: 217
    player_id: 1
    origin_url: http://localhost:52531/
    frame_url: http://localhost:52531/
    frame_title: Home Page
    url: blob:http://localhost:52531/dcb25d89-9830-40a5-ba88-33c13b5c03eb
    info: Selected FFmpegVideoDecoder for video decoding, config: codec: vp8 format: 1 profile: vp8 coded size: [1280,720] visible rect: [0,0,1280,720] natural size: [1280,720] has extra data? false encryption scheme: Unencrypted rotation: 0°
    pipeline_state: kSuspended
    found_video_stream: true
    video_codec_name: vp8
    video_dds: false
    video_decoder: FFmpegVideoDecoder
    duration: unknown
    height: 720
    width: 1280
    video_buffering_state: BUFFERING_HAVE_NOTHING
    for_suspended_start: false
    pipeline_buffering_state: BUFFERING_HAVE_NOTHING
    event: PAUSE

    Log

    Timestamp       Property            Value
    00:00:00 00     origin_url          http://localhost:52531/
    00:00:00 00     frame_url           http://localhost:52531/
    00:00:00 00     frame_title         Home Page
    00:00:00 00     url                 blob:http://localhost:52531/dcb25d89-9830-40a5-ba88-33c13b5c03eb
    00:00:00 00     info                ChunkDemuxer: buffering by DTS
    00:00:00 35     pipeline_state      kStarting
    00:00:15 213    found_video_stream  true
    00:00:15 213    video_codec_name    vp8
    00:00:15 216    video_dds           false
    00:00:15 216    video_decoder       FFmpegVideoDecoder
    00:00:15 216    info                Selected FFmpegVideoDecoder for video decoding, config: codec: vp8 format: 1 profile: vp8 coded size: [1280,720] visible rect: [0,0,1280,720] natural size: [1280,720] has extra data? false encryption scheme: Unencrypted rotation: 0°
    00:00:15 216    pipeline_state      kPlaying
    00:00:15 213    duration            unknown
    00:00:16 661    height              720
    00:00:16 661    width               1280
    00:00:16 665    video_buffering_state       BUFFERING_HAVE_ENOUGH
    00:00:16 665    for_suspended_start         false
    00:00:16 665    pipeline_buffering_state    BUFFERING_HAVE_ENOUGH
    00:00:16 667    pipeline_state      kSuspending
    00:00:16 670    pipeline_state      kSuspended
    00:00:52 759    info                Effective playback rate changed from 0 to 1
    00:00:52 759    event               PLAY
    00:00:52 759    pipeline_state      kResuming
    00:00:52 760    video_dds           false
    00:00:52 760    video_decoder       FFmpegVideoDecoder
    00:00:52 760    info                Selected FFmpegVideoDecoder for video decoding, config: codec: vp8 format: 1 profile: vp8 coded size: [1280,720] visible rect: [0,0,1280,720] natural size: [1280,720] has extra data? false encryption scheme: Unencrypted rotation: 0°
    00:00:52 760    pipeline_state      kPlaying
    00:00:52 793    height              720
    00:00:52 793    width               1280
    00:00:52 798    video_buffering_state       BUFFERING_HAVE_ENOUGH
    00:00:52 798    for_suspended_start         false
    00:00:52 798    pipeline_buffering_state    BUFFERING_HAVE_ENOUGH
    00:00:56 278    video_buffering_state       BUFFERING_HAVE_NOTHING
    00:00:56 295    for_suspended_start         false
    00:00:56 295    pipeline_buffering_state    BUFFERING_HAVE_NOTHING
    00:01:20 717    event               PAUSE
    00:01:33 538    event               PLAY
    00:01:35 94     event               PAUSE
    00:01:55 561    pipeline_state      kSuspending
    00:01:55 563    pipeline_state      kSuspended

    Can someone tell me what’s wrong with my code, or dose chrome require some magic configuration to work ?

    Thanks 

    Please excuse my english :)