Recherche avancée

Médias (0)

Mot : - Tags -/publication

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (103)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (7215)

  • I am converting images to video using ffmpeg in koltin but i am getting error

    28 mars 2024, par Mohith_karthikeya

    i implement ffmpeg by using this gitbub by this reference :5
https://github.com/tanersener/mobile-ffmpeg in koltin
my code is :

    


    class BurstModeToVideo(&#xA;    private val context: Context,&#xA;    private val onVideoConverted: (File) -> Unit&#xA;) {&#xA;&#xA;    private val vibeDirectory = File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "vibes")&#xA;    private val outputDirectory = context.getExternalFilesDir(Environment.DIRECTORY_MOVIES)&#xA;&#xA;    fun convertBitmapToJpeg(vibes: List<bitmap>) {&#xA;        if (!vibeDirectory.exists()) {&#xA;            vibeDirectory.mkdirs()&#xA;        }&#xA;&#xA;        vibes.forEachIndexed { index, vibe ->&#xA;            val fileName = "$index.jpg"&#xA;            val file = File(vibeDirectory, fileName)&#xA;            FileOutputStream(file).use { fos ->&#xA;                vibe.compress(Bitmap.CompressFormat.JPEG, 100, fos)&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    private val callback = ExecuteCallback { _, returnCode ->&#xA;        if (returnCode == Config.RETURN_CODE_SUCCESS) {&#xA;            try {&#xA;                val tempFile = File("${outputDirectory?.absolutePath}/vibe.mp4")&#xA;                onVideoConverted(tempFile)&#xA;                Log.e(TAG, "FFmpeg output found $tempFile")&#xA;                Toast.makeText(context,"$tempFile",Toast.LENGTH_LONG).show()&#xA;                Log.e(TAG, "FFmpeg output found $")&#xA;            } catch (e: IOException) {&#xA;                Log.e(TAG, "Error handling FFmpeg output", e)&#xA;            }&#xA;        } else {&#xA;            Log.i(TAG, "Async command execution failed with returnCode=$returnCode.")&#xA;        }&#xA;    }&#xA;&#xA;    fun convertShotsToVideo() {&#xA;        if (!vibeDirectory.exists() || vibeDirectory.listFiles()?.isEmpty() == true) {&#xA;            Log.e(TAG, "No images to convert")&#xA;            return&#xA;        }&#xA;&#xA;        Log.d(TAG, "Images are stored in: ${vibeDirectory.absolutePath}")&#xA;&#xA;        val imageFiles = vibeDirectory.listFiles { file -> file.isFile &amp;&amp; file.extension.equals("jpg", ignoreCase = true) }&#xA;        if (imageFiles.isNullOrEmpty()) {&#xA;            Log.e(TAG, "No image files found in directory")&#xA;            return&#xA;        }&#xA;&#xA;        Log.d(TAG, "List of image files:")&#xA;        imageFiles.forEach { file ->&#xA;            Log.d(TAG, file.name)&#xA;        }&#xA;&#xA;        val cmd = "-i ${vibeDirectory.absolutePath}/%d.jpg -c:v mpeg4 -y ${outputDirectory?.absolutePath}/vibe.mp4"&#xA;&#xA;        FFmpevubeg.executeAsync(cmd, callback)&#xA;    }&#xA;&#xA;    companion object {&#xA;        private const val TAG = "BurstModeToVideo"&#xA;    }&#xA;}&#xA;</bitmap>

    &#xA;

    above function convert images from bimtap to jpeg files and then it converts to video by using ffmpeg. And i initialize this fun in mainactivity.kt and it goes here :

    &#xA;

    var vibe by remember {&#xA;        mutableStateOf(null)&#xA;    }&#xA;&#xA;    val burstModeToVideo = BurstModeToVideo(&#xA;        context,&#xA;        onVideoConverted = {&#xA;            vibe = it&#xA;        }&#xA;    )&#xA;coroutineScope.launch {&#xA;            withContext(Dispatchers.IO) {&#xA;                burstModeToVideo.convertBitmapToJpeg(vibesList)&#xA;                burstModeToVideo.convertShotsToVideo()&#xA;            }&#xA;        }&#xA;&#xA;VideoPlayer(vibe)&#xA;

    &#xA;

    now this vibe variable is used in videoPlayer function and it goes here :

    &#xA;

    @OptIn(UnstableApi::class)&#xA;@Composable&#xA;fun VideoPlayer(file: File) {&#xA;    val context = LocalContext.current&#xA;&#xA;    val exoPlayer = remember {&#xA;        ExoPlayer.Builder(context)&#xA;            .build()&#xA;            .apply {&#xA;                val defaultDataSourceFactory = DefaultDataSource.Factory(context)&#xA;                val dataSourceFactory: DataSource.Factory = DefaultDataSource.Factory(&#xA;                    context,&#xA;                    defaultDataSourceFactory&#xA;                )&#xA;                this.repeatMode = ExoPlayer.REPEAT_MODE_ALL&#xA;                this.playWhenReady =  true&#xA;                val source = file.let {&#xA;                    ProgressiveMediaSource.Factory(dataSourceFactory)&#xA;                        .createMediaSource(MediaItem.fromUri(Uri.fromFile(file)))&#xA;                }&#xA;                this.setMediaSource(source)&#xA;                this.prepare()&#xA;                this.play()&#xA;                this.volume = 0f&#xA;            }&#xA;    }&#xA;&#xA;    DisposableEffect(Unit) {&#xA;        onDispose {&#xA;            exoPlayer.release()&#xA;        }&#xA;    }&#xA;&#xA;    AndroidView(&#xA;        factory = { ctx ->&#xA;            PlayerView(ctx).apply {&#xA;                useController = false&#xA;                resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM&#xA;                player = exoPlayer&#xA;            }&#xA;        },&#xA;        modifier = Modifier.fillMaxSize()&#xA;    )&#xA;}&#xA;

    &#xA;

    the error is :

    &#xA;

     MediaCodec will operate in async mode&#xA;2024-03-28 20:08:53.065 18946-27920 OplusCCodec             com.example.flenzey                  D  initiateShutdown [475]: (0xb400007656569fc0) keepComponentAllocated=0&#xA;2024-03-28 20:08:53.067 18946-27920 BpBinder                com.example.flenzey                  I  onLastStrongRef automatically unlinking death recipients: android.media.IResourceManagerService&#xA;2024-03-28 20:08:53.069 18946-27926 hw-BpHwBinder           com.example.flenzey                  I  onLastStrongRef automatically unlinking death recipients&#xA;2024-03-28 20:08:53.071 18946-27926 OplusCCodec             com.example.flenzey                  D  ~OplusCCodec [144]: (0xb400007656569fc0)&#xA;2024-03-28 20:08:53.077 18946-27889 MediaCodecRenderer      com.example.flenzey                  W  Failed to initialize decoder: c2.android.mpeg4.decoder&#xA;                                                                                                      java.lang.IllegalArgumentException&#xA;                                                                                                          at android.media.MediaCodec.native_configure(Native Method)&#xA;                                                                                                          at android.media.MediaCodec.configure(MediaCodec.java:2176)&#xA;                                                                                                          at android.media.MediaCodec.configure(MediaCodec.java:2092)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.initialize(AsynchronousMediaCodecAdapter.java:174)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.access$100(AsynchronousMediaCodecAdapter.java:54)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(AsynchronousMediaCodecAdapter.java:119)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:117)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1195)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1103)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:551)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1560)&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:1152)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:994)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:814)&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:940)&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1102)&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541)&#xA;                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)&#xA;                                                                                                          at android.os.Looper.loopOnce(Looper.java:238)&#xA;                                                                                                          at android.os.Looper.loop(Looper.java:349)&#xA;                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)&#xA;2024-03-28 20:08:53.091 18946-27889 MediaCodecVideoRenderer com.example.flenzey                  E  Video codec error&#xA;                                                                                                      androidx.media3.exoplayer.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: c2.android.mpeg4.decoder, Format(1, null, null, video/mp4v-es, null, 22800180, null, [2448, 3264, 24.999998, ColorInfo(Unset color space, Unset color range, Unset color transfer, false, 8bit Luma, 8bit Chroma)], [-1, -1])&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1114)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:551)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1560)&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:1152)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:994)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:814)&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:940)&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1102)&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541)&#xA;                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)&#xA;                                                                                                          at android.os.Looper.loopOnce(Looper.java:238)&#xA;                                                                                                          at android.os.Looper.loop(Looper.java:349)&#xA;                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)&#xA;                                                                                                      Caused by: java.lang.IllegalArgumentException&#xA;                                                                                                          at android.media.MediaCodec.native_configure(Native Method)&#xA;                                                                                                          at android.media.MediaCodec.configure(MediaCodec.java:2176)&#xA;                                                                                                          at android.media.MediaCodec.configure(MediaCodec.java:2092)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.initialize(AsynchronousMediaCodecAdapter.java:174)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.access$100(AsynchronousMediaCodecAdapter.java:54)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(AsynchronousMediaCodecAdapter.java:119)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:117)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1195)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1103)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:551)&#xA0;&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1560)&#xA0;&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:1152)&#xA0;&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:994)&#xA0;&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:814)&#xA0;&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:940)&#xA0;&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1102)&#xA0;&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541)&#xA0;&#xA;                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)&#xA0;&#xA;                                                                                                          at android.os.Looper.loopOnce(Looper.java:238)&#xA0;&#xA;                                                                                                          at android.os.Looper.loop(Looper.java:349)&#xA0;&#xA;                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)&#xA0;&#xA;2024-03-28 20:08:53.092 18946-27889 MediaCodecInfo          com.example.flenzey                  D  NoSupport [sizeAndRate.support, 2448x3264@24.999998092651367] [c2.android.mpeg4.decoder, video/mp4v-es] [OP535DL1, CPH2381, OnePlus, 31]&#xA;2024-03-28 20:08:53.108 18946-27889 ExoPlayerImplInternal   com.example.flenzey                  E  Playback error&#xA;                                                                                                      androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/mp4v-es, null, 22800180, null, [2448, 3264, 24.999998, ColorInfo(Unset color space, Unset color range, Unset color transfer, false, 8bit Luma, 8bit Chroma)], [-1, -1]), format_supported=NO_EXCEEDS_CAPABILITIES&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:620)&#xA;                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)&#xA;                                                                                                          at android.os.Looper.loopOnce(Looper.java:238)&#xA;                                                                                                          at android.os.Looper.loop(Looper.java:349)&#xA;                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)&#xA;                                                                                                      Caused by: androidx.media3.exoplayer.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: c2.android.mpeg4.decoder, Format(1, null, null, video/mp4v-es, null, 22800180, null, [2448, 3264, 24.999998, ColorInfo(Unset color space, Unset color range, Unset color transfer, false, 8bit Luma, 8bit Chroma)], [-1, -1])&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1114)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:551)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1560)&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:1152)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:994)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:814)&#xA;                                                                                                          at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:940)&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1102)&#xA;                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541)&#xA;                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)&#xA0;&#xA;                                                                                                          at android.os.Looper.loopOnce(Looper.java:238)&#xA0;&#xA;                                                                                                          at android.os.Looper.loop(Looper.java:349)&#xA0;&#xA;                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)&#xA0;&#xA;                                                                                                      Caused by: java.lang.IllegalArgumentException&#xA;                                                                                                          at android.media.MediaCodec.native_configure(Native Method)&#xA;                                                                                                          at android.media.MediaCodec.configure(MediaCodec.java:2176)&#xA;                                                                                                          at android.media.MediaCodec.configure(MediaCodec.java:2092)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.initialize(AsynchronousMediaCodecAdapter.java:174)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.access$100(AsynchronousMediaCodecAdapter.java:54)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(AsynchronousMediaCodecAdapter.java:119)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:117)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1195)&#xA;                                                                                                          at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1103)&#xA;

    &#xA;

    can anybody solve it

    &#xA;

    i tried to implement but i don't how to solve it . please decode this and get me correct result.

    &#xA;

  • NumPy array of a video changes from the original after writing into the same video

    29 mars 2021, par Rashiq

    I have a video (test.mkv) that I have converted into a 4D NumPy array - (frame, height, width, color_channel). I have even managed to convert that array back into the same video (test_2.mkv) without altering anything. However, after reading this new, test_2.mkv, back into a new NumPy array, the array of the first video is different from the second video's array i.e. their hashes don't match and the numpy.array_equal() function returns false. I have tried using both python-ffmpeg and scikit-video but cannot get the arrays to match.

    &#xA;

    Python-ffmpeg attempt :

    &#xA;

    import ffmpeg&#xA;import numpy as np&#xA;import hashlib&#xA;&#xA;file_name = &#x27;test.mkv&#x27;&#xA;&#xA;# Get video dimensions and framerate&#xA;probe = ffmpeg.probe(file_name)&#xA;video_stream = next((stream for stream in probe[&#x27;streams&#x27;] if stream[&#x27;codec_type&#x27;] == &#x27;video&#x27;), None)&#xA;width = int(video_stream[&#x27;width&#x27;])&#xA;height = int(video_stream[&#x27;height&#x27;])&#xA;frame_rate = video_stream[&#x27;avg_frame_rate&#x27;]&#xA;&#xA;# Read video into buffer&#xA;out, error = (&#xA;    ffmpeg&#xA;        .input(file_name, threads=120)&#xA;        .output("pipe:", format=&#x27;rawvideo&#x27;, pix_fmt=&#x27;rgb24&#x27;)&#xA;        .run(capture_stdout=True)&#xA;)&#xA;&#xA;# Convert video buffer to array&#xA;video = (&#xA;    np&#xA;        .frombuffer(out, np.uint8)&#xA;        .reshape([-1, height, width, 3])&#xA;)&#xA;&#xA;# Convert array to buffer&#xA;video_buffer = (&#xA;    np.ndarray&#xA;        .flatten(video)&#xA;        .tobytes()&#xA;)&#xA;&#xA;# Write buffer back into a video&#xA;process = (&#xA;    ffmpeg&#xA;        .input(&#x27;pipe:&#x27;, format=&#x27;rawvideo&#x27;, s=&#x27;{}x{}&#x27;.format(width, height))&#xA;        .output("test_2.mkv", r=frame_rate)&#xA;        .overwrite_output()&#xA;        .run_async(pipe_stdin=True)&#xA;)&#xA;process.communicate(input=video_buffer)&#xA;&#xA;# Read the newly written video&#xA;out_2, error = (&#xA;    ffmpeg&#xA;        .input("test_2.mkv", threads=40)&#xA;        .output("pipe:", format=&#x27;rawvideo&#x27;, pix_fmt=&#x27;rgb24&#x27;)&#xA;        .run(capture_stdout=True)&#xA;)&#xA;&#xA;# Convert new video into array&#xA;video_2 = (&#xA;    np&#xA;        .frombuffer(out_2, np.uint8)&#xA;        .reshape([-1, height, width, 3])&#xA;)&#xA;&#xA;# Video dimesions change&#xA;print(f&#x27;{video.shape} vs {video_2.shape}&#x27;) # (844, 1080, 608, 3) vs (2025, 1080, 608, 3)&#xA;print(f&#x27;{np.array_equal(video, video_2)}&#x27;) # False&#xA;&#xA;# Hashes don&#x27;t match&#xA;print(hashlib.sha256(bytes(video_2)).digest()) # b&#x27;\x88\x00\xc8\x0ed\x84!\x01\x9e\x08 \xd0U\x9a(\x02\x0b-\xeeA\xecU\xf7\xad0xa\x9e\\\xbck\xc3&#x27;&#xA;print(hashlib.sha256(bytes(video)).digest()) # b&#x27;\x9d\xc1\x07xh\x1b\x04I\xed\x906\xe57\xba\xf3\xf1k\x08\xfa\xf1\xfaM\x9a\xcf\xa9\t8\xf0\xc9\t\xa9\xb7&#x27;&#xA;

    &#xA;

    Scikit-video attempt :

    &#xA;

    import skvideo.io as sk&#xA;import numpy as np&#xA;&#xA;video_data = sk.vread(&#x27;test.mkv&#x27;)&#xA;&#xA;sk.vwrite(&#x27;test_2_ski.mkv&#x27;, video_data)&#xA;&#xA;video_data_2 = sk.vread(&#x27;test_2_ski.mkv&#x27;)&#xA;&#xA;# Dimensions match but...&#xA;print(video_data.shape) # (844, 1080, 608, 3)&#xA;print(video_data_2.shape) # (844, 1080, 608, 3)&#xA;&#xA;# ...array elements don&#x27;t&#xA;print(np.array_equal(video_data, video_data_2)) # False&#xA;&#xA;# Hashes don&#x27;t match either&#xA;print(hashlib.sha256(bytes(video_2)).digest()) # b&#x27;\x8b?]\x8epD:\xd9B\x14\xc7\xba\xect\x15G\xfaRP\xde\xad&amp;EC\x15\xc3\x07\n{a[\x80&#x27;&#xA;print(hashlib.sha256(bytes(video)).digest()) # b&#x27;\x9d\xc1\x07xh\x1b\x04I\xed\x906\xe57\xba\xf3\xf1k\x08\xfa\xf1\xfaM\x9a\xcf\xa9\t8\xf0\xc9\t\xa9\xb7&#x27;&#xA;

    &#xA;

    I don't understand where I'm going wrong and both the respective documentations do not highlight how to do this particular task. Any help is appreciated. Thank you.

    &#xA;

  • Unable to stream video file from MediaMTX media server to browser via WebRTC

    8 juin 2024, par thegreatjedi

    I took over a repository at work. It's a working demo comprising a web server which receives video and camera feeds from a media server (built from the rtsp-simple-server Docker image) via a RTSP relay server and streams the feeds to the client, all deployed via Docker Compose.

    &#xA;

    I'm trying to switch over to use WebRTC instead. rtsp-simple-server has upgraded into MediaMTX since the time the demo was created 2 years ago. This is the relevant section of the updated Docker Compose configuration :

    &#xA;

      media-server:&#xA;    image: bluenviron/mediamtx:latest-ffmpeg&#xA;    expose:&#xA;      - 8889&#xA;    init: true&#xA;    ports:&#xA;      - 8889:8889&#xA;    restart: unless-stopped&#xA;    volumes:&#xA;      - type: bind&#xA;        source: ./demo/vids&#xA;        target: /vids&#xA;      - type: bind&#xA;        source: ./demo/mediamtx.yml&#xA;        target: /mediamtx.yml&#xA;

    &#xA;

    Relevant part of the MediaMTX custom configuration in mediamtx.yml :

    &#xA;

    ###############################################&#xA;# Path settings&#xA;&#xA;# Settings in "paths" are applied to specific paths, and the map key&#xA;# is the name of the path.&#xA;# Any setting in "pathDefaults" can be overridden here.&#xA;# It&#x27;s possible to use regular expressions by using a tilde as prefix,&#xA;# for example "~^(test1|test2)$" will match both "test1" and "test2",&#xA;# for example "~^prefix" will match all paths that start with "prefix".&#xA;paths:&#xA;  # example:&#xA;  # my_camera:&#xA;  #   source: rtsp://my_camera&#xA;  ~^demo\d&#x2B;$:&#xA;    runOnDemand: ffmpeg -re -stream_loop -1 -i /vids/$MTX_PATH.mp4 -c:v libvpx -b:v 0 -crf 18 -qmin 18 -qmax 18 -f webm http://localhost:8889/$MTX_PATH/whip&#xA;&#xA;  # Settings under path "all_others" are applied to all paths that&#xA;  # do not match another entry.&#xA;  all_others:&#xA;

    &#xA;

    I've absolutely no experience with WebRTC. This is my first time hearing of this protocol, let alone working with it. From what I understand, I need to convert my demo mp4 videos (which were successfully streaming via RTSP in the previous implementation) to a compatible video codec, so I've opted for VP8.

    &#xA;

    Before trying to stream the videos into my web server, I tested the stream directly in the browser (tried with both the latest versions of Chrome and Edge). I went to http://localhost:8889/demo0 (which should convert demo0.mp4 to VP8 and then stream it over WebRTC). The video player loaded in the browser but no video data was received and nothing played. After several seconds, the screen displayed "Error : bad status code 400, retrying in some seconds". In the browser console, it showed :

    &#xA;

    Failed to load resource : the server responded with a status of 400 (Bad Request)

    &#xA;

    Inside the MediaMTX container's runtime logs, this is what's displayed :

    &#xA;

    2024-04-02 14:53:08 ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers&#xA;2024-04-02 14:53:08   built with gcc 13.2.1 (Alpine 13.2.1_git20231014) 20231014&#xA;2024-04-02 14:53:08   configuration: --prefix=/usr --disable-librtmp --disable-lzma --disable-static --disable-stripping --enable-avfilter --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libmp3lame --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librist --enable-libsoxr --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-lto=auto --enable-lv2 --enable-openssl --enable-pic --enable-postproc --enable-pthreads --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan --optflags=-O3 --enable-libjxl --enable-libsvtav1 --enable-libvpl&#xA;2024-04-02 14:53:08   libavutil      58. 29.100 / 58. 29.100&#xA;2024-04-02 14:53:08   libavcodec     60. 31.102 / 60. 31.102&#xA;2024-04-02 14:53:08   libavformat    60. 16.100 / 60. 16.100&#xA;2024-04-02 14:53:08   libavdevice    60.  3.100 / 60.  3.100&#xA;2024-04-02 14:53:08   libavfilter     9. 12.100 /  9. 12.100&#xA;2024-04-02 14:53:08   libswscale      7.  5.100 /  7.  5.100&#xA;2024-04-02 14:53:08   libswresample   5.  0.100 /  5.  0.100&#xA;2024-04-02 14:53:08   libpostproc    57.  3.100 / 57.  3.100&#xA;2024-04-02 14:53:08 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;/vids/demo0.mp4&#x27;:&#xA;2024-04-02 14:53:08   Metadata:&#xA;2024-04-02 14:53:08     major_brand     : isom&#xA;2024-04-02 14:53:08     minor_version   : 512&#xA;2024-04-02 14:53:08     compatible_brands: isomiso2mp41&#xA;2024-04-02 14:53:08     encoder         : Lavf58.76.100&#xA;2024-04-02 14:53:08   Duration: 00:00:03.47, start: 0.000000, bitrate: 1675 kb/s&#xA;2024-04-02 14:53:08   Stream #0:0[0x1](und): Video: mpeg1video (mp4v / 0x7634706D), yuv420p(tv, progressive), 640x360 [SAR 1:1 DAR 16:9], 104857 kb/s, 30 fps, 30 tbr, 90k tbn (default)&#xA;2024-04-02 14:53:08     Metadata:&#xA;2024-04-02 14:53:08       handler_name    : VideoHandler&#xA;2024-04-02 14:53:08       vendor_id       : [0][0][0][0]&#xA;2024-04-02 14:53:08     Side data:&#xA;2024-04-02 14:53:08       cpb: bitrate max/min/avg: 0/0/0 buffer size: 49152 vbv_delay: N/A&#xA;2024-04-02 14:53:08 Stream mapping:&#xA;2024-04-02 14:53:08   Stream #0:0 -> #0:0 (mpeg1video (native) -> vp8 (libvpx))&#xA;2024-04-02 14:53:08 Press [q] to stop, [?] for help&#xA;2024-04-02 14:53:08 [libvpx @ 0x7faa8591b8c0] v1.13.1&#xA;2024-04-02 14:53:08 [libvpx @ 0x7faa8591b8c0] Bitrate not specified for constrained quality mode, using default of 256kbit/sec&#xA;2024-04-02 14:53:08 Output #0, webm, to &#x27;http://localhost:8889/demo0/whip&#x27;:&#xA;2024-04-02 14:53:08   Metadata:&#xA;2024-04-02 14:53:08     major_brand     : isom&#xA;2024-04-02 14:53:08     minor_version   : 512&#xA;2024-04-02 14:53:08     compatible_brands: isomiso2mp41&#xA;2024-04-02 14:53:08     encoder         : Lavf60.16.100&#xA;2024-04-02 14:53:08   Stream #0:0(und): Video: vp8, yuv420p(tv, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 256 kb/s, 30 fps, 1k tbn (default)&#xA;2024-04-02 14:53:08     Metadata:&#xA;2024-04-02 14:53:08       handler_name    : VideoHandler&#xA;2024-04-02 14:53:08       vendor_id       : [0][0][0][0]&#xA;2024-04-02 14:53:08       encoder         : Lavc60.31.102 libvpx&#xA;2024-04-02 14:53:08     Side data:&#xA;2024-04-02 14:53:08       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;2024-04-02 14:53:18 2024/04/02 06:53:18 INF [path demo0] runOnDemand command stopped: timed out&#xA;2024-04-02 14:53:18 2024/04/02 06:53:18 INF [WebRTC] [session 0f460c76] closed: source of path &#x27;demo0&#x27; has timed out&#xA;[out#0/webm @ 0x7faa859487c0] video:272kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.042856%&#xA;2024-04-02 14:53:18 frame=  315 fps= 32 q=18.0 Lsize=     275kB time=00:00:10.46 bitrate= 215.1kbits/s speed=1.05x    &#xA;2024-04-02 14:53:18 Exiting normally, received signal 2.&#xA;

    &#xA;

    I'm not sure what this is supposed to mean ? Why isn't the server able to stream this 3-second, 709kb video even once ? The browser connected to the server and the URL successfully, but no data was being transferred.

    &#xA;

    Just in case, I decided to manually convert all of my mp4 files to webm using ffmpeg, and verified with Window's media player that the webm videos work. Then, I modified MediaMTX's configuration to stream the webm videos directly :

    &#xA;

    paths:&#xA;  # example:&#xA;  # my_camera:&#xA;  #   source: rtsp://my_camera&#xA;  ~^demo\d&#x2B;$:&#xA;    runOnDemand: ffmpeg -re -stream_loop -1 -i /vids/$MTX_PATH.webm -c copy -f webm http://localhost:8889/$MTX_PATH/whip&#xA;

    &#xA;

    However, the error persists :

    &#xA;

    2024-04-02 15:03:58 ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers&#xA;2024-04-02 15:03:58   built with gcc 13.2.1 (Alpine 13.2.1_git20231014) 20231014&#xA;2024-04-02 15:03:58   configuration: --prefix=/usr --disable-librtmp --disable-lzma --disable-static --disable-stripping --enable-avfilter --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libmp3lame --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librist --enable-libsoxr --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-lto=auto --enable-lv2 --enable-openssl --enable-pic --enable-postproc --enable-pthreads --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan --optflags=-O3 --enable-libjxl --enable-libsvtav1 --enable-libvpl&#xA;2024-04-02 15:03:58   libavutil      58. 29.100 / 58. 29.100&#xA;2024-04-02 15:03:58   libavcodec     60. 31.102 / 60. 31.102&#xA;2024-04-02 15:03:58   libavformat    60. 16.100 / 60. 16.100&#xA;2024-04-02 15:03:58   libavdevice    60.  3.100 / 60.  3.100&#xA;2024-04-02 15:03:58   libavfilter     9. 12.100 /  9. 12.100&#xA;2024-04-02 15:03:58   libswscale      7.  5.100 /  7.  5.100&#xA;2024-04-02 15:03:58   libswresample   5.  0.100 /  5.  0.100&#xA;2024-04-02 15:03:58   libpostproc    57.  3.100 / 57.  3.100&#xA;2024-04-02 15:03:58 Input #0, matroska,webm, from &#x27;/vids/demo0.webm&#x27;:&#xA;2024-04-02 15:03:58   Metadata:&#xA;2024-04-02 15:03:58     COMPATIBLE_BRANDS: isomiso2mp41&#xA;2024-04-02 15:03:58     MAJOR_BRAND     : isom&#xA;2024-04-02 15:03:58     MINOR_VERSION   : 512&#xA;2024-04-02 15:03:58     ENCODER         : Lavf60.16.100&#xA;2024-04-02 15:03:58   Duration: 00:00:03.47, start: 0.000000, bitrate: 217 kb/s&#xA;2024-04-02 15:03:58   Stream #0:0: Video: vp8, yuv420p(tv, progressive), 640x360, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn (default)&#xA;2024-04-02 15:03:58     Metadata:&#xA;2024-04-02 15:03:58       HANDLER_NAME    : VideoHandler&#xA;2024-04-02 15:03:58       VENDOR_ID       : [0][0][0][0]&#xA;2024-04-02 15:03:58       ENCODER         : Lavc60.31.102 libvpx&#xA;2024-04-02 15:03:58       DURATION        : 00:00:03.466000000&#xA;2024-04-02 15:03:58 Output #0, webm, to &#x27;http://localhost:8889/demo0/whip&#x27;:&#xA;2024-04-02 15:03:58   Metadata:&#xA;2024-04-02 15:03:58     COMPATIBLE_BRANDS: isomiso2mp41&#xA;2024-04-02 15:03:58     MAJOR_BRAND     : isom&#xA;2024-04-02 15:03:58     MINOR_VERSION   : 512&#xA;2024-04-02 15:03:58     encoder         : Lavf60.16.100&#xA;2024-04-02 15:03:58   Stream #0:0: Video: vp8, yuv420p(tv, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbr, 1k tbn (default)&#xA;2024-04-02 15:03:58     Metadata:&#xA;2024-04-02 15:03:58       HANDLER_NAME    : VideoHandler&#xA;2024-04-02 15:03:58       VENDOR_ID       : [0][0][0][0]&#xA;2024-04-02 15:03:58       ENCODER         : Lavc60.31.102 libvpx&#xA;2024-04-02 15:03:58       DURATION        : 00:00:03.466000000&#xA;2024-04-02 15:03:58 Stream mapping:&#xA;2024-04-02 15:03:58   Stream #0:0 -> #0:0 (copy)&#xA;2024-04-02 15:03:58 Press [q] to stop, [?] for help&#xA;2024-04-02 15:04:08 2024/04/02 07:04:08 INF [path demo0] runOnDemand command stopped: timed out&#xA;2024-04-02 15:04:08 2024/04/02 07:04:08 INF [WebRTC] [session 829664cb] closed: source of path &#x27;demo0&#x27; has timed out&#xA;[out#0/webm @ 0x7f04b00515c0] video:281kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.023511%&#xA;2024-04-02 15:04:08 size=     284kB time=00:00:10.49 bitrate= 221.3kbits/s speed=1.05x    &#xA;2024-04-02 15:04:08 Exiting normally, received signal 2.&#xA;

    &#xA;

    This is the same when I try to stream my other videos (demo1.mp4, demo2.mp4 etc.). What am I doing wrong ?

    &#xA;