Recherche avancée

Médias (1)

Mot : - Tags -/ticket

Autres articles (66)

  • Submit enhancements and plugins

    13 avril 2011

    If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
    You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

Sur d’autres sites (6926)

  • Bit-field badness

    30 janvier 2010, par Mans — Compilers, Optimisation

    Consider the following C code which is based on an real-world situation.

    struct bf1_31 
        unsigned a:1 ;
        unsigned b:31 ;
     ;
    

    void func(struct bf1_31 *p, int n, int a)

    int i = 0 ;
    do
    if (p[i].a)
    p[i].b += a ;
    while (++i < n) ;

    How would we best write this in ARM assembler ? This is how I would do it :

    func :
            ldr     r3,  [r0], #4
            tst     r3,  #1
            add     r3,  r3,  r2,  lsl #1
            strne   r3,  [r0, #-4]
            subs    r1,  r1,  #1
            bgt     func
            bx      lr
    

    The add instruction is unconditional to avoid a dependency on the comparison. Unrolling the loop would mask the latency of the ldr instruction as well, but that is outside the scope of this experiment.

    Now compile this code with gcc -march=armv5te -O3 and watch in horror :

    func :
            push    r4
            mov     ip, #0
            mov     r4, r2
    loop :
            ldrb    r3, [r0]
            add     ip, ip, #1
            tst     r3, #1
            ldrne   r3, [r0]
            andne   r2, r3, #1
            addne   r3, r4, r3, lsr #1
            orrne   r2, r2, r3, lsl #1
            strne   r2, [r0]
            cmp     ip, r1
            add     r0, r0, #4
            blt     loop
            pop     r4
            bx      lr
    

    This is nothing short of awful :

    • The same value is loaded from memory twice.
    • A complicated mask/shift/or operation is used where a simple shifted add would suffice.
    • Write-back addressing is not used.
    • The loop control counts up and compares instead of counting down.
    • Useless mov in the prologue ; swapping the roles or r2 and r4 would avoid this.
    • Using lr in place of r4 would allow the return to be done with pop {pc}, saving one instruction (ignoring for the moment that no callee-saved registers are needed at all).

    Even for this trivial function the gcc-generated code is more than twice the optimal size and slower by approximately the same factor.

    The main issue I wanted to illustrate is the poor handling of bit-fields by gcc. When accessing bitfields from memory, gcc issues a separate load for each field even when they are contained in the same aligned memory word. Although each load after the first will most likely hit L1 cache, this is still bad for several reasons :

    • Loads have typically two or three cycles result latency compared to one cycle for data processing instructions. Any bit-field can be extracted from a register with two shifts, and on ARM the second of these can generally be achieved using a shifted second operand to a following instruction. The ARMv6T2 instruction set also adds the SBFX and UBFX instructions for extracting any signed or unsigned bit-field in one cycle.
    • Most CPUs have more data processing units than load/store units. It is thus more likely for an ALU instruction than a load/store to issue without delay on a superscalar processor.
    • Redundant memory accesses can trigger early flushing of store buffers rendering these less efficient.

    No gcc bashing is complete without a comparison with another compiler, so without further ado, here is the ARM RVCT output (armcc --cpu 5te -O3) :

    func :
            mov     r3, #0
            push    r4, lr
    loop :
            ldr     ip, [r0, r3, lsl #2]
            tst     ip, #1
            addne   ip, ip, r2, lsl #1
            strne   ip, [r0, r3, lsl #2]
            add     r3, r3, #1
            cmp     r3, r1
            blt     loop
            pop     r4, pc
    

    This is much better, the core loop using only one instruction more than my version. The loop control is counting up, but at least this register is reused as offset for the memory accesses. More remarkable is the push/pop of two registers that are never used. I had not expected to see this from RVCT.

    Even the best compilers are still no match for a human.

  • Batch splitting large audio files into small fixed-length audio files in moments of silence

    26 juillet 2023, par Haldjärvi

    to train the SO-VITS-SVC neural network, we need 10-14 second voice files. As a material, let's say I use phrases from some game. I have already made a batch script for decoding different files into one working format, another batch script for removing silence, as well as a batch script for combining small audio files into files of 13-14 seconds (I used Python, pydub and FFmpeg). To successfully automatically create a training dataset, it remains only to make one batch script - Cutting audio files lasting more than 14 seconds into separate files lasting 10-14 seconds, cutting in places of silence or close to silence is highly preferable.

    &#xA;

    So, it is necessary to batch cut large audio files (20 seconds, 70 seconds, possibly several hundred seconds) into segments of approximately 10-14 seconds, however, the main task is to look for the quietest place in the cut areas so as not to cut phrases in the middle of a word (this is not very good for model training). So, is it really possible to do this in a very optimal way, so that the processing of a 30-second file does not take 15 seconds, but is fast ? Quiet zone detection is required only in the area of cuts, that is, 10-14 seconds, if counted from the very beginning of the file.

    &#xA;

    I would be very grateful for any help.

    &#xA;

    I tried to write a script together with ChatGPT, but all options gave completely unpredictable results and were not even close to what I needed... I had to stop at the option with a sharp cut of files for exactly 14000 milliseconds. However, I hope there is a chance to make a variant with cutting exactly in quiet areas.

    &#xA;

    import os&#xA;from pydub import AudioSegment&#xA;&#xA;input_directory = ".../RemSilence/"&#xA;output_directory = ".../Split/"&#xA;max_duration = 14000&#xA;&#xA;def split_audio_by_duration(input_file, duration):&#xA;    audio = AudioSegment.from_file(input_file)&#xA;    segments = []&#xA;    for i in range(0, len(audio), duration):&#xA;        segment = audio[i:i &#x2B; duration]&#xA;        segments.append(segment)&#xA;    return segments&#xA;&#xA;if __name__ == "__main__":&#xA;    os.makedirs(output_directory, exist_ok=True)&#xA;    audio_files = [os.path.join(input_directory, file) for file in os.listdir(input_directory) if file.endswith(".wav")]&#xA;    audio_files.sort(key=lambda file: len(AudioSegment.from_file(file)))&#xA;    for file in audio_files:&#xA;        audio = AudioSegment.from_file(file)&#xA;        if len(audio) > max_duration:&#xA;            segments = split_audio_by_duration(file, max_duration)&#xA;            for i, segment in enumerate(segments):&#xA;                output_filename = f"output_{len(os.listdir(output_directory))&#x2B;1}.wav"&#xA;                output_file_path = os.path.join(output_directory, output_filename)&#xA;                segment.export(output_file_path, format="wav")&#xA;        else:&#xA;            output_filename = f"output_{len(os.listdir(output_directory))&#x2B;1}.wav"&#xA;            output_file_path = os.path.join(output_directory, output_filename)&#xA;            audio.export(output_file_path, format="wav")&#xA;

    &#xA;

  • How to set pts, dts and duration in ffmpeg library ?

    24 mars, par hslee

    I want to pack some compressed video packets(h.264) to ".mp4" container.&#xA;One word, Muxing, no decoding and no encoding.&#xA;And I have no idea how to set pts, dts and duration.

    &#xA;&#xA;

      &#xA;
    1. I get the packets with "pcap" library.
    2. &#xA;

    3. I removed headers before compressed video data show up. e.g. Ethernet, VLAN.
    4. &#xA;

    5. I collected data until one frame and decoded it for getting information of data. e.g. width, height. (I am not sure that it is necessary)
    6. &#xA;

    7. I initialized output context, stream and codec context.
    8. &#xA;

    9. I started to receive packets with "pcap" library again. (now for muxing)
    10. &#xA;

    11. I made one frame and put that data in AVPacket structure.
    12. &#xA;

    13. I try to set PTS, DTS and duration. (I think here is wrong part, not sure though)
    14. &#xA;

    &#xA;&#xA;

    *7-1. At the first frame, I saved time(msec) with packet header structure.

    &#xA;&#xA;

    *7-2. whenever I made one frame, I set parameters like this : PTS(current time - start time), DTS(same PTS value), duration(current PTS - before PTS)

    &#xA;&#xA;

    I think it has some error because :

    &#xA;&#xA;

      &#xA;
    1. I don't know how far is suitable long for dts from pts.

    2. &#xA;

    3. At least, I think duration means how long time show this frame from now to next frame, so It should have value(next PTS - current PTS), but I can not know the value next PTS at that time.

    4. &#xA;

    &#xA;&#xA;

    It has I-frame only.

    &#xA;&#xA;

    // make input context for decoding&#xA;&#xA;AVFormatContext *&amp;ic = gInputContext;&#xA;&#xA;ic = avformat_alloc_context();&#xA;&#xA;AVCodec *cd = avcodec_find_decoder(AV_CODEC_ID_H264);&#xA;&#xA;AVStream *st = avformat_new_stream(ic, cd);&#xA;&#xA;AVCodecContext *cc = st->codec;&#xA;&#xA;avcodec_open2(cc, cd, NULL);&#xA;&#xA;// make packet and decode it after collect packets is be one frame&#xA;&#xA;gPacket.stream_index = 0;&#xA;&#xA;gPacket.size    = gPacketLength[0];&#xA;&#xA;gPacket.data    = gPacketData[0];&#xA;&#xA;gPacket.pts     = AV_NOPTS_VALUE;&#xA;&#xA;gPacket.dts     = AV_NOPTS_VALUE;&#xA;&#xA;gPacket.flags   = AV_PKT_FLAG_KEY;&#xA;&#xA;avcodec_decode_video2(cc, gFrame, &amp;got_picture, &amp;gPacket);&#xA;&#xA;// I checked automatically it initialized after "avcodec_decode_video2"&#xA;&#xA;// put some info that I know that not initialized&#xA;&#xA;cc->time_base.den   = 90000;&#xA;&#xA;cc->time_base.num   = 1;&#xA;&#xA;cc->bit_rate    = 2500000;&#xA;&#xA;cc->gop_size    = 1;&#xA;&#xA;// make output context with input context&#xA;&#xA;AVFormatContext *&amp;oc = gOutputContext;&#xA;&#xA;avformat_alloc_output_context2(&amp;oc, NULL, NULL, filename);&#xA;&#xA;AVFormatContext *&amp;ic = gInputContext;&#xA;&#xA;AVStream *ist = ic->streams[0];&#xA;&#xA;AVCodecContext *&amp;icc = ist->codec;&#xA;&#xA;AVStream *ost = avformat_new_stream(oc, icc->codec);&#xA;&#xA;AVCodecContext *occ = ost->codec;&#xA;&#xA;avcodec_copy_context(occ, icc);&#xA;&#xA;occ->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;avio_open(&amp;(oc->pb), filename, AVIO_FLAG_WRITE);&#xA;&#xA;// repeated part for muxing&#xA;&#xA;AVRational Millisecond = { 1, 1000 };&#xA;&#xA;gPacket.stream_index = 0;&#xA;&#xA;gPacket.data = gPacketData[0];&#xA;&#xA;gPacket.size = gPacketLength[0];&#xA;&#xA;gPacket.pts = av_rescale_rnd(pkthdr->ts.tv_sec * 1000 /&#xA;&#xA;    &#x2B; pkthdr->ts.tv_usec / 1000 /&#xA;&#xA;    - gStartTime, Millisecond.den, ost->time_base.den, /&#xA;&#xA;    (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));&#xA;&#xA;gPacket.dts = gPacket.pts;&#xA;&#xA;gPacket.duration = gPacket.pts - gPrev;&#xA;&#xA;gPacket.flags = AV_PKT_FLAG_KEY;&#xA;&#xA;gPrev = gPacket.pts;&#xA;&#xA;av_interleaved_write_frame(gOutputContext, &amp;gPacket);&#xA;

    &#xA;&#xA;

    Expected and actual results is a .mp4 video file that can play.

    &#xA;