Recherche avancée

Médias (0)

Mot : - Tags -/flash

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (47)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

Sur d’autres sites (8958)

  • How to add subtitles to the encoded video using ffmpeg ?

    14 novembre 2019, par geo-freak

    I am trying to add my srt file to the video using the options which were answered here before. My input file has captions in it by default. I tried in different ways to get the captions enabled in my encoded video. Below are the commands I used.

    ffmpeg  -i input.ts -i captions.srt -b:a 32000 -ar 48000  -force_key_frames 'expr:gte(t,n_forced*3)' -acodec libfaac -hls_flags single_file -hls_list_size 0 -hls_time 3 -vcodec libx264 -s 320x240 -b:v 512000 -maxrate 512000 -c:s mov_text outfile.ts

    But I couldn’t see the captions after I see the mediainfo of the encoded file. You can see the log file of my command.

    [mpegts @ 0x56412e67b0c0] max_analyze_duration 5000000 reached at 5024000 microseconds st:1
    input.ts FPS 29.970030 1
    Input #0, mpegts, from 'input.ts':
     Duration: 00:03:00.07, start: 1.400000, bitrate: 2172 kb/s
     Program 1
       Metadata:
         service_name    : Service01
         service_provider: FFmpeg
       Stream #0:0[0x100]: Video: mpeg2video (Main), 1 reference frame ([2][0][0][0] / 0x0002), yuv420p(tv), 704x480 [SAR 10:11 DAR 4:3], Closed Captions, max. 15000 kb/s,
    29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
       Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 192 kb/s
    Input #1, srt, from 'captions.srt':
     Duration: N/A, bitrate: N/A
       Stream #1:0: Subtitle: subrip
    [graph 0 input from stream 0:0 @ 0x56412e678540] w:704 h:480 pixfmt:yuv420p tb:1/90000 fr:30000/1001 sar:10/11 sws_param:flags=2
    [scaler for output stream 0:0 @ 0x56412e9caac0] w:320 h:240 flags:'bicubic' interl:0
    [scaler for output stream 0:0 @ 0x56412e9caac0] w:704 h:480 fmt:yuv420p sar:10/11 -> w:320 h:240 fmt:yuv420p sar:1/1 flags:0x4
    [graph 1 input from stream 0:1 @ 0x56412e9f74e0] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
    [audio format for output stream 0:1 @ 0x56412e9f7b40] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format
    for output stream 0:1'                                                                                                                                              
    [auto-inserted resampler 0 @ 0x56412e9f9f20] ch:2 chl:stereo fmt:fltp r:48000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
    [libx264 @ 0x56412e9bb8c0] VBV maxrate specified, but no bufsize, ignored
    [libx264 @ 0x56412e9bb8c0] using SAR=1/1
    [libx264 @ 0x56412e9bb8c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    [libx264 @ 0x56412e9bb8c0] profile High, level 2.0
    [mpegts @ 0x56412e9ba5a0] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
    Output #0, mpegts, to 'my_encoded_all-3.ts':
     Metadata:
       encoder         : Lavf57.25.100
       Stream #0:0: Video: h264 (libx264), -1 reference frame, yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 512 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
       Metadata:
         encoder         : Lavc57.24.102 libx264
       Side data:
         unknown side data type 10 (24 bytes)
       Stream #0:1(eng): Audio: aac (libfaac), 48000 Hz, stereo, s16, 32 kb/s
       Metadata:
         encoder         : Lavc57.24.102 libfaac
       Stream #0:2(eng): Subtitle: subrip (srt), 320x240
           Metadata:
             encoder         : Lavc57.24.102 srt
       Stream mapping:
         Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
         Stream #0:1 -> #0:1 (ac3 (native) -> aac (libfaac))
         Stream #1:0 -> #0:2 (subrip (srt) -> subrip (srt))
    Press [q] to stop, [?] for help
    [scaler for output stream 0:0 @ 0x56412e9caac0] w:704 h:480 fmt:yuv420p sar:40/33 -> w:320 h:240 fmt:yuv420p sar:4/3 flags:0x4
    No more output streams to write to, finishing.e=00:02:58.85 bitrate= 658.4kbits/s speed=13.2x
    frame= 5377 fps=385 q=-1.0 Lsize=   16672kB time=00:59:16.18 bitrate=  38.4kbits/s speed= 255x
    video:11401kB audio:1410kB subtitle:446kB other streams:0kB global headers:0kB muxing overhead: 25.753614%
    Input file #0 (input.ts):
     Input stream #0:0 (video): 5380 packets read (40279443 bytes); 5377 frames decoded;
     Input stream #0:1 (audio): 5625 packets read (4320000 bytes); 5625 frames decoded (8640000 samples);
     Total: 11005 packets (44599443 bytes) demuxed
    Input file #1 (captions.srt):
     Input stream #1:0 (subtitle): 10972 packets read (447147 bytes); 10972 frames decoded;
     Total: 10972 packets (447147 bytes) demuxed
    Output file #0 (output.ts):
     Output stream #0:0 (video): 5377 frames encoded; 5377 packets muxed (11675098 bytes);
     Output stream #0:1 (audio): 8438 frames encoded (8640000 samples); 8439 packets muxed (1444109 bytes);
     Output stream #0:2 (subtitle): 10972 frames encoded; 10972 packets muxed (456619 bytes);
     Total: 24788 packets (13575826 bytes) muxed
    [libx264 @ 0x56412e9bb8c0] frame I:81    Avg QP:15.08  size: 16370
    [libx264 @ 0x56412e9bb8c0] frame P:2312  Avg QP:17.77  size:  3393
    [libx264 @ 0x56412e9bb8c0] frame B:2984  Avg QP:22.38  size:   839
    [libx264 @ 0x56412e9bb8c0] consecutive B-frames: 20.6% 13.2%  9.4% 56.8%
    [libx264 @ 0x56412e9bb8c0] mb I  I16..4: 11.6% 37.0% 51.4%
    [libx264 @ 0x56412e9bb8c0] mb P  I16..4:  1.2%  3.2%  2.4%  P16..4: 33.7% 18.0% 15.7%  0.0%  0.0%    skip:25.6%
    [libx264 @ 0x56412e9bb8c0] mb B  I16..4:  0.2%  0.3%  0.2%  B16..8: 30.7%  9.2%  3.2%  direct: 5.1%  skip:51.1%  L0:33.6% L1:44.5% BI:21.9%
    [libx264 @ 0x56412e9bb8c0] final ratefactor: 16.76
    [libx264 @ 0x56412e9bb8c0] 8x8 transform intra:43.0% inter:49.8%
    [libx264 @ 0x56412e9bb8c0] coded y,uvDC,uvAC intra: 77.9% 85.1% 68.8% inter: 22.9% 21.7% 6.0%
    [libx264 @ 0x56412e9bb8c0] i16 v,h,dc,p: 30% 38%  5% 26%
    [libx264 @ 0x56412e9bb8c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 23% 18%  4%  5%  7%  6%  7%  8%
    [libx264 @ 0x56412e9bb8c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 23% 11%  5%  6%  8%  6%  7%  6%
    [libx264 @ 0x56412e9bb8c0] i8c dc,h,v,p: 46% 24% 21%  8%
    [libx264 @ 0x56412e9bb8c0] Weighted P-Frames: Y:4.2% UV:2.6%
    [libx264 @ 0x56412e9bb8c0] ref P L0: 73.3% 10.9% 11.1%  4.5%  0.1%
    [libx264 @ 0x56412e9bb8c0] ref B L0: 92.1%  6.3%  1.6%
    [libx264 @ 0x56412e9bb8c0] ref B L1: 97.4%  2.6%

    I found no issues in encoding but I couldn’t see the captions enabled in my output encoded video. I played it in my VLC player. No tracks for subtitles.

    Can’t we add the subtitles to a video while encoding ?

    Any help in achieving this would be appreciated.

  • x264 encoded frames into a mp4 container with ffmpeg API

    10 septembre 2019, par PJD

    I'm struggling with understanding what is and what is not needed in getting my already encoded x264 frames into a video container file using ffmpeg's libavformat API.

    



    My current program will get the x264 frames like this -

    



    while( x264_encoder_delayed_frames( h ) )
{
    printf("Writing delayed frame %u\n", delayed_frame_counter++);
    i_frame_size = x264_encoder_encode( h, &nal, &i_nal, NULL, &pic_out );
    if( i_frame_size < 0 ) {
            printf("Failed to encode a delayed x264 frame.\n");
            return ERROR;
        }
    else if( i_frame_size )
    {
        if( !fwrite(nal->p_payload, i_frame_size, 1, video_file_ptr) ) {
            printf("Failed to write a delayed x264 frame.\n");
            return ERROR;
        }
    }
}


    



    If I use the CLI to the ffmpeg binary, I can put these frames into a container using :

    



    ffmpeg -i "raw_frames.h264" -c:v copy -f mp4 "video.mp4"


    



    I would like to code this function into my program using the libavformat API though. I'm a little stuck in the concepts and the order on which each ffmpeg function is needed to be called.

    



    So far I have written :

    



            mAVOutputFormat = av_guess_format("gen_vid.mp4", NULL, NULL);
        printf("Guessed format\n");

        int ret = avformat_alloc_output_context2(&mAVFormatContext, NULL, NULL, "gen_vid.mp4");
        printf("Created context = %d\n", ret);
        printf("Format = %s\n", mAVFormatContext->oformat->name);

        mAVStream = avformat_new_stream(mAVFormatContext, 0);
        if (!mAVStream) {
            printf("Failed allocating output stream\n");
        } else {
            printf("Allocated stream.\n");
        }

        mAVCodecParameters = mAVStream->codecpar;
        if (mAVCodecParameters->codec_type != AVMEDIA_TYPE_AUDIO &&
            mAVCodecParameters->codec_type != AVMEDIA_TYPE_VIDEO &&
            mAVCodecParameters->codec_type != AVMEDIA_TYPE_SUBTITLE) {
            printf("Invalid codec?\n");
        }

        if (!(mAVFormatContext->oformat->flags & AVFMT_NOFILE)) {
            ret = avio_open(&mAVFormatContext->pb, "gen_vid.mp4", AVIO_FLAG_WRITE);
            if (ret < 0) {
              printf("Could not open output file '%s'", "gen_vid.mp4");
            }
          }

        ret = avformat_write_header(mAVFormatContext, NULL);
        if (ret < 0) {
          printf("Error occurred when opening output file\n");
        }


    



    This will print out :

    



    Guessed format
Created context = 0
Format = mp4
Allocated stream.
Invalid codec?
[mp4 @ 0x55ffcea2a2c0] Could not find tag for codec none in stream #0, codec not currently supported in container
Error occurred when opening output file


    



    How can I make sure the codec type is set correctly for my video ?
Next I need to somehow point my mAVStream to use my x264 frames - advice would be great.

    



    Update 1 :
So I've tried to set the H264 codec, so the codec's meta-data is available. I seem to hit 2 newer issues now.
1) It cannot find the device and therefore cannot configure the encoder.
2) I get the "dimensions not set".

    



    mAVOutputFormat = av_guess_format("gen_vid.mp4", NULL, NULL);
printf("Guessed format\n");

// MUST allocate the media file format context. 
int ret = avformat_alloc_output_context2(&mAVFormatContext, NULL, NULL, "gen_vid.mp4");
printf("Created context = %d\n", ret);
printf("Format = %s\n", mAVFormatContext->oformat->name);

// Even though we already have encoded the H264 frames using x264,
// we still need the codec's meta-data.
const AVCodec *mAVCodec;
mAVCodec = avcodec_find_encoder(AV_CODEC_ID_H264);
if (!mAVCodec) {
    fprintf(stderr, "Codec '%s' not found\n", "H264");
    exit(1);
}
mAVCodecContext = avcodec_alloc_context3(mAVCodec);
if (!mAVCodecContext) {
    fprintf(stderr, "Could not allocate video codec context\n");
    exit(1);
}
printf("Codec context allocated with defaults.\n");
/* put sample parameters */
mAVCodecContext->bit_rate = 400000;
mAVCodecContext->width = width;
mAVCodecContext->height = height;
mAVCodecContext->time_base = (AVRational){1, 30};
mAVCodecContext->framerate = (AVRational){30, 1};
mAVCodecContext->gop_size = 10;
mAVCodecContext->level = 31;
mAVCodecContext->max_b_frames = 1;
mAVCodecContext->pix_fmt = AV_PIX_FMT_NV12;

av_opt_set(mAVCodecContext->priv_data, "preset", "slow", 0);
printf("Set codec parameters.\n");

// Initialize the AVCodecContext to use the given AVCodec.
avcodec_open2(mAVCodecContext, mAVCodec, NULL);            

// Add a new stream to a media file. Must be called before
// calling avformat_write_header().
mAVStream = avformat_new_stream(mAVFormatContext, mAVCodec);
if (!mAVStream) {
    printf("Failed allocating output stream\n");
} else {
    printf("Allocated stream.\n");
}

// TODO How should codecpar be set?
mAVCodecParameters = mAVStream->codecpar;
if (mAVCodecParameters->codec_type != AVMEDIA_TYPE_AUDIO &&
    mAVCodecParameters->codec_type != AVMEDIA_TYPE_VIDEO &&
    mAVCodecParameters->codec_type != AVMEDIA_TYPE_SUBTITLE) {
    printf("Invalid codec?\n");
}

if (!(mAVFormatContext->oformat->flags & AVFMT_NOFILE)) {
    ret = avio_open(&mAVFormatContext->pb, "gen_vid.mp4", AVIO_FLAG_WRITE);
    if (ret < 0) {
      printf("Could not open output file '%s'", "gen_vid.mp4");
    }
  }
printf("Called avio_open()\n");

// MUST write a header.
ret = avformat_write_header(mAVFormatContext, NULL);
if (ret < 0) {
  printf("Error occurred when opening output file (writing header).\n");
}


    



    Now I am getting this output -

    



    Guessed format
Created context = 0
Format = mp4
Codec context allocated with defaults.
Set codec parameters.
[h264_v4l2m2m @ 0x556460344b40] Could not find a valid device
[h264_v4l2m2m @ 0x556460344b40] can't configure encoder
Allocated stream.
Invalid codec?
Called avio_open()
[mp4 @ 0x5564603442c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp4 @ 0x5564603442c0] dimensions not set
Error occurred when opening output file (writing header).


    


  • x264 encoded frames into a mp4 container with ffmpeg API

    10 septembre 2019, par PJD

    I'm struggling with understanding what is and what is not needed in getting my already encoded x264 frames into a video container file using ffmpeg's libavformat API.

    



    My current program will get the x264 frames like this -

    



    while( x264_encoder_delayed_frames( h ) )
{
    printf("Writing delayed frame %u\n", delayed_frame_counter++);
    i_frame_size = x264_encoder_encode( h, &nal, &i_nal, NULL, &pic_out );
    if( i_frame_size < 0 ) {
            printf("Failed to encode a delayed x264 frame.\n");
            return ERROR;
        }
    else if( i_frame_size )
    {
        if( !fwrite(nal->p_payload, i_frame_size, 1, video_file_ptr) ) {
            printf("Failed to write a delayed x264 frame.\n");
            return ERROR;
        }
    }
}


    



    If I use the CLI to the ffmpeg binary, I can put these frames into a container using :

    



    ffmpeg -i "raw_frames.h264" -c:v copy -f mp4 "video.mp4"


    



    I would like to code this function into my program using the libavformat API though. I'm a little stuck in the concepts and the order on which each ffmpeg function is needed to be called.

    



    So far I have written :

    



            mAVOutputFormat = av_guess_format("gen_vid.mp4", NULL, NULL);
        printf("Guessed format\n");

        int ret = avformat_alloc_output_context2(&mAVFormatContext, NULL, NULL, "gen_vid.mp4");
        printf("Created context = %d\n", ret);
        printf("Format = %s\n", mAVFormatContext->oformat->name);

        mAVStream = avformat_new_stream(mAVFormatContext, 0);
        if (!mAVStream) {
            printf("Failed allocating output stream\n");
        } else {
            printf("Allocated stream.\n");
        }

        mAVCodecParameters = mAVStream->codecpar;
        if (mAVCodecParameters->codec_type != AVMEDIA_TYPE_AUDIO &&
            mAVCodecParameters->codec_type != AVMEDIA_TYPE_VIDEO &&
            mAVCodecParameters->codec_type != AVMEDIA_TYPE_SUBTITLE) {
            printf("Invalid codec?\n");
        }

        if (!(mAVFormatContext->oformat->flags & AVFMT_NOFILE)) {
            ret = avio_open(&mAVFormatContext->pb, "gen_vid.mp4", AVIO_FLAG_WRITE);
            if (ret < 0) {
              printf("Could not open output file '%s'", "gen_vid.mp4");
            }
          }

        ret = avformat_write_header(mAVFormatContext, NULL);
        if (ret < 0) {
          printf("Error occurred when opening output file\n");
        }


    



    This will print out :

    



    Guessed format
Created context = 0
Format = mp4
Allocated stream.
Invalid codec?
[mp4 @ 0x55ffcea2a2c0] Could not find tag for codec none in stream #0, codec not currently supported in container
Error occurred when opening output file


    



    How can I make sure the codec type is set correctly for my video ?
Next I need to somehow point my mAVStream to use my x264 frames - advice would be great.

    



    Update 1 :
So I've tried to set the H264 codec, so the codec's meta-data is available. I seem to hit 2 newer issues now.
1) It cannot find the device and therefore cannot configure the encoder.
2) I get the "dimensions not set".

    



    mAVOutputFormat = av_guess_format("gen_vid.mp4", NULL, NULL);
printf("Guessed format\n");

// MUST allocate the media file format context. 
int ret = avformat_alloc_output_context2(&mAVFormatContext, NULL, NULL, "gen_vid.mp4");
printf("Created context = %d\n", ret);
printf("Format = %s\n", mAVFormatContext->oformat->name);

// Even though we already have encoded the H264 frames using x264,
// we still need the codec's meta-data.
const AVCodec *mAVCodec;
mAVCodec = avcodec_find_encoder(AV_CODEC_ID_H264);
if (!mAVCodec) {
    fprintf(stderr, "Codec '%s' not found\n", "H264");
    exit(1);
}
mAVCodecContext = avcodec_alloc_context3(mAVCodec);
if (!mAVCodecContext) {
    fprintf(stderr, "Could not allocate video codec context\n");
    exit(1);
}
printf("Codec context allocated with defaults.\n");
/* put sample parameters */
mAVCodecContext->bit_rate = 400000;
mAVCodecContext->width = width;
mAVCodecContext->height = height;
mAVCodecContext->time_base = (AVRational){1, 30};
mAVCodecContext->framerate = (AVRational){30, 1};
mAVCodecContext->gop_size = 10;
mAVCodecContext->level = 31;
mAVCodecContext->max_b_frames = 1;
mAVCodecContext->pix_fmt = AV_PIX_FMT_NV12;

av_opt_set(mAVCodecContext->priv_data, "preset", "slow", 0);
printf("Set codec parameters.\n");

// Initialize the AVCodecContext to use the given AVCodec.
avcodec_open2(mAVCodecContext, mAVCodec, NULL);            

// Add a new stream to a media file. Must be called before
// calling avformat_write_header().
mAVStream = avformat_new_stream(mAVFormatContext, mAVCodec);
if (!mAVStream) {
    printf("Failed allocating output stream\n");
} else {
    printf("Allocated stream.\n");
}

// TODO How should codecpar be set?
mAVCodecParameters = mAVStream->codecpar;
if (mAVCodecParameters->codec_type != AVMEDIA_TYPE_AUDIO &&
    mAVCodecParameters->codec_type != AVMEDIA_TYPE_VIDEO &&
    mAVCodecParameters->codec_type != AVMEDIA_TYPE_SUBTITLE) {
    printf("Invalid codec?\n");
}

if (!(mAVFormatContext->oformat->flags & AVFMT_NOFILE)) {
    ret = avio_open(&mAVFormatContext->pb, "gen_vid.mp4", AVIO_FLAG_WRITE);
    if (ret < 0) {
      printf("Could not open output file '%s'", "gen_vid.mp4");
    }
  }
printf("Called avio_open()\n");

// MUST write a header.
ret = avformat_write_header(mAVFormatContext, NULL);
if (ret < 0) {
  printf("Error occurred when opening output file (writing header).\n");
}


    



    Now I am getting this output -

    



    Guessed format
Created context = 0
Format = mp4
Codec context allocated with defaults.
Set codec parameters.
[h264_v4l2m2m @ 0x556460344b40] Could not find a valid device
[h264_v4l2m2m @ 0x556460344b40] can't configure encoder
Allocated stream.
Invalid codec?
Called avio_open()
[mp4 @ 0x5564603442c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp4 @ 0x5564603442c0] dimensions not set
Error occurred when opening output file (writing header).