Recherche avancée

Médias (2)

Mot : - Tags -/map

Autres articles (67)

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

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Création définitive du canal

    12 mars 2010, par

    Lorsque votre demande est validée, vous pouvez alors procéder à la création proprement dite du canal. Chaque canal est un site à part entière placé sous votre responsabilité. Les administrateurs de la plateforme n’y ont aucun accès.
    A la validation, vous recevez un email vous invitant donc à créer votre canal.
    Pour ce faire il vous suffit de vous rendre à son adresse, dans notre exemple "http://votre_sous_domaine.mediaspip.net".
    A ce moment là un mot de passe vous est demandé, il vous suffit d’y (...)

Sur d’autres sites (8167)

  • FFMPEG concat demuxer - how to make file formats compatible ?

    10 avril 2015, par user206481

    I need to automate mp4 concatenation server-side and I’m using FFMPEG. I will get uploads of mp4 files and I want to attach a Title.mp4 and End.mp4 to each one. I am also overlaying a soundtrack (the input videos do not have sound) There is a potential high server load so I’d like to do it as efficiently as possible using ffmpeg’s concat demuxer to avoid re-encoding the video.

    After receiving samples of each file, I am not successful and I believe it is due to mismatched file formats. My result has good Title.mp4 and audio, then when the sample uploaded mp4 is supposed to play there is garbled green/pink/red pixels on the top half of the video, then the End.mp4 plays fine. Here is my ffmpeg command and output :

    $ ffmpeg -f concat -i <(printf "file '%s'\n" Title.mp4 Sample.mp4 End.mp4) -i SoundTrack.wav -c:v copy -strict -2 -y Out.mp4

    ffmpeg version 2.6.1 Copyright (c) 2000-2015 the FFmpeg developers
    built with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-55)
    configuration: --prefix=/home/dpmsmobi/ffmpeg_build --extra-cflags=-I/home/dpmsmobi/ffmpeg_build/include --extra-ldflags=-L/home/dpmsmobi/ffmpeg_build/lib --bindir=/home/dpmsmobi/bin --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
     libavutil      54. 20.100 / 54. 20.100
     libavcodec     56. 26.100 / 56. 26.100
     libavformat    56. 25.101 / 56. 25.101
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 11.102 /  5. 11.102
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    Input #0, concat, from '/dev/fd/63':
     Duration: N/A, start: 0.000000, bitrate: 1810 kb/s
       Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 768x512 [SAR 1:1 DAR 3:2], 1810 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc
    Guessed Channel Layout for  Input Stream #1.0 : stereo
    Input #1, wav, from 'SoundTrack.wav':
     Metadata:
       encoded_by      : Adobe Premiere Pro CC 2014 (Maci
       encoder         : Adobe Premiere Pro CC 2014 (Macintosh)
       date            : 2015-04-07
       creation_time   : 11:12:10
       time_reference  : 0
     Duration: 00:00:15.06, bitrate: 1551 kb/s
       Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
    Output #0, mp4, to 'Out.mp4':
     Metadata:
       encoder         : Lavf56.25.101
       Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 768x512 [SAR 1:1 DAR 3:2], q=2-31, 1810 kb/s, 30 fps, 30 tbr, 30k tbn, 30k tbc
       Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s
       Metadata:
         encoder         : Lavc56.26.100 aac
    Stream mapping:
     Stream #0:0 -> #0:0 (copy)
     Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
    Press [q] to stop, [?] for help
    [concat @ 0x1dedc20] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
    [concat @ 0x1dedc20] DTS 69750 < 91000 out of order
    [mp4 @ 0x1f75060] Non-monotonous DTS in output stream 0:0; previous: 91000, current: 69750; changing to 91001. This may result in incorrect timestamps in the output file.

    <----- many more Non-monotonous DTS messages omitted here ---->

    frame=  427 fps=0.0 q=-1.0 Lsize=    4123kB time=00:00:15.06 bitrate=2242.5kbits/s    
    video:3873kB audio:236kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.344173%

    I can successfully concatenate the Title.mp4 to the End.mp4, and I can successfully concatenate two Sample.mp4 files, so I know I’ve got the ffmpeg command right. I can also successfully concat the files using the following ffmpeg command with filter_complex instead of concat demuxer (this takes considerably longer due to re-encoding) :

    ffmpeg -i Title.mp4 -i Sample.mp4 -i End.mp4 -i SoundTrack.wav -filter_complex '[0:0] [1:0] [2:0] concat=n=3:v=1 [v]' -map '[v]' -map 3:0 -crf 20 -strict -2 -y Out2.mp4

    Here is the MediaInfo output for each type of mp4 file :

    $ mediainfo Title.mp4
    General
    Complete name                            : Title.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media / Version 2
    Codec ID                                 : mp42
    File size                                : 693 KiB
    Duration                                 : 3s 100ms
    Overall bit rate mode                    : Variable
    Overall bit rate                         : 1 831 Kbps
    Encoded date                             : UTC 2015-04-07 19:15:03
    Tagged date                              : UTC 2015-04-07 19:15:03
    ©TIM                                     : 00:00:00:00
    ©TSC                                     : 30
    ©TSZ                                     : 1

    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : Main@L3.1
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 3 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 3s 100ms
    Bit rate mode                            : Variable
    Bit rate                                 : 1 811 Kbps
    Maximum bit rate                         : 3 000 Kbps
    Width                                    : 768 pixels
    Height                                   : 512 pixels
    Display aspect ratio                     : 3:2
    Frame rate mode                          : Constant
    Frame rate                               : 30.000 fps
    Standard                                 : NTSC
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.154
    Stream size                              : 685 KiB (99%)
    Language                                 : English
    Encoded date                             : UTC 2015-04-07 19:15:03
    Tagged date                              : UTC 2015-04-07 19:15:03
    Color range                              : Limited

    $ mediainfo Sample.mp4
    General
    Complete name                            : Sample.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom
    File size                                : 2.93 MiB
    Duration                                 : 7s 9ms
    Overall bit rate                         : 3 505 Kbps
    Encoded date                             : UTC 1970-01-01 00:00:00
    Tagged date                              : UTC 1970-01-01 00:00:00
    Writing application                      : Lavf52.64.2

    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : Baseline@L3.1
    Format settings, CABAC                   : No
    Format settings, ReFrames                : 1 frame
    Format settings, GOP                     : M=1, N=30
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 7s 9ms
    Bit rate                                 : 3 500 Kbps
    Width                                    : 768 pixels
    Height                                   : 512 pixels
    Display aspect ratio                     : 3:2
    Frame rate mode                          : Variable
    Frame rate                               : 30.250 fps
    Minimum frame rate                       : 23.462 fps
    Maximum frame rate                       : 296.053 fps
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.294
    Stream size                              : 2.92 MiB (100%)
    Language                                 : English
    Encoded date                             : UTC 1970-01-01 00:00:00
    Tagged date                              : UTC 1970-01-01 00:00:00

    I’m pretty sure it’s the mp42 vs isom Codec ID’s, and potentially the constant vs variable frame rates. I can’t change the input mp4’s but I know their format will stay the same. How can I reformat the Title and End mp4’s to match the input mp4 files so I can use ffmpeg concat demux ?

  • FFmpeg C API - syncing video and audio

    10 novembre 2015, par Justin Bradley

    I am trimming video and having a hard getting the audio to sync correctly. The code below is as close as I’ve gotten it work. I’ve tried both re-encoding and not re-encoding the output streams.

    The video trims correctly and is written to the output container. The audio stream also trims correctly, but is written to the front of the output container. For example if the trim length is 10s - the correct portion of audio plays for 10s and then the correct portion of video plays.

    //////// audio stream ////////
    const AVStream *input_stream_audio = input_container->streams[audio_stream_index];
    const AVCodec *decoder_audio = avcodec_find_decoder(input_stream_audio->codec->codec_id);
    if(!decoder_audio) {
       cleanup(decoded_packet, output_container, decoded_frame);
       avformat_close_input(&input_container);
       LOGE("=> Audio decoder not found");
       return -1;
    }
    if(avcodec_open2(input_stream_audio->codec, decoder_audio, NULL) < 0) {
       cleanup(decoded_packet, output_container, decoded_frame);
       avformat_close_input(&input_container);
       LOGE("=> Error opening audio decoder");
       return -1;
    }

    AVStream *output_stream_audio = avformat_new_stream(output_container, NULL);
    if(avcodec_copy_context(output_stream_audio->codec, input_stream_audio->codec) != 0){
       LOGE("=> Failed to Copy audio Context ");
       return -1;
    }
    else {
       LOGI("=> Copied audio context ");
       output_stream_audio->codec->codec_id = input_stream_audio->codec->codec_id;
       output_stream_audio->codec->codec_tag = 0;
       output_stream_audio->pts = input_stream_audio->pts;
       output_stream_audio->time_base.num = input_stream_audio->time_base.num;
       output_stream_audio->time_base.den = input_stream_audio->time_base.den;

    }

    if(avio_open(&output_container->pb, output_file, AVIO_FLAG_WRITE) < 0) {
       cleanup(decoded_packet, output_container, decoded_frame);
       avformat_close_input(&input_container);
       LOGE("=> Error opening output file");
       return -1;
    }

    // allocate frame for conversion
    decoded_frame = avcodec_alloc_frame();
    if(!decoded_frame) {
       cleanup(decoded_packet, output_container, decoded_frame);
       avformat_close_input(&input_container);
       LOGE("=> Error allocating frame");
       return -1;
    }

    av_dump_format(input_container, 0, input_file, 0);
    avformat_write_header(output_container, NULL);
    av_init_packet(&decoded_packet);

    decoded_packet.data = NULL;
    decoded_packet.size = 0;
    int current_frame_num = 1;
    int current_frame_num_audio = 1;
    int got_frame, len;

    AVRational default_timebase;
    default_timebase.num = 1;
    default_timebase.den = AV_TIME_BASE;

    int64_t starttime_int64 = av_rescale_q((int64_t)( 12.0 * AV_TIME_BASE ), AV_TIME_BASE_Q, input_stream->time_base);
    int64_t endtime_int64 = av_rescale_q((int64_t)( 18.0 * AV_TIME_BASE ), AV_TIME_BASE_Q, input_stream->time_base);
    LOGI("=> starttime_int64:     %" PRId64, starttime_int64);
    LOGI("=> endtime_int64:       %" PRId64, endtime_int64);

    int64_t starttime_int64_audio = av_rescale_q((int64_t)( 12.0 * AV_TIME_BASE ), AV_TIME_BASE_Q, input_stream_audio->time_base);
    int64_t endtime_int64_audio = av_rescale_q((int64_t)( 18.0 * AV_TIME_BASE ), AV_TIME_BASE_Q, input_stream_audio->time_base);
    LOGI("=> starttime_int64_audio:     %" PRId64, starttime_int64_audio);
    LOGI("=> endtime_int64_audio:       %" PRId64, endtime_int64_audio);

    // loop input container and decode frames
    while(av_read_frame(input_container, &decoded_packet)>=0) {
       // video packets
       if (decoded_packet.stream_index == video_stream_index) {
           len = avcodec_decode_video2(input_stream->codec, decoded_frame, &got_frame, &decoded_packet);
           if(len < 0) {
               cleanup(decoded_packet, output_container, decoded_frame);
               avformat_close_input(&input_container);
               LOGE("=> No frames to decode");
               return -1;
           }
           // this is the trim range we're looking for
           if(got_frame && decoded_frame->pkt_pts >= starttime_int64 && decoded_frame->pkt_pts <= endtime_int64) {
                   av_init_packet(&encoded_packet);
                   encoded_packet.data =  NULL;
                   encoded_packet.size =  0;

                   ret = avcodec_encode_video2(output_stream->codec, &encoded_packet, decoded_frame, &got_frame);
                   if (ret < 0) {
                       cleanup(decoded_packet, output_container, decoded_frame);
                       avformat_close_input(&input_container);
                       LOGE("=> Error encoding frames");
                       return ret;
                   }
                   if(got_frame) {
                       if (output_stream->codec->coded_frame->key_frame) {
                           encoded_packet.flags |= AV_PKT_FLAG_KEY;
                       }

                       encoded_packet.stream_index = output_stream->index;
                       encoded_packet.pts = av_rescale_q(current_frame_num, output_stream->codec->time_base, output_stream->time_base);
                       encoded_packet.dts = av_rescale_q(current_frame_num, output_stream->codec->time_base, output_stream->time_base);

                       ret = av_interleaved_write_frame(output_container, &encoded_packet);
                       if (ret < 0) {
                           cleanup(decoded_packet, output_container, decoded_frame);
                           avformat_close_input(&input_container);
                           LOGE("=> Error encoding frames");
                           return ret;
                       }
                       else {
                           current_frame_num +=1;
                       }
                   }
               av_free_packet(&encoded_packet);
           }
       }
       // audio packets
       else if(decoded_packet.stream_index == audio_stream_index) {
           // this is the trim range we're looking for
           if(decoded_packet.pts >= starttime_int64_audio && decoded_packet.pts <= endtime_int64_audio) {
               av_init_packet(&encoded_packet);

               encoded_packet.data =  decoded_packet.data;
               encoded_packet.size =  decoded_packet.size;
               encoded_packet.stream_index = audio_stream_index;
               encoded_packet.pts = av_rescale_q(current_frame_num_audio, output_stream_audio->codec->time_base, output_stream_audio->time_base);
               encoded_packet.dts = av_rescale_q(current_frame_num_audio, output_stream_audio->codec->time_base, output_stream_audio->time_base);

               ret = av_interleaved_write_frame(output_container, &encoded_packet);
               if (ret < 0) {
                   cleanup(decoded_packet, output_container, decoded_frame);
                   avformat_close_input(&input_container);
                   LOGE("=> Error encoding frames");
                   return ret;
               }
               else {
                   current_frame_num_audio +=1;
               }
              av_free_packet(&encoded_packet);
           }
       }
    }

    Edit

    I have slight improvement on the initial code. The audio and video are still not perfectly synced, but the original problem of the audio playing first followed by the video is resolved.

    I’m now writing the decoded packet to the output container rather than re-encoding it.

    In the end though I have the same problem - the trimmed video’s audio and video streams are not perfectly synced.

    // audio packets
       else if(decoded_packet.stream_index == audio_stream_index) {
           // this is the trim range we're looking for
           if(decoded_packet.pts >= starttime_int64_audio && decoded_packet.pts <= endtime_int64_audio) {
               ret = av_interleaved_write_frame(output_container, &decoded_packet);
               if (ret < 0) {
                   cleanup(decoded_packet, output_container, decoded_frame);
                   avformat_close_input(&input_container);
                   LOGE("=> Error writing audio frame (%s)", av_err2str(ret));
                   return ret;
               }
               else {
                   current_frame_num_audio +=1;
               }
           }
           else if(decoded_frame->pkt_pts > endtime_int64_audio) {
               audio_copy_complete = true;
           }
       }
  • how to convert a video to H264 video codec format & webm and ogv with watermark via ffmpeg

    5 mars 2015, par ali

    I used this code :

    function convert()
    {
     exec("$ffmpegPath  -i $inputPath -i $watermark -filter_complex overlay=10:10 $outPath");
    }

    convert('test.mp4');
    convert('test.webm');
    convert('test.ogv');

    This code works...but not in browser !
    I can run output videos via KMPLAYER in desktop (ovg only video - no audio)

    I want to run it on web via videojs.

    mp4 playback with videojs in browsers - audio plays but video is blank.

    I googled and I think I must convert it to h264 format...

    Can somebody change my orginal code to 3 valid codes for h264,webm and ogv ?