Recherche avancée

Médias (1)

Mot : - Tags -/ogv

Autres articles (13)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

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

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

Sur d’autres sites (4935)

  • How to force Constant Bit Rate using FFMPEG

    6 octobre 2014, par user1338254

    I use FFMPEG (command line Input) to convert my videos to a specific output format. The problem I am facing is when I try to pass a constant bit rate(700 kbps) to FFMPEG, the result is an output video with a different bit rate(say 1000 kbps). This phenomenon occurs invariably for all videos.Why is this happening ? I need to maintain a constant bit rate. Can anyone help me out.

    My FFMPEG version is 0.5

    The command line parameter which I am passing to FFMPEG is,

    -i {inputfile}
    -b 700k -ab 64k
    -vcodec libx264
    -acodec libfaac -ac 2 -ar 44100
    -y -s 320x240
    {outputfile}

    EDIT :

    I was able to force CBR with a fluctuation of 3% when I used the following parameters.

    ffmpeg -i myfile.avi
    -b 4000k -minrate 4000k
    -maxrate 4000k -bufsize 1835k   out.m2v

    But when I used -maxrate and - minrate along with my parameter set I was not able to force CBR. My parameter set is as follows,

    -i {inputfile}
    -b 1200k -minrate 1200k
    -maxrate 1200k -bufsize 1200k
    -ab 64k -vcodec libx264
    -acodec libfaac -ac 2 -ar 44100
    -y -s 320x240
    {outputfile}

    Why is this happening ?

  • Store converted video in a buffer to transfer to S3

    24 mai 2012, par Chris

    I have a system set up to upload an image, take that temporarily uploaded file, convert it to a resized jpeg, read the buffer of that conversion and send the buffer to amazon S3 for storage as an image. It works wonderfully because no permanent file is stored on the my server, everything is on S3.

    Now I am attempting to add this same functionality but with video. The process goes through, but the resulting files stored on Amazons S3 servers are 1.5kb a piece, instead of multimb videos.

    My code is as follows :

    public function transfer($method, $file, $bucketName, $filename, $contentType){
       switch($method){
           case 'file':
               if($this->s3->putObject($this->s3->inputFile($file, false), $bucketName, $filename, S3::ACL_PUBLIC_READ, array(), $contentType))
                   return true;
               else
                   return false;
               break;
           case 'string':
               if ($this->s3->putObject($file, $bucketName, $filename, S3::ACL_PUBLIC_READ, array(), $contentType))
                   return true;
               else
                   return false;
               break;
           case 'resource':
               if($this->s3->putObject($this->s3->inputResource(fopen($file, 'rb'), filesize($file)), $bucketName, $filename, S3::ACL_PUBLIC_READ, array(), $contentType))
                   return true;
               else
                   return false;
               break;
       }
       return false;
    }  


    /**
    *   AmazonS3Handler - convert()
    */

    public function convert($file, $type)
    {
            $ffmpeg = "/usr/bin/ffmpeg";
       $cmd['webm'] = $ffmpeg. " -i ". $file ." -vcodec libvpx -acodec libvorbis -ac 2 -f webm -g 30 2>&1";
       $cmd['ogv'] = $ffmpeg. " -i ". $file ." -vcodec libtheora -acodec libvorbis -ac 2 2>&1";
       $cmd['mp4'] = $ffmpeg. " -i ". $file ." -vcodec libx264 -acodec libfaac -ac 2 2>&1";
       $cmd['jpg'] = $ffmpeg. " -i ". $file ." -vframes 30";

       ob_start();
       passthru($cmd[$type]);
       $fileContents = ob_get_contents();
       ob_end_clean();
       return $fileContents;
    }

    From my understanding, passthru should return raw output which could be picked up by the output buffer.

    Am I doing something wrong ? Is there a better way to convert a video on my servers but keep the data on S3 ?

    Thanks !

    EDIT : I've boiled it down to the executing of the command. FFMPEG wasn't being located, so I changed the path to "/usr/bin/ffmpeg", no more error 127, now when I run exec() (not passthru) I get error 1

    EDIT2 : Here is the output of running the script :

    Array
    (
    [0] => ffmpeg version 0.7.3-4:0.7.3-0ubuntu0.11.10.1, Copyright (c) 2000-2011 the Libav developers
    [1] =>   built on Jan  4 2012 16:08:51 with gcc 4.6.1
    [2] =>   configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=amd64 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
    [3] =>   libavutil    51.  7. 0 / 51.  7. 0
    [4] =>   libavcodec   53.  6. 0 / 53.  6. 0
    [5] =>   libavformat  53.  3. 0 / 53.  3. 0
    [6] =>   libavdevice  53.  0. 0 / 53.  0. 0
    [7] =>   libavfilter   2.  4. 0 /  2.  4. 0
    [8] =>   libswscale    2.  0. 0 /  2.  0. 0
    [9] =>   libpostproc  52.  0. 0 / 52.  0. 0
    [10] =>
    [11] => Seems stream 1 codec frame rate differs from container frame rate: 2000.00 (2000/1) -> 30.30 (1000/33)
    [12] => Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'iv.m4v':
    [13] =>   Metadata:
    [14] =>     major_brand     : M4V
    [15] =>     minor_version   : 1
    [16] =>     compatible_brands: M4V M4A mp42isom
    [17] =>     creation_time   : 2012-01-23 04:00:18
    [18] =>     encoder         : Mac OS X v10.7.2 (CMA 889, CM 705.42, x86_64)
    [19] =>   Duration: 00:00:11.70, start: 0.000000, bitrate: 345 kb/s
    [20] =>     Stream #0.0(und): Audio: aac, 44100 Hz, stereo, s16, 125 kb/s
    [21] =>     Metadata:
    [22] =>       creation_time   : 2012-01-23 04:00:18
    [23] =>     Stream #0.1(und): Video: h264 (Main), yuv420p, 640x360 [PAR 1:1 DAR 16:9], 206 kb/s, 30.30 fps, 30.30 tbr, 1k tbn, 2k tbc
    [24] =>     Metadata:
    [25] =>       creation_time   : 2012-01-23 04:00:18
    [26] => iv.webm: Permission denied
    )

    It looks like the permissions aren't set right, however the file has chmod 777 permissions. What other permissions need to get changed ?

  • how to convert an MPEGTS file into an FLV file by programming with libavcodec

    9 mai 2014, par Hexing B

    I wanna convert an MPEGTS file into an FLV file with libavcodec APIs(just transformat, video/audio codecs are not changed). Following is the code I found on web. After some hack, it can generate an FLV file, which could not be played. Any clue to fix this ?

    #include
    #include
    #include
    #include

    #include <libavformat></libavformat>avformat.h>
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>avutil.h>
    #include <libavutil></libavutil>rational.h>
    #include <libavdevice></libavdevice>avdevice.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libswscale></libswscale>swscale.h>

    static AVStream* add_output_stream(AVFormatContext* output_format_context, AVStream* input_stream) {
       AVCodecContext* input_codec_context = NULL;
       AVCodecContext* output_codec_context = NULL;

       AVStream* output_stream = NULL;
       output_stream = avformat_new_stream(output_format_context, 0);
       if (!output_stream) {
           printf("Call av_new_stream function failed\n");
           return NULL;
       }

       input_codec_context = input_stream->codec;
       output_codec_context = output_stream->codec;

       output_codec_context->codec_id = input_codec_context->codec_id;
       output_codec_context->codec_type = input_codec_context->codec_type;
       // output_codec_context->codec_tag = input_codec_context->codec_tag;
       output_codec_context->codec_tag = av_codec_get_tag(output_format_context->oformat->codec_tag, input_codec_context->codec_id);
       output_codec_context->bit_rate = input_codec_context->bit_rate;
       output_codec_context->extradata = input_codec_context->extradata;
       output_codec_context->extradata_size = input_codec_context->extradata_size;

       if (av_q2d(input_codec_context->time_base) * input_codec_context->ticks_per_frame > av_q2d(input_stream->time_base) &amp;&amp; av_q2d(input_stream->time_base) &lt; 1.0 / 1000) {
           output_codec_context->time_base = input_codec_context->time_base;
           output_codec_context->time_base.num *= input_codec_context->ticks_per_frame;
       } else {
           output_codec_context->time_base = input_stream->time_base;
       }
       switch (input_codec_context->codec_type) {
       case AVMEDIA_TYPE_AUDIO:
           output_codec_context->channel_layout = input_codec_context->channel_layout;
           output_codec_context->sample_rate = input_codec_context->sample_rate;
           output_codec_context->channels = input_codec_context->channels;
           output_codec_context->frame_size = input_codec_context->frame_size;
           if ((input_codec_context->block_align == 1 &amp;&amp; input_codec_context->codec_id == CODEC_ID_MP3) || input_codec_context->codec_id == CODEC_ID_AC3) {
               output_codec_context->block_align = 0;
           } else {
               output_codec_context->block_align = input_codec_context->block_align;
           }
           break;
       case AVMEDIA_TYPE_VIDEO:
           output_codec_context->pix_fmt = input_codec_context->pix_fmt;
           output_codec_context->width = input_codec_context->width;
           output_codec_context->height = input_codec_context->height;
           output_codec_context->has_b_frames = input_codec_context->has_b_frames;
           if (output_format_context->oformat->flags &amp; AVFMT_GLOBALHEADER) {
               output_codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
           }
           // output_codec_context->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
           break;
       default:
           break;
       }

       return output_stream;
    }

    int main(int argc, char* argv[]) {
       const char* input = argv[1];
       const char* output_prefix = NULL;
       char* segment_duration_check = 0;
       const char* index = NULL;
       char* tmp_index = NULL;
       const char* http_prefix = NULL;
       long max_tsfiles = 0;
       double prev_segment_time = 0;
       double segment_duration = 0;

       AVInputFormat* ifmt = NULL;
       AVOutputFormat* ofmt = NULL;
       AVFormatContext* ic = NULL;
       AVFormatContext* oc = NULL;
       AVStream* video_st = NULL;
       AVStream* audio_st = NULL;
       AVCodec* codec = NULL;
       AVDictionary* pAVDictionary = NULL;

       av_register_all();
       av_log_set_level(AV_LOG_DEBUG);

       char szError[256] = {0};
       int nRet = avformat_open_input(&amp;ic, input, ifmt, &amp;pAVDictionary);
       if (nRet != 0) {
           av_strerror(nRet, szError, 256);
           printf(szError);
           printf("\n");
           printf("Call avformat_open_input function failed!\n");
           return 0;
       }

       if (avformat_find_stream_info(ic, NULL) &lt; 0) {
           printf("Call av_find_stream_info function failed!\n");
           return 0;
       }

       ofmt = av_guess_format(NULL, argv[2], NULL);
       if (!ofmt) {
           printf("Call av_guess_format function failed!\n");
           return 0;
       }

       oc = avformat_alloc_context();
       if (!oc) {
           printf("Call av_guess_format function failed!\n");
           return 0;
       }
       oc->oformat = ofmt;

       int video_index = -1, audio_index = -1;
       unsigned int i;
       for (i = 0; i &lt; ic->nb_streams &amp;&amp; (video_index &lt; 0 || audio_index &lt; 0); i++) {
           switch (ic->streams[i]->codec->codec_type) {
           case AVMEDIA_TYPE_VIDEO:
               video_index = i;
               ic->streams[i]->discard = AVDISCARD_NONE;
               video_st = add_output_stream(oc, ic->streams[i]);
               if (video_st->codec->codec_id == CODEC_ID_H264) {
                   video_st->codec->opaque = av_bitstream_filter_init("h264_mp4toannexb");
               }
               break;
           case AVMEDIA_TYPE_AUDIO:
               audio_index = i;
               ic->streams[i]->discard = AVDISCARD_NONE;
               audio_st = add_output_stream(oc, ic->streams[i]);
               if (audio_st->codec->codec_id == CODEC_ID_AAC &amp;&amp; !audio_st->codec->extradata_size) {
                   audio_st->codec->opaque = av_bitstream_filter_init("aac_adtstoasc");
               }
               break;
           default:
               ic->streams[i]->discard = AVDISCARD_ALL;
               break;
           }
       }
       codec = avcodec_find_decoder(video_st->codec->codec_id);
       if (codec == NULL) {
           printf("Call avcodec_find_decoder function failed!\n");
           return 0;
       }

       if (avcodec_open2(video_st->codec, codec, NULL) &lt; 0) {
           printf("Call avcodec_open function failed !\n");
           return 0;
       }

       if (avio_open(&amp;oc->pb, argv[2], AVIO_FLAG_WRITE) &lt; 0) {
           return 0;
       }

       if (avformat_write_header(oc, &amp;pAVDictionary)) {
           printf("Call avformat_write_header function failed.\n");
           return 0;
       }

       int decode_done = 0;
       do {
           AVPacket packet;
           decode_done = av_read_frame(ic, &amp;packet);
           if (decode_done &lt; 0) {
               break;
           }

           if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; AV_PKT_FLAG_KEY) &amp;&amp; video_st->codec->opaque != NULL) {
               AVPacket pkt = packet;
               int a = av_bitstream_filter_filter(video_st->codec->opaque, video_st->codec, NULL, &amp;pkt.data, &amp;pkt.size,
                       packet.data, packet.size, packet.flags &amp; AV_PKT_FLAG_KEY);
               if (a == 0) {
                   memmove(packet.data, pkt.data, pkt.size);
                   packet.size = pkt.size;
               } else if (a > 0) {
                   packet = pkt;
               }
           }
           else if (packet.stream_index == audio_index &amp;&amp; audio_st->codec->opaque != NULL) {
               AVPacket pkt = packet;
               int a = av_bitstream_filter_filter(audio_st->codec->opaque, audio_st->codec, NULL, &amp;pkt.data, &amp;pkt.size,
                       packet.data, packet.size, packet.flags &amp; AV_PKT_FLAG_KEY);
               if (a == 0) {
                   memmove(packet.data, pkt.data, pkt.size);
                   packet.size = pkt.size;
               } else if (a > 0) {
                   packet = pkt;
               }
           }
           nRet = av_interleaved_write_frame(oc, &amp;packet);
           if (nRet &lt; 0) {
               printf("Call av_interleaved_write_frame function failed\n");
           } else if (nRet > 0) {
               printf("End of stream requested\n");
               av_free_packet(&amp;packet);
                   break;
           }
           av_free_packet(&amp;packet);
       } while(!decode_done);

       av_write_trailer(oc);

       av_bitstream_filter_close(video_st->codec->opaque);  
       av_bitstream_filter_close(audio_st->codec->opaque);  
       avcodec_close(video_st->codec);
       unsigned int k;
       for(k = 0; k &lt; oc->nb_streams; k++) {
           av_freep(&amp;oc->streams[k]->codec);
           av_freep(&amp;oc->streams[k]);
       }
       av_free(oc);
       getchar();
       return 0;
    }