Recherche avancée

Médias (0)

Mot : - Tags -/flash

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

Autres articles (57)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

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

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

Sur d’autres sites (6760)

  • Adding audio to video without re encoding [migrated]

    4 mars 2015, par user1503606

    I am looking to add audio to a video without having to re encode the two pieces.

    I have looked at a few questions on stack overflow followed the answers and i still cant seemed to get it to work, if anyone can spot what i am missing please help.

    I am running this code.

    ffmpeg -i DJ_Mes_Rescue-Some_Day-Guesthouse_Music.mp3 -i output.mp4 -map 0:0 -map 1:0 -acodec copy -vcodec copy -shortest edit2.mp4

    Now from what i understand ffmpeg is mapping the stream over the top ffmpeg info for the audio track is.

    Input #0, mp3, from 'DJ_Mes_Rescue-Some_Day-Guesthouse_Music.mp3':
     Metadata:
       encoder         : LAME 64bits version 3.98.4 (http://www.mp3dev.org/)
       title           : Some Day
       artist          : DJ Mes, Rescue
       TLEN            : 378750
       genre           : House
       track           : 1/0
       date            : 2015
     Duration: 00:06:18.80, start: 0.025056, bitrate: 320 kb/s
       Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
       Metadata:
         encoder         : LAME3.98r
       Side data:
         replaygain: track gain - -10.100000, track peak - unknown, album gain - unknown, album peak - unknown,
       Stream #0:1: Video: png, rgb24, 225x225, 90k tbr, 90k tbn, 90k tbc
       Metadata:
         title           :
         comment         : Other

    And for the video it is.

    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf56.15.102
     Duration: 00:00:49.46, start: 0.046440, bitrate: 566 kb/s
       Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 568x320, 462 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
       Metadata:
         handler_name    : SoundHandler

    So i am mapping the stream 0:0 from the audio file to 1:0 from the video file, but all i seem to get is a video with no audio.

    Can someone help ?

    UPDATE whole output added

    ffmpeg -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -i output.mp4 -c copy -map 0:0 -map 1:0 -shortest mixed.mp4
    ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
     built on Jan 12 2015 10:15:06 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
     configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
     libavutil      54. 15.100 / 54. 15.100
     libavcodec     56. 13.100 / 56. 13.100
     libavformat    56. 15.102 / 56. 15.102
     libavdevice    56.  3.100 / 56.  3.100
     libavfilter     5.  2.103 /  5.  2.103
     libavresample   2.  1.  0 /  2.  1.  0
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    Input #0, mp3, from 'Saison-Please_Don%27t_Go-Guesthouse_Music.mp3':
     Metadata:
       encoder         : LAME 64bits version 3.98.4 (http://www.mp3dev.org/)
       title           : Please Donât Go
       artist          : Saison
       TLEN            : 408492
       genre           : House
       track           : 1/0
       date            : 2015
     Duration: 00:06:48.53, start: 0.025056, bitrate: 320 kb/s
       Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
       Metadata:
         encoder         : LAME3.98r
       Side data:
         replaygain: track gain - -8.400000, track peak - unknown, album gain - unknown, album peak - unknown,
       Stream #0:1: Video: png, rgb24, 225x225, 90k tbr, 90k tbn, 90k tbc
       Metadata:
         title           :
         comment         : Other
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf56.15.102
     Duration: 00:00:49.46, start: 0.046440, bitrate: 566 kb/s
       Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 568x320, 462 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    Output #0, mp4, to 'mixed.mp4':
     Metadata:
       date            : 2015
       title           : Please Donât Go
       artist          : Saison
       TLEN            : 408492
       genre           : House
       track           : 1/0
       encoder         : Lavf56.15.102
       Stream #0:0: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, stereo, 320 kb/s
       Metadata:
         encoder         : LAME3.98r
       Side data:
         replaygain: track gain - -8.400000, track peak - unknown, album gain - unknown, album peak - unknown,
       Stream #0:1(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 568x320, q=2-31, 462 kb/s, 30 fps, 15360 tbn, 15360 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
    Stream mapping:
     Stream #0:0 -> #0:0 (copy)
     Stream #1:0 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame= 1481 fps=0.0 q=-1.0 Lsize=    4759kB time=00:00:49.34 bitrate= 790.0kbits/s    
    video:2785kB audio:1929kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.960839%

    ANOTHER UPDATE :

    So i have tried the following

    ffmpeg -i 3.mp4 -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -map 0:0 -map 0:1 -map 1:0 -map 2:0 -c:v copy -c:a copy 23.mp4

    and if i run.

    ffmpeg -i 23.mp4

    You can see the streams/audio has been added but it is not playing ?

    Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf56.15.102
     Duration: 00:06:48.53, start: 0.025057, bitrate: 713 kb/s
       Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 568x320, 462 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
       Stream #0:2(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 319 kb/s
       Metadata:
         handler_name    : SoundHandler
       Stream #0:3(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 319 kb/s
       Metadata:
         handler_name    : SoundHandler

    ONE MORE UPDATE THIS SEEMS TO WORK :

    ffmpeg -i 3.mp4 -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -map 0:0 -map 0:1 -map 1:0  -c:v copy -c:a copy 234.mp4 && ffmpeg -i 234.mp4 -map 0:0 -map 0:2 -acodec copy -vcodec copy new_file3.mp4
  • FFmpeg c++ H264 decoding error

    12 avril 2015, par Yoohoo

    I have a program which capture video from webcam, encode with ffmpeg, encoded packet then write to buffer. At the receiver side, read from buffer decode with ffmpeg and play.

    Now I merge sender and receiver in one program for testing. It works fine with AV_CODEC_ID_MPEG1VIDEO, but when I change the ffmpeg codec to AV_CODEC_ID_H264, at the decoding progress, it shows error :

    error

    The whole program is here FYI, I made a loop to let the whole progress run twice.

    What is the cause of the error, is there anything special for H264 ? Thanks in advance !

    #include

    extern "C" {

    #include <libavutil></libavutil>opt.h>
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>common.h>
    #include <libavutil></libavutil>imgutils.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>samplefmt.h>
    #include <libswscale></libswscale>swscale.h>
    #include "v4l2.h"
    }
    #include "opencv2/highgui/highgui.hpp"
    #include <iostream>

    using namespace cv;
    using namespace std;
    #define INBUF_SIZE 4096
    static uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];



    static AVCodec *codec;
    static AVCodecContext *c= NULL;
    static int  ret,   got_output;
    static int frame_count;
    static FILE *f;

    static AVPacket pkt;
    static AVFrame *frame;
    static AVFrame *frameDecode;
    static AVFrame *framergb;
    static uint8_t endcode[] = { 0, 0, 1, 0xb7 };
    static AVPacket avpkt;
    int totalSize=0;

    #define SUBSITY     3



    static int decode_write_frame(AVCodecContext *avctx,
                             AVFrame *frame, int *frame_count, AVPacket *pkt, int last)
    {
    int len, got_frame;
    char buf[1024];
    struct SwsContext *convert_ctx;
    Mat m;
    AVFrame dst;

    len = avcodec_decode_video2(avctx, frame, &amp;got_frame, pkt);
    if (len &lt; 0) {
       fprintf(stderr, "Error while decoding frame %d\n", *frame_count);
       return len;
    }
    if (got_frame) {
       printf("Saving %s frame %3d\n", last ? "last " : "", *frame_count);
       fflush(stdout);

    int w = avctx->width;
    int h = avctx->height;

    /*convert AVFrame to opencv Mat frame*/

    m = cv::Mat(h, w, CV_8UC3);
    dst.data[0] = (uint8_t *)m.data;
    avpicture_fill( (AVPicture *)&amp;dst, dst.data[0], PIX_FMT_BGR24, w, h);

    enum PixelFormat src_pixfmt = (enum PixelFormat)frame->format;
    enum PixelFormat dst_pixfmt = PIX_FMT_BGR24;
    convert_ctx = sws_getContext(w, h, src_pixfmt, w, h, dst_pixfmt,
                       SWS_FAST_BILINEAR, NULL, NULL, NULL);

    if(convert_ctx == NULL) {
       fprintf(stderr, "Cannot initialize the conversion context!\n");
       exit(1);
    }

    sws_scale(convert_ctx, frame->data, frame->linesize, 0, h,
                       dst.data, dst.linesize);


       imshow("MyVideo", m);
       //video.write(m);
       waitKey(10); //wait next frame time


       (*frame_count)++;
    }
    if (pkt->data) {
       pkt->size -= len;
       pkt->data += len;
    }
    return 0;
    }


    static void video_decode_example(char *inbufout)
    {
    int bytes;
    uint8_t *buffer;

    av_init_packet(&amp;avpkt);


    memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);


    codec = avcodec_find_decoder(AV_CODEC_ID_H264);
    if (!codec) {
       fprintf(stderr, "Codec not found\n");
       exit(1);
    }

    c = avcodec_alloc_context3(codec);
    if (!c) {
       fprintf(stderr, "Could not allocate video codec context\n");
       exit(1);
    }

    if(codec->capabilities&amp;CODEC_CAP_TRUNCATED)
       c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */


    /* open it */
    if (avcodec_open2(c, codec, NULL) &lt; 0) {
       fprintf(stderr, "Could not open codec\n");
       exit(1);
    }


    frameDecode = avcodec_alloc_frame();
    if (!frameDecode) {
       fprintf(stderr, "Could not allocate video frame\n");
       exit(1);
    }


    bytes=avpicture_get_size(PIX_FMT_RGB24, CAMER_WIDTH, CAMER_HEIGHT);
    buffer=(uint8_t *)av_malloc(bytes*sizeof(uint8_t));
    avpicture_fill((AVPicture *)framergb, buffer, PIX_FMT_RGB24,
                   CAMER_WIDTH, CAMER_HEIGHT);*/

    frame_count = 0;

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"


    int size1=0;
    for(;;) {

       memcpy(inbuf,inbufout+size1,INBUF_SIZE);
       size1+=INBUF_SIZE;
       if (size1>(totalSize-INBUF_SIZE))
           break;
       avpkt.size=INBUF_SIZE;


       avpkt.data = inbuf;

       /*frame by frame process*/

       while (avpkt.size > 0)
           if (decode_write_frame(c, frameDecode, &amp;frame_count, &amp;avpkt, 0) &lt; 0)
               exit(1);
    }
    avpkt.data = NULL;
    avpkt.size = 0;
    decode_write_frame(c, frameDecode, &amp;frame_count, &amp;avpkt, 1);
    }
    static void init_video_encode(const char *filename, AVCodecID codec_id, int max_f)
    {

    printf("Encode video file %s\n", filename);

    /* find the mpeg1 video encoder */
    codec = avcodec_find_encoder(codec_id);
    if (!codec) {
       fprintf(stderr, "Codec not found\n");
       exit(1);
    }

    c = avcodec_alloc_context3(codec);
    if (!c) {
       fprintf(stderr, "Could not allocate video codec context\n");
       exit(1);
    }

    /* put sample parameters */
    c->bit_rate = 400000;
    /* resolution must be a multiple of two */
    c->width = 640;
    c->height = 480;
    /* frames per second */
    c->time_base= (AVRational){1,25};
    c->gop_size = 10; /* emit one intra frame every ten frames */
    c->max_b_frames=max_f;
    c->pix_fmt = AV_PIX_FMT_YUV420P;

    if(codec_id == AV_CODEC_ID_H264)
       av_opt_set(c->priv_data, "preset", "slow", 0);

    /* open it */
    if (avcodec_open2(c, codec, NULL) &lt; 0) {
       fprintf(stderr, "Could not open codec\n");
       exit(1);
    }

    frame = avcodec_alloc_frame();
    if (!frame) {
       fprintf(stderr, "Could not allocate video frame\n");
       exit(1);
    }
    frame->format = c->pix_fmt;
    frame->width  = c->width;
    frame->height = c->height;


    ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
                        c->pix_fmt, 32);

    /* get the delayed frames */
    if (ret &lt; 0) {
       fprintf(stderr, "Could not allocate raw picture buffer\n");
       exit(1);
    }

    printf("\n");
    }

    int video_encode(int frameNo,char *inbufout)
    {
    static int count = 0;
    static int i = 0;

    /* encode 1 frame of video */
    av_init_packet(&amp;pkt);
    pkt.data = NULL;    // packet data will be allocated by the encoder
    pkt.size = 0;
    //cout&lt;&lt;"\nBefore YUV\n";
    if(count == 0)
    read_yuv420(frame->data[0]);
    count ++;

    if(count == SUBSITY) {
    count = 0;
    }

    frame->pts = i++;

    /* encode the image */
    ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_output);
    if (ret &lt; 0) {
        fprintf(stderr, "Error encoding frame\n");
        return -1;
    }

    if (got_output) {
        printf("Write frame %3d (size=%5d)\n", i, pkt.size);
        memcpy(inbufout+totalSize,pkt.data,pkt.size);
        totalSize+=pkt.size;
        fwrite(pkt.data, 1, pkt.size, f);

        av_free_packet(&amp;pkt);
    }
    return 0;
    }

    void cancle_encode(void)
    {
    fclose(f);
    avcodec_close(c);
    av_free(c);
    av_freep(&amp;frame->data[0]);
    avcodec_free_frame(&amp;frame);
    }


    int main(int argc, char **argv)
    {
    int i;


    char inbufout[25*50*(INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE)];
    if(init_v4l2() &lt; 0) {
    printf("can't open camera\n");
    return 0;
    }

    /* register all the codecs */
    avcodec_register_all();



    for(int j=0;j&lt;2;j++){
       //init_video_encode("test.mpg", AV_CODEC_ID_MPEG1VIDEO, 15);
       init_video_encode("test.mpg", AV_CODEC_ID_H264, 15);
       //for(i = 0;i&lt; 10*15;i++ ) {
       for(i = 0;i&lt; 25*10;i++ ) {
       if(video_encode(i,inbufout) &lt; 0)
           return 0;
       }
       cout&lt;&lt;"\n"&lt;code></iostream>
  • Increase Duration of a video FFMPEG C++

    9 avril 2015, par Shahroz Tariq

    I am using the code from the samples of FFmpeg which encodes a picture into a video. All I want to do is to give it a series of pictures and it gives me a video with each picture is taking one second`Code below is just taking one picture from my file system & creating video from it

    AVCodec *codec;
    AVCodecContext *c = NULL;
    int i, ret, x, y, got_output;
    FILE *f;

    AVPacket pkt;
    uint8_t endcode[] = { 0, 0, 1, 0xb7 };

    printf("Encode video file %s\n", filename);

    /* find the mpeg1 video encoder */
    codec = avcodec_find_encoder((AVCodecID)codec_id);
    if (!codec)
    {
       fprintf(stderr, "Codec not found\n");
       exit(1);
    }

    c = avcodec_alloc_context3(codec);
    if (!c)
    {
       fprintf(stderr, "Could not allocate video codec context\n");
       exit(1);
    }

    /* put sample parameters */
    c->bit_rate = 400000;
    /* resolution must be a multiple of two */
    c->width = 200;
    c->height = 200;
    /* frames per second */
    AVRational rational;
    rational.num = 1;
    rational.den = 25;
    c->time_base = rational;
    /* emit one intra frame every ten frames
    * check frame pict_type before passing frame
    * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
    * then gop_size is ignored and the output of encoder
    * will always be I frame irrespective to gop_size
    */
    c->gop_size = 10;
    c->max_b_frames = 1;
    c->pix_fmt = AV_PIX_FMT_YUV420P;

    if (codec_id == AV_CODEC_ID_H264)
       av_opt_set(c->priv_data, "preset", "slow", 0);

    /* open it */
    if (avcodec_open2(c, codec, NULL) &lt; 0)
    {
       fprintf(stderr, "Could not open codec\n");
       exit(1);
    }

    fopen_s(&amp;f, filename, "wb");
    if (!f)
    {
       fprintf(stderr, "Could not open %s\n", filename);
       exit(1);
    }
    AVFrame *frame = OpenImage("..\\..\\..\\..\\..\\..\\1.jpg");
    //frame = av_frame_alloc();
    if (!frame)
    {
       fprintf(stderr, "Could not allocate video frame\n");
       exit(1);
    }

    frame->format = c->pix_fmt;
    frame->width = c->width;
    frame->height = c->height;
    /* the image can be allocated by any means and av_image_alloc() is
    * just the most convenient way if av_malloc() is to be used */

    int screenHeight = 200;
    int screenWidth = 200;
    for (i = 0; i &lt; 25; i++)
    {
       av_init_packet(&amp;pkt);
       pkt.data = NULL;    // packet data will be allocated by the encoder
       pkt.size = 0;

       fflush(stdout);



       frame->pts = i;

       /* encode the image */
       ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_output);
       if (ret &lt; 0)
       {
           fprintf(stderr, "Error encoding frame\n");
           exit(1);
       }

       if (got_output)
       {
           printf("Write frame %3d (size=%5d)\n", i, pkt.size);
           fwrite(pkt.data, 1, pkt.size, f);
           av_free_packet(&amp;pkt);
       }
    }

    /* get the delayed frames */
    for (got_output = 1; got_output; i++)
    {
       fflush(stdout);

       ret = avcodec_encode_video2(c, &amp;pkt, NULL, &amp;got_output);
       if (ret &lt; 0)
       {
           fprintf(stderr, "Error encoding frame\n");
           exit(1);
       }

       if (got_output)
       {
           printf("Write frame %3d (size=%5d)\n", i, pkt.size);
           fwrite(pkt.data, 1, pkt.size, f);
           av_free_packet(&amp;pkt);
       }
    }

    /* add sequence end code to have a real mpeg file */
    fwrite(endcode, 1, sizeof(endcode), f);
    fclose(f);

    avcodec_close(c);
    av_free(c);
    av_freep(&amp;frame->data[0]);
    av_frame_free(&amp;frame);
    printf("\n");`