Recherche avancée

Médias (39)

Mot : - Tags -/audio

Autres articles (61)

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

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

Sur d’autres sites (8068)

  • FFmpeg remuxing parts of an audio file

    22 décembre 2022, par zorleone

    I'm trying to remux individual tracks from a FLAC file using the FFmpeg libraries.
I get the starting timestamps from a Cue sheet, I seek to the timestamps using avformat_seek_file. However after writing the packets to output files, they only have data from the beginning of the input file.

    


    This is the code snippet which opens the input FLAC and also creates an output AVFormatContext for each track. I'm guessing the issue is avformat_seek_file, it doesn't seem to do anything, since even though I seek to the beginning of a track, the output file contains data from the beginning of the input.

    


        for(int i = 0; i <= sheet.ntracks; i++) {
        sheet.avfmtctx = avformat_alloc_context();
        if(avformat_open_input(&sheet.avfmtctx, sheet.file, NULL, NULL) < 0) {
            fprintf(stderr,
                    "avformat_open_input(): failed to open %s\n",
                    sheet.file);
            return 1;
        }
        int audio_stream_idx = -1;
        for(int i = 0; i < sheet.avfmtctx->nb_streams; i++) {
            if(sheet.avfmtctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
                audio_stream_idx = i;
                break;
            }
        }
        avformat_find_stream_info(sheet.avfmtctx, NULL);
        AVFormatContext *output;
        char *filepath = title_to_filepath(&sheet.tracks[i], sheet.file);
        avformat_alloc_output_context2(&output, NULL, NULL, filepath);
        AVStream *out_audio_stream = avformat_new_stream(output, NULL);
        avcodec_parameters_copy(out_audio_stream->codecpar,
                                sheet.avfmtctx->streams[audio_stream_idx]->codecpar);

        if(avio_open(&output->pb, filepath, AVIO_FLAG_WRITE) < 0) {
            fprintf(stderr, "Failed to open %s for writing\n", filepath);
            return 1;
        }
        if(avformat_write_header(output, NULL) < 0) {
            fprintf(stderr, "avformat_write_header() failed\n");
            return 1;
        }
        int64_t current_frame = sheet.tracks[i].index;
        int64_t next_track_index = (i < sheet.ntracks) ?
                                   sheet.tracks[i + 1].index :
                                   INT64_MAX;
        if(avformat_seek_file(sheet.avfmtctx,
                           -1,
                           INT64_MIN,
                           current_frame,
                           current_frame,
                           0) < 0) {
            fprintf(stderr, "Failed to seek to the index of track %d\n", i);
            avformat_free_context(sheet.avfmtctx);
            sheet.avfmtctx = NULL;
            av_write_trailer(output);
            avio_closep(&output->pb);
            avformat_free_context(output);
            free(filepath);
            continue;
        }
        AVPacket *pkt = av_packet_alloc();
        int64_t pts_diff = AV_NOPTS_VALUE, dts_diff = AV_NOPTS_VALUE;
        while(current_frame < next_track_index && !avio_feof(output->pb)) {
            int ret;
            if((ret = av_read_frame(sheet.avfmtctx, pkt)) < 0) {
                if(ret != AVERROR_EOF)
                    fprintf(stderr, "av_read_frame() failed: %s\n", av_err2str(ret));
                break;
            }
            if(pkt->stream_index != audio_stream_idx)
                continue;
            // runs only once
            if(pts_diff == AV_NOPTS_VALUE && dts_diff == AV_NOPTS_VALUE) {
                pts_diff = pkt->pts;
                dts_diff = pkt->dts;
            }

            pkt->stream_index = 0; // first and only stream
            pkt->pts -= pts_diff;
            pkt->dts -= dts_diff;
            pkt->pos = -1;
            av_interleaved_write_frame(output, pkt);

            current_frame++;
        }

        avformat_free_context(sheet.avfmtctx);
        sheet.avfmtctx = NULL;

        av_write_trailer(output);
        av_packet_free(&pkt);
        avio_closep(&output->pb);
        avformat_free_context(output);

        free(filepath);
    }



    


    current_frame and next_track_index are calculated from the INDEX lines in the Cue sheet : MM * 60 * 75 + SS * 75 + FF.
Can someone tell me what I'm doing wrong, and how to get the data I need from the input ?

    


  • Remux and segment only parts of a video file without difference in output

    20 juin 2013, par Christian P.

    I have a working program built on top of libav (alternatively ffmpeg - expertise is either is useful here).

    It takes an mp4 video, encoded with h264 video / AAC audio, and remuxes it to MPEG TS and segments it into X second chunks. It is analogous to the following ffmpeg command :

    ffmpeg -y -i video.mp4 -c:a copy -bsf:a aac_adtstoasc -c:v copy -bsf:v h264_mp4toannexb -flags -global_header -map 0 -f segment -segment_time 10 -segment_list playlist.m3u8 -segment_format mpegts chunk_%03d.ts

    The reason I am not using the command-line, is that I wish to generate only a subset of the segments. So if a video results in 10 segments of between 8 and 12 seconds (the segments are never exactly the desired length due to keyframes), I might wish to generate segments 3-7 at a later time.

    The complete code for my program can be found here.

    I use av_read_frame to read every frame from the source file, remux (including a bitfilter process) and write to output file. Once the duration since the last output becomes close/greater than the desired segment length, I flush the output file, close it, open the next segment and continue.

    I have tried altering the code to do an av_seek_frame to the end of the first segment and start from there (I also attempted to start at the end of the 2nd and 3rd segment). The new segments are the same length (in seconds and pts), but have a different size than the comparable segments from the full runthrough (within a few kilobytes) - the starting segment (whether it's the 2nd, 3rd or other) also shows as having 2 packets LESS than the comparable segment from previously.

    I assumed that av_seek_frame would give me an exact match as if I had manually done a loop with av_read_frame up to that frame, but it seems like it's not the case.

    What I wish for :

    • A way to "fast-forward" in the file to a specific (not approximate) point in the file.
    • To write from that point forward and have the output be completely identical to the output a full run provides (same size, same length, same exact bytes).
  • How To Abandon The Probesize Input Buffer For Real Time RTSP Playback

    3 juin 2014, par user3051473

    As far as I know that ffmpeg need to first read probesize input buffer to analysis the codec. And the probesize data will cause realtime RTSP delay. So I’m wandering that :

    How can I make av_read_frame() to skip the probesize input buffer which has already delayed ? Thanks very much.