Recherche avancée

Médias (21)

Mot : - Tags -/Nine Inch Nails

Autres articles (36)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

Sur d’autres sites (5014)

  • Swift - Workaround/Alternative to M3u8 to play mp4 segment or merge segments into mp4

    14 mai 2020, par STerrier

    I used AVAssetExportSession to download a session URL but the issue that you can't download live stream so to get around it, the live stream is split into 10 seconds mp4 segments that are downloaded using an m3u8 to create the URLs. I then use AVAssetExportSession to merge those mp4 segments.

    



    I can merge those clips one by one into one mp4 file which is what I want but as the file gets bigger, the longer it takes as I am dealing with thousands of segments which becomes unpractical.

    



    I thought about using AVplayerLooper but I cannot scrub, rewind or forward through the mp4 segment like a single video.

    



    Is there a way to combine the mp4 clips together to play as one video as the m3u8 does without merging ? or is there a fast way to merge videos ?

    



    Note : The server uses FFmpeg but I am not allowed to use FFmpeg or pods in the app.

    



    below is the function to merge videos

    



    var mp4Array: [AVAsset] = []
var avAssetExportSession: AVAssetExportSession?

var firstAsset: AVAsset?
var secondAsset: AVAsset?

func mergeVideos() {

    firstAsset = mp4Array.first
    secondAsset = mp4Array[1]

    guard let firstAsset = firstAsset, let secondAsset = secondAsset else { return }
    let mixComposition = AVMutableComposition()

    guard let firstTrack = mixComposition.addMutableTrack(withMediaType: .video, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) else {return}

    do {

        try firstTrack.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: firstAsset.duration),
                                       of: firstAsset.tracks(withMediaType: .video)[0],
                                       at: CMTime.zero)

    } catch {
        print("Couldn't load track 1")
        return
    }

    guard let secondTrack = mixComposition.addMutableTrack(withMediaType: .video, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) else {return}

    do {
        try secondTrack.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: secondAsset.duration),
                                        of: secondAsset.tracks(withMediaType: .video)[0],
                                        at: firstAsset.duration)
    } catch {
        print("couldn't load track 2")
        return
    }

    let mainInstruction = AVMutableVideoCompositionInstruction()
    mainInstruction.timeRange = CMTimeRangeMake(start: CMTime.zero, duration: CMTimeAdd(firstAsset.duration, secondAsset.duration))

    let firstAssetInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: firstTrack)
    firstAssetInstruction.setOpacity(0.0, at: firstAsset.duration)

    let secondAssetInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: secondTrack)

    mainInstruction.layerInstructions = [firstAssetInstruction, secondAssetInstruction]
    let mainComposition = AVMutableVideoComposition()
    mainComposition.instructions = [mainInstruction]
    mainComposition.frameDuration = CMTimeMake(value: 1, timescale: 30)
    mainComposition.renderSize = firstTrack.naturalSize

    guard let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
    let url = documentDirectory.appendingPathComponent("MergedVideos/mergeVideo\(videoInt).mp4")

    guard let exporter = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetHighestQuality) else {return}

    exporter.outputURL = url
    exporter.outputFileType = AVFileType.mp4
    exporter.shouldOptimizeForNetworkUse = true
    exporter.videoComposition = mainComposition

    exporter.exportAsynchronously {

        if exporter.status == .completed {
            let avasset = AVAsset(url:url)
            self.mergeUrl = avasset
            if self.mp4Array.count > 1{
                print("This add the merged video to the front of the mp4array")
                self.mp4Array.remove(at: 1)
                self.mp4Array.removeFirst()
                self.videoInt = self.videoInt + 1
                self.mp4Array.append(self.mergeUrl!)
                self.mp4Array.bringToFront(item: self.mp4Array.last!)
            }

            if (self.mp4Array.count > 1){
                if self.mergeUrl != nil {
                    self.mergeVideos()
                }
            } else {
                var numberofvideosdeleted = 0
                while (numberofvideosdeleted < self.videoInt - 1){
                    do {
                        print("deleting")
                        let url = documentDirectory.appendingPathComponent("MergedVideos/mergeVideo\(numberofvideosdeleted).mp4")
                        try FileManager.default.removeItem(at: url)
                        numberofvideosdeleted = numberofvideosdeleted + 1
                    } catch {
                        print("Error removing videos")
                    }
                }

                self.deleteCurrentSegementsInFolder()
            }
        }
    }
}


    


  • avformat/matroskadec : Fix lzo decompression

    28 décembre 2019, par Andreas Rheinhardt
    avformat/matroskadec : Fix lzo decompression
    

    When a Matroska Block is only stored in compressed form, the size of
    the uncompressed block is not explicitly coded and therefore not known
    before decompressing it. Therefore the demuxer uses a guess for the
    uncompressed size : The first guess is three times the compressed size
    and if this is not enough, it is repeatedly incremented by a factor of
    three. But when this happens with lzo, the decompression is neither
    resumed nor started again. Instead when av_lzo1x_decode indicates that x
    bytes of input data could not be decoded, because the output buffer is
    already full, the first (not the last) x bytes of the input buffer are
    resent for decoding in the next try ; they overwrite already decoded
    data.

    This commit fixes this by instead restarting the decompression anew,
    just with a bigger buffer.

    This seems to be a regression since 935ec5a1.

    A FATE-test for this has been added.

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Signed-off-by : James Almer <jamrial@gmail.com>

    • [DH] libavformat/matroskadec.c
    • [DH] tests/fate/matroska.mak
    • [DH] tests/ref/fate/matroska-lzo-decompression
  • FFMPEG : sws_scale returns error : Slice parameters 0, 2160 are invalid

    21 janvier 2020, par Matthew Czarnek

    I’m trying to follow a tutorial to display ffmpeg AVFrame output in SDL. The tutorial(and all examples I’m seeing online) are still using ’sws_getContext’, which has been deprecated and removed from the newest version of ffmpeg. Trying to change current pixel format from whatever it currently is to PIX_FMT_YUV420P, so I can display it. I believe I need the sws_scale function to accomplish this.

    However, sws_scale is the function that causes a command line error of :
    Slice parameters 0, 2160 are invalid

    Here is all my code associate with swsContext :

    struct SwsContext* av_sws_ctx = NULL;
    av_sws_ctx = sws_alloc_context();

    sws_init_context(av_sws_ctx, NULL, NULL);

    sws_scale(av_sws_ctx, (uint8_t const* const*)av_frame->data,
                           av_frame->linesize, 0, av_codec_context->height,
                           av_frame->data, av_frame->linesize);

    Further complicating the matter, SwsContext is only defined internal to ffmpeg, externally I can’t set/get any variables or even view them in the debugger.

    int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[] )

    The vales of other parameters, other than av_sws_ctx :

    srcSlice: av_frame->data =
        8 arrays, first is filled with "\x10\x10\x10\x10\x10..."
        second and third are "€€€€€€€€€€€€€€€€€..."
        rest are NULL
    linesize(av_frame->linesize) is an array:
       3840,1920,1920,0,0,0,0,0
    srcSliceY:0
    srcSliceH:2160
    dest: same as second parameter (av_frame->data)
    dstStride: av_frame->linesize again

    If I drill into sws_scale source code, I find that this error is thrown by this chunk of code :

    if ((srcSliceY &amp; (macro_height-1)) ||
           ((srcSliceH&amp; (macro_height-1)) &amp;&amp; srcSliceY + srcSliceH != c->srcH) ||
           srcSliceY + srcSliceH > c->srcH) {
           av_log(c, AV_LOG_ERROR, "Slice parameters %d, %d are invalid\n", srcSliceY, srcSliceH);
           return AVERROR(EINVAL);
       }

    I assume that the issue therefore is that the height of my video is bigger than sws_context(4k video). But can’t figure out how to tell sws_context what it’s height should be using sws_alloc_context or sws_init_context or any other function.

    See something I’m missing ? Thank you.