Recherche avancée

Médias (1)

Mot : - Tags -/intégration

Autres articles (87)

  • 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" ;

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (3835)

  • Specify timestamp in ffmpeg video segment command

    25 mars 2019, par Soumya

    I have a continuous RTSP stream coming from a camera over the network.
    I want to dump the stream but in video files of length 1 min each.

    I an using the following command

    ffmpeg -i "rtsp://user:pass@example.com"  -f mp4 -r 12 -s 640x480 -ar 44100 \
    -ac 1 -segment_time 60 -segment_format mp4 "out%03d.mp4"

    The name of the files being created are of the form out001.mp4, out002.mp4, etc.

    I want to include the timestamp (hour and minute) in the name of the file segments eg. 09-30.mp4, 09-31.mp4, etc.

    If it is mandatory to provide a serial number for the segment, is it possible to get something like 09-30-001.mp4, 09-31-002.mp4 ?

  • Problem opening xvid264 with avcodec_alloc_context(NULL)

    12 juillet 2024, par user3763774

    I want to multiplex audio and video together using the ffmpeg encoding library with xvid264rgb codec. I can open the codec when I create the context specifying that codec, but not if I use NULL for the argument with allocate context. My understanding is I need to use NULL so I can open the audio codec as well.

    


    In the example, the first open works with codec indicated in the allocate context. The second doesn't.

    


    #include &#xA;#include &#xA;#include &#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#define WIDTH 400&#xA;#define HEIGHT 300&#xA;&#xA;const AVCodec *videocodec;&#xA;&#xA;bool init_video_encoder(AVCodecContext *c, int width, int height) {&#xA;    int ret;&#xA;    &#xA;    const AVRational tb_rat = {1, 30};&#xA;    const AVRational fr_rat = {30, 1};&#xA;&#xA;    fprintf(stderr, "init video encoder\n");&#xA;    // video&#xA;    //fprintf(stderr, "speed= %d \n", videocodec->speed);&#xA;    c->bit_rate = 400000;&#xA;    c->width = width;&#xA;    c->height = height;&#xA;    c->time_base = tb_rat;&#xA;    c->framerate = fr_rat;&#xA;    c->gop_size = 10;&#xA;    c->max_b_frames = 1;&#xA;    c->pix_fmt = AV_PIX_FMT_RGB24;&#xA;    if( videocodec->id == AV_CODEC_ID_H264 ) &#xA;        av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;        &#xA;    ret = avcodec_open2(c, videocodec, NULL);&#xA;    if( ret &lt; 0 ) {&#xA;        fprintf(stderr, "failure to open codec: %s\n", av_err2str(ret));&#xA;        return false;&#xA;    }&#xA;    //avcodec_free_context(&amp;c);&#xA;    return true;&#xA;}&#xA;&#xA;int main(int argc, char **argv) {&#xA;&#xA;    AVCodecContext *context = NULL;&#xA;&#xA;    videocodec = avcodec_find_encoder_by_name("libx264rgb");&#xA;    if( videocodec == NULL ) {&#xA;        fprintf(stderr, "video encoder &#x27;libx264rgb&#x27; not found");&#xA;        exit;&#xA;    }&#xA;&#xA;    context = avcodec_alloc_context3(videocodec);&#xA;    if( context == NULL ) {&#xA;        fprintf(stderr, "could not allocate context with codec");&#xA;        return false;&#xA;    }&#xA;    if( init_video_encoder( context, WIDTH, HEIGHT ) ) &#xA;        fprintf(stderr, " success initializing video encoder case one\n");&#xA;    else&#xA;        fprintf(stderr, " failure to initialize video encoder case one\n");&#xA;    avcodec_close( context );&#xA;&#xA;    context = avcodec_alloc_context3(NULL);&#xA;    if( context == NULL ) {&#xA;        fprintf(stderr, "could not allocate context without codec");&#xA;        return false;&#xA;    }&#xA;    if( init_video_encoder( context, WIDTH, HEIGHT ) ) &#xA;        fprintf(stderr, " success initializing video encoder case two\n");&#xA;    else&#xA;        fprintf(stderr, " failure to initialize video encoder case two\n");&#xA;    avcodec_close( context );&#xA;}&#xA;

    &#xA;

    Here is the error message :

    &#xA;

    broken ffmpeg default settings detected&#xA;use an encoding preset (e.g. -vpre medium)&#xA;preset usage: -vpre <speed> -vpre <profile>&#xA;speed presets are listed in x264 --help&#xA;profile is optional; x264 defaults to high&#xA;failure to open codec: Generic error in an external library&#xA;failure to initialize video encoder case two&#xA;</profile></speed>

    &#xA;

    Is this the right approach to use ? How do I set the encoding preset ? The code appears already to do that.

    &#xA;

  • Transcoding Videos Using FastAPI and ffmpeg

    15 janvier 2024, par Sanji Vinsmoke

    I created an API using Fast API where I upload one or more videos, may specify the resolution of transcoding, and the output is transcoded video from 240p upto the resolution I specified. Available resolutions are - 240p, 360p, 480p, 720p, 1080p. I used ffmpeg for the transcoding job.

    &#xA;

    The problem that is bugging me since yesterday is that, after deploying to the s3 bucket and adding the url for the index.m3u8 file in any hls player, the video is blank. Only the audio and streaming are working. I have tried tweaking with the parameters in the ffmpeg parameters, the error is still there. I tried manually transcoding a video file locally, even that video's index.m3u8 file is blank in live version. I added the relevant codes for this project. I implemented each feature one by one, but I simply cannot find the reason why the video is totally blank on live.

    &#xA;

    def transcode_video(input_path, output_folder, res, video_id, video_resolution, progress_bar=None):&#xA;    # Transcode the video into .m3u8 format with segment format&#xA;    output_path = os.path.join(output_folder, f"{res}_{video_id}.m3u8")&#xA;&#xA;    # Use subprocess for command execution&#xA;    chunk_size = 1 # Specify the desired chunk size in seconds&#xA;&#xA;    transcode_command = [&#xA;        "ffmpeg", "-i", input_path, "-vf", f"scale={res}:&#x27;trunc(ow/a/2)*2&#x27;", "-c:a", "aac", "-strict", "-2",&#xA;        "-f", "segment", "-segment_time", str(chunk_size), "-segment_list", output_path, "-segment_format", "ts",&#xA;        f"{output_path.replace(&#x27;.m3u8&#x27;, &#x27;_%03d.ts&#x27;)}"&#xA;    ]&#xA;&#xA;    try:&#xA;        subprocess.run(transcode_command, check=True, capture_output=True)&#xA;    except subprocess.CalledProcessError as e:&#xA;        print(f"Error during transcoding: {e}")&#xA;        print(f"FFmpeg error output: {e.stderr}")&#xA;        # Continue with the next video even if an error occurs&#xA;        return False&#xA;&#xA;    # Update the progress bar&#xA;    if progress_bar:&#xA;        progress_bar.update(1)&#xA;    return True&#xA;&#xA;&#xA;def get_bandwidth(resolution):&#xA;    # Define a simple function to calculate bandwidth based on resolution&#xA;    resolutions_and_bandwidths = {&#xA;        240: 400000,&#xA;        360: 850000,&#xA;        480: 1400000,&#xA;        720: 2500000,&#xA;        1080: 4500000,&#xA;    }&#xA;    &#xA;    return resolutions_and_bandwidths.get(resolution, 0)&#xA;def create_index_m3u8(video_id, resolutions_to_transcode):&#xA;    # Write the index.m3u8 file&#xA;    index_m3u8_path = os.path.join(OUTPUT_FOLDER, f"index_{video_id}.m3u8")&#xA;    with open(index_m3u8_path, "w") as index_file:&#xA;        index_file.write("#EXTM3U\n")&#xA;        index_file.write("#EXT-X-VERSION:3\n")&#xA;&#xA;        for res in resolutions_to_transcode:&#xA;            aspect_ratio = 16 / 9&#xA;            folder_name = f"{res}p_{video_id}"&#xA;            resolution_file_name = f"{res}_{video_id}.m3u8"&#xA;            index_file.write(&#xA;                f"#EXT-X-STREAM-INF:BANDWIDTH={get_bandwidth(res)},RESOLUTION={int(res * aspect_ratio)}x{res}\n{folder_name}/{resolution_file_name}\n"&#xA;            )&#xA;

    &#xA;

    I tried reducing or increasing chunk size, adding codecs, setting up dimensions. Where am I doing wrong ?

    &#xA;

    My python version is 3.8.18, ffmpeg version-4.4.4, ffmpeg-python version-0.2.0

    &#xA;