Recherche avancée

Médias (9)

Mot : - Tags -/soundtrack

Autres articles (81)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

Sur d’autres sites (12794)

  • Split h.264 stream into multiple parts in python

    31 janvier 2023, par BillPlayz

    My objective is to split an h.264 stream into multiple parts, meaning while reading the stream from a pipe i would like to save it into x second long packages (in my case 10).

    


    I am using a libcamera-vid subprocess on my Raspberry Pi that outputs the h.264 stream into stdout.
    
Might be irrelevant, depends : libcamera-vid outputs a message every frame and I am able to locate it at isFrameStopLine
To convert the stream, I use an ffmpeg subprocess, as you can see in the code below.

    


    Imagine it like that :
    
Stream is running...
    
- Start recording to a file
    
- Sleep x seconds
    
- Finish recording to file
    
- Start recording a new file
    
- Sleep x seconds
    
- Finish recording the new file
    
- and so on...

    


    Here is my current code, however upon running the first export succeeds, and after the second or third the ffmpeg-subprocess is terminating with the error :
    
pipe:: Invalid data found when processing input
    &#xA;And shortly after, the python process, because of the ffmpeg termination i believe.&#xA;Traceback (most recent call last):   File "/home/survpi-camera/main.py", line 56, in <module>     processStreamLine(readData)   File "/home/survpi-camera/main.py", line 16, in processStreamLine     streamInfo["process"].stdin.write(data) BrokenPipeError: [Errno 32] Broken pipe</module>

    &#xA;

    recentStreamProcesses = []&#xA;streamInfo = {&#xA;    "lastStreamStart": -1,&#xA;    "process": None&#xA;}&#xA;&#xA;def processStreamLine(data):&#xA;    isInfoLine = ((data.startswith(b"[") and (b"INFO" in data)) or (data == b"Preview window unavailable"))&#xA;    isFrameStopLine = (data.startswith(b"#") and (b" fps) exp" in data))&#xA;    if ((not isInfoLine) and (not isFrameStopLine)):&#xA;        streamInfo["process"].stdin.write(data)&#xA;    &#xA;    if (isFrameStopLine):&#xA;        if (time.time() - streamInfo["lastStreamStart"] >= 10):&#xA;            print("10 seconds passed, exporting...")&#xA;            exportStream()&#xA;            createNewStream()&#xA;&#xA;def createNewStream():&#xA;    streamInfo["lastStreamStart"] = time.time()&#xA;    streamInfo["process"] = subprocess.Popen([&#xA;        "ffmpeg",&#xA;        "-r","30",&#xA;        "-i","-",&#xA;        "-c","copy",("/home/survpi-camera/" &#x2B; str(round(time.time())) &#x2B; ".mp4")&#xA;    ],stdin=subprocess.PIPE,stderr=subprocess.STDOUT)&#xA;    print("Created new streamProcess.")&#xA;&#xA;def exportStream():&#xA;    print("Exporting...")&#xA;    streamInfo["process"].stdin.close()&#xA;    recentStreamProcesses.append(streamInfo["process"])&#xA;&#xA;&#xA;cameraProcess = subprocess.Popen([&#xA;    "libcamera-vid",&#xA;    "-t","0",&#xA;    "--width","1920",&#xA;    "--height","1080",&#xA;    "--codec","h264",&#xA;    "--inline",&#xA;    "--listen",&#xA;    "-o","-"&#xA;],stdout=subprocess.PIPE,stdin=subprocess.PIPE,stderr=subprocess.STDOUT)&#xA;&#xA;createNewStream()&#xA;&#xA;while True:&#xA;    readData = cameraProcess.stdout.readline()&#xA;    &#xA;    processStreamLine(readData)&#xA;

    &#xA;

    Thank you in advance !

    &#xA;

  • 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.&#xA;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.

    &#xA;

    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.

    &#xA;

        for(int i = 0; i &lt;= sheet.ntracks; i&#x2B;&#x2B;) {&#xA;        sheet.avfmtctx = avformat_alloc_context();&#xA;        if(avformat_open_input(&amp;sheet.avfmtctx, sheet.file, NULL, NULL) &lt; 0) {&#xA;            fprintf(stderr,&#xA;                    "avformat_open_input(): failed to open %s\n",&#xA;                    sheet.file);&#xA;            return 1;&#xA;        }&#xA;        int audio_stream_idx = -1;&#xA;        for(int i = 0; i &lt; sheet.avfmtctx->nb_streams; i&#x2B;&#x2B;) {&#xA;            if(sheet.avfmtctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;                audio_stream_idx = i;&#xA;                break;&#xA;            }&#xA;        }&#xA;        avformat_find_stream_info(sheet.avfmtctx, NULL);&#xA;        AVFormatContext *output;&#xA;        char *filepath = title_to_filepath(&amp;sheet.tracks[i], sheet.file);&#xA;        avformat_alloc_output_context2(&amp;output, NULL, NULL, filepath);&#xA;        AVStream *out_audio_stream = avformat_new_stream(output, NULL);&#xA;        avcodec_parameters_copy(out_audio_stream->codecpar,&#xA;                                sheet.avfmtctx->streams[audio_stream_idx]->codecpar);&#xA;&#xA;        if(avio_open(&amp;output->pb, filepath, AVIO_FLAG_WRITE) &lt; 0) {&#xA;            fprintf(stderr, "Failed to open %s for writing\n", filepath);&#xA;            return 1;&#xA;        }&#xA;        if(avformat_write_header(output, NULL) &lt; 0) {&#xA;            fprintf(stderr, "avformat_write_header() failed\n");&#xA;            return 1;&#xA;        }&#xA;        int64_t current_frame = sheet.tracks[i].index;&#xA;        int64_t next_track_index = (i &lt; sheet.ntracks) ?&#xA;                                   sheet.tracks[i &#x2B; 1].index :&#xA;                                   INT64_MAX;&#xA;        if(avformat_seek_file(sheet.avfmtctx,&#xA;                           -1,&#xA;                           INT64_MIN,&#xA;                           current_frame,&#xA;                           current_frame,&#xA;                           0) &lt; 0) {&#xA;            fprintf(stderr, "Failed to seek to the index of track %d\n", i);&#xA;            avformat_free_context(sheet.avfmtctx);&#xA;            sheet.avfmtctx = NULL;&#xA;            av_write_trailer(output);&#xA;            avio_closep(&amp;output->pb);&#xA;            avformat_free_context(output);&#xA;            free(filepath);&#xA;            continue;&#xA;        }&#xA;        AVPacket *pkt = av_packet_alloc();&#xA;        int64_t pts_diff = AV_NOPTS_VALUE, dts_diff = AV_NOPTS_VALUE;&#xA;        while(current_frame &lt; next_track_index &amp;&amp; !avio_feof(output->pb)) {&#xA;            int ret;&#xA;            if((ret = av_read_frame(sheet.avfmtctx, pkt)) &lt; 0) {&#xA;                if(ret != AVERROR_EOF)&#xA;                    fprintf(stderr, "av_read_frame() failed: %s\n", av_err2str(ret));&#xA;                break;&#xA;            }&#xA;            if(pkt->stream_index != audio_stream_idx)&#xA;                continue;&#xA;            // runs only once&#xA;            if(pts_diff == AV_NOPTS_VALUE &amp;&amp; dts_diff == AV_NOPTS_VALUE) {&#xA;                pts_diff = pkt->pts;&#xA;                dts_diff = pkt->dts;&#xA;            }&#xA;&#xA;            pkt->stream_index = 0; // first and only stream&#xA;            pkt->pts -= pts_diff;&#xA;            pkt->dts -= dts_diff;&#xA;            pkt->pos = -1;&#xA;            av_interleaved_write_frame(output, pkt);&#xA;&#xA;            current_frame&#x2B;&#x2B;;&#xA;        }&#xA;&#xA;        avformat_free_context(sheet.avfmtctx);&#xA;        sheet.avfmtctx = NULL;&#xA;&#xA;        av_write_trailer(output);&#xA;        av_packet_free(&amp;pkt);&#xA;        avio_closep(&amp;output->pb);&#xA;        avformat_free_context(output);&#xA;&#xA;        free(filepath);&#xA;    }&#xA;&#xA;

    &#xA;

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

    &#xA;

  • corrupted video after concat parts of captured RTSP stream with FFMPEG

    11 décembre 2022, par 555Russich

    Target : capture rtsp stream with sound from intercom camera and save it as 1hour duration video

    &#xA;


    &#xA;

    URL for rtsp stream is updаting every 2 minutes, but i need to get parts with 1hour duration. So i see only solution to concatenate 2 minutes videos. It's required time between capturing stream parts to get response from server and reconnect with another url

    &#xA;


    &#xA;

    First i tried opencv. It's not working with sound

    &#xA;


    &#xA;

    Then i started using ffmpeg :

    &#xA;

    Capturing stream :

    &#xA;

    ffmpeg -rtsp_transport tcp -i  2min_part.mp4&#xA;

    &#xA;

    Concatenating :

    &#xA;

    ffmpeg -safe 0 -f concat -i parts_list.txt -c copy concatenated_1.mp4&#xA;

    &#xA;

    in stdout getting Non-monotonous DTS in output stream :

    &#xA;

    [mp4 @ 0x560c12d80bc0] Non-monotonous DTS in output stream 0:0; previous: 57400952, current: 41462297; changing to 57400953. This may result in incorrect timestamps in the output file.&#xA;[mp4 @ 0x560c12d80bc0] Non-monotonous DTS in output stream 0:0; previous: 57400953, current: 41462809; changing to 57400954. This may result in incorrect timestamps in the output file.&#xA;[mp4 @ 0x560c12d80bc0] Non-monotonous DTS in output stream 0:0; previous: 57400954, current: 41463321; changing to 57400955. This may result in incorrect timestamps in the output file.&#xA;...&#xA;

    &#xA;

    After opening video in media players i see that from one second video is stopped, but sound is going on. Interesting part that with every new opening this second (starting from video stops) changes

    &#xA;


    &#xA;

    Then i tried this solution :

    &#xA;

    ffmpeg -safe 0 -f concat -segment_time_metadata 1 -i parts_list.txt -vf select=concatdec_select -af aselect=concatdec_select,aresample=async=1 concatenated_2.mp4&#xA;

    &#xA;

    No Non-monotonous DTS wаrnings, but video is still corrupted like first. Also this solution requires a lot of CPU while first concatenating method is very fast.

    &#xA;


    &#xA;

    Question : How to do concatenating and get not corrupted video ? May be i need to configure capturing options to simply use concatenating with -c copy ?

    &#xA;

    parts of videos and concatenated

    &#xA;

    using exiftool concatenated_1.mp4 i see that :

    &#xA;

    Duration                        : 1:17:44&#xA;Track Duration                  : 1:17:44&#xA;Media Duration                  : 0:53:59&#xA;

    &#xA;