Recherche avancée

Médias (1)

Mot : - Tags -/remix

Autres articles (50)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

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

Sur d’autres sites (7616)

  • How can I fix video processing and 500 Error - (Laravel, FFmpeg)

    19 juillet 2019, par San Martín Figueroa Pablo

    I’m setting up a new website with Laravel for uploading videos...
    I have read all the possible solutions but none of them help me to solve the issue...

    This is my issue : When I upload a small file (<10mb) the web works fine, the video get uploaded and the video get converted, the dashboard shows the converted videos---

    When I try to upload a large file, the file get uploaded, the video get converted with a green frame on it (really uggly) and the site goes to a 500 server error...

    I’m using Laravel Jobs to do the conversion.

    My Controller code :

       &lt;?php

       namespace App\Http\Controllers;

       use Illuminate\Http\Request;
       use Illuminate\Support\Facades\DB;
       use Illuminate\Support\Facades\Storage;
       use Symfony\Component\HttpFoundation\Response;
       use Carbon;
       use Closure;
       use App\Jobs\ConvertVideoForPreview;
       use FFMpeg\FFProbe;
       use FFMpeg\Coordinate\Dimension;
       use FFMpeg\Format\Video\X264;
       use Pawlox\VideoThumbnail\Facade\VideoThumbnail;
       use Pbmedia\LaravelFFMpeg\FFMpegFacade as FFMpeg;
       use Illuminate\Contracts\Filesystem\Filesystem;


       use App\Video;

       class VideoController extends Controller
       {
       public function createVideo(){
           return view('video.createVideo');  
       }
       public function saveVideo(Request $request){


           set_time_limit(0);
           ini_set('memory_limit', '1024M');

           //Validar Formulario

           $validatedData = $this -> validate($request, [

               'title' => 'required',
               'description' => 'required',
               'palabras' => 'required',
               'video' => 'mimetypes:video/mp4,video/quicktime'


           ]);

           $video = new Video();
           $user = \Auth::user();
           $video -> user_id = $user->id;
           $video -> title = $request -> input('title');
           $video -> description = $request -> input('description');
           $video -> palabras = $request -> input('palabras');



           $video_file = $request -> file('video');

           if($video_file){

           $video_path = 'original'.'_'.$video_file ->                                
           getClientOriginalName();
           Storage::disk('videos')-> put($video_path,
           \File::get($video_file));

           $videoUrl = storage_path('app/videos/').$video_path;
           $storageUrl = storage_path('app/thumbs/');
           $fileName = 'thumb'.'_'.time().'.jpg';
           $second = 2;

           VideoThumbnail::createThumbnail($videoUrl, $storageUrl,    
           $fileName, $second, $width = 640, $height = 480);

           $video -> preview = $fileName;
           $video -> video_path = $video_path;

         }
           $video -> save();

           ConvertVideoForPreview::dispatch($video);

           return redirect() -> route('home')
                             -> with (array(
               'message' => 'El video se ha enviado con exito'));
         }

           public function getImage($filename){

               $file = Storage::disk('thumbs') -> get($filename);
               return new Response($file, 200);
         }

           public function getVideo($filename){

               $file = Storage::disk('converted_videos') ->  
           get($filename);
               return new Response($file, 200);
         }

         }

    This is my ConvertVideo Job :

       &lt;?php

        namespace App\Jobs;

        use App\Video;

        use Carbon\Carbon;
        use FFMpeg;
        use FFMpeg\Format\Video\X264;

        use Illuminate\Http\Request;
        use Illuminate\Bus\Queueable;
        use Illuminate\Queue\SerializesModels;
        use Illuminate\Queue\InteractsWithQueue;
        use Illuminate\Contracts\Queue\ShouldQueue;
        use Illuminate\Foundation\Bus\Dispatchable;

        class ConvertVideoForPreview implements ShouldQueue

           {
             use Dispatchable, InteractsWithQueue, Queueable,
             SerializesModels;

             public $video;


             public function __construct(Video $video)
            {
                $this -> video = $video;
            }
             public function handle()
            {

             $converted_name= 'preview'.'-'.$this -> video ->
             video_path.'.mp4';

             FFMpeg::open('videos/'.$this -> video -> video_path)

                           -> export()
                   -> inFormat(new \FFMpeg\Format\Video\X264)
                       -> save('converted_videos/'.$converted_name);

               $this -> video -> update([
               'video_preview' => $converted_name,
               'processed' => true
                ]);
         }
        }

    One of my goals is to upload large video files (<=4GB), show a uploading process bar and a encoding process bar during the video upload.

    I getting this error :

    [core:error] [pid 14787:tid 139975366489856] [client
     201.188.26.12:51022] Script timed out before returning headers:
     index.php,

    It’s happend when the video es proccesing and the redirect to home dashboard it’s call...

    The FFMPEG works :

    [2019-07-19 17:20:41] local.INFO: ffprobe executed command successfully  
    [2019-07-19 17:21:52] local.INFO: ffmpeg executed command successfully  
    [2019-07-19 17:21:52] local.INFO: ffmpeg running command '/usr/local/bin/ffmpeg' '-y' '-i' '/home/tribus/public_html/storage/app/videos/original_Sequence 01.mov' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '2' '-passlogfile' '/tmp/ffmpeg-passes5d31fbe9010e6ldt9s/pass-5d31fbe90152d' '/home/tribus/public_html/storage/app/converted_videos/preview-original_Sequence 01.mov.mp4'

    I have tried : Change all the memory and file size in PHP.ini, Nginx, Apache... (Probably I’m missing one)...

    Changed timeouts too.

    My environment : VPS 4GB 50GB, APACHE 2.4, PHP7.3, MySql MariaDB, WebServer : Apache-Nginx, Laravel 5.8.

    Can anyone help me to reach this ?...

    This is how the large video looks after converted and show 500 error in the browser :
    Error video processed

  • ffmpeg generate thumbnails on GPU

    22 juin 2018, par Oleksandr Kyrpa

    I try to generate thumbnails with acceleration on GPU, so compile ffmpeg 3.4.1 and run command :

    ./ffmpeg  -i ~/Videos/1080.mp4 -vf "hwupload_cuda,thumbnail_cuda=100,scale_cuda=107:60,hwdownload,format=yuv420p" -vframes 1 -y ~/Videos/thumbs/thumb%03d.jpg

    But I get wrong output picture (the color of thumbnail is green) :

    enter image description here

    Correct image must be black.
    How to make first image with correct color ?

    enter image description here

    log : -loglevel verbose

    ffmpeg version N-89707-g89b84cb Copyright (c) 2000-2018 the FFmpeg developers
     built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
     configuration: --cpu=native --enable-pthreads --extra-version=hd --enable-gnutls --enable-vaapi --enable-vdpau --enable-nonfree --enable-gpl --enable-swscale --enable-libx264 --enable-version3 --enable-nvenc --enable-libnpp --enable-cuda --enable-cuvid --enable-cuda-sdk --enable-filter=scale_cuda --enable-filter=thumbnail_cuda --extra-cflags=-I/usr/local/cuda-8.0/include --extra-ldflags=-L/usr/local/cuda-8.0/lib64
     libavutil      56.  7.100 / 56.  7.100
     libavcodec     58.  9.100 / 58.  9.100
     libavformat    58.  3.100 / 58.  3.100
     libavdevice    58.  0.100 / 58.  0.100
     libavfilter     7. 11.100 /  7. 11.100
     libswscale      5.  0.101 /  5.  0.101
     libswresample   3.  0.101 /  3.  0.101
     libpostproc    55.  0.100 / 55.  0.100
    [h264 @ 0x392ed40] Reinit context to 1920x1088, pix_fmt: yuv420p
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/alex/Videos/1080.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: isommp42
       creation_time   : 2012-05-30T20:01:34.000000Z
     Duration: 00:01:14.21, start: 0.000000, bitrate: 5476 kb/s
       Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088), 5321 kb/s, 29.97 fps, 29.97 tbr, 60k tbn, 59.94 tbc (default)
       Metadata:
         creation_time   : 1970-01-01T00:00:00.000000Z
         handler_name    : VideoHandler
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 152 kb/s (default)
       Metadata:
         creation_time   : 2012-05-30T20:01:34.000000Z
         handler_name    : IsoMedia File Produced by Google, 5-11-2011
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
    Press [q] to stop, [?] for help
    [h264 @ 0x3a38280] Reinit context to 1920x1088, pix_fmt: yuv420p
    [Parsed_thumbnail_cuda_1 @ 0x4e3d8c0] batch size: 100 frames
    [graph 0 input from stream 0:0 @ 0x4e8b640] w:1920 h:1080 pixfmt:yuv420p tb:1/60000 fr:30000/1001 sar:0/1 sws_param:flags=2
    [auto_scaler_0 @ 0x4e8ca00] w:iw h:ih flags:'bicubic' interl:0
    [format @ 0x4e8b540] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_format_4' and the filter 'format'
    [Parsed_scale_cuda_2 @ 0x4e89380] w:1920 h:1080 -> w:107 h:60
    [swscaler @ 0x4ebf0c0] deprecated pixel format used, make sure you did set range correctly
    [auto_scaler_0 @ 0x4e8ca00] w:107 h:60 fmt:yuv420p sar:0/1 -> w:107 h:60 fmt:yuvj420p sar:0/1 flags:0x4
    Output #0, image2, to '/home/alex/Videos/thumbs/thumb%03d.jpg':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: isommp42
       encoder         : Lavf58.3.100
       Stream #0:0(und): Video: mjpeg, 1 reference frame, yuvj420p(pc, left), 107x60, q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default)
       Metadata:
         creation_time   : 1970-01-01T00:00:00.000000Z
         handler_name    : VideoHandler
         encoder         : Lavc58.9.100 mjpeg
       Side data:
         cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    [Parsed_thumbnail_cuda_1 @ 0x4e3d8c0] frame id #76 (pts_time=2.535867) selected from a set of 100 images
    No more output streams to write to, finishing.
    frame=    1 fps=0.9 q=3.1 Lsize=N/A time=00:00:02.56 bitrate=N/A speed=2.26x    
    video:2kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
    Input file #0 (/home/alex/Videos/1080.mp4):
     Input stream #0:0 (video): 115 packets read (134655 bytes); 101 frames decoded;
     Input stream #0:1 (audio): 1 packets read (9 bytes);
     Total: 116 packets (134664 bytes) demuxed
    Output file #0 (/home/alex/Videos/thumbs/thumb%03d.jpg):
     Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (1864 bytes);
     Total: 1 packets (1864 bytes) muxed

    UPDATE, working !
    Add format=nv12 before hwupload

    -vf "format=nv12,hwupload_cuda,thumbnail_cuda,scale_cuda=1280:72‌​0,hwdownload,format=‌​nv12"

  • Encoding images to h264 and rtp output : SDP file without sprop-parameter-sets does not play

    14 septembre 2021, par oarfish

    tl ;dr : I try to encode acquired camera frames to h264, send via RTP&#xA;and play this back on another device. SDP file generated by ffmpeg for&#xA;a sample video has info which my own SDP file misses. My SDP file&#xA;plays in ffplay, but not VLC, while both play ffmpeg's SDP file. I am&#xA;suspecting missing sprop-parameter-sets in my SDP file.

    &#xA;

    Ultimately I want to play this back in VLC.

    &#xA;


    &#xA;

    I am writing code that encodes images to h264 and outputs to an RTP&#xA;server (or client ? anyway the part that is listening). I generate an&#xA;SDP file for this.

    &#xA;

      &#xA;
    • ffplay plays the stream without problem
    • &#xA;

    • mplayer shows a green box embedded in a larger black box, but I read&#xA;somewhere it only supports mpegts over RTP, so not sure
    • &#xA;

    • VLC does not play the SDP file.
    • &#xA;

    &#xA;

    Now when instead I use some random video and have ffmpeg output an SDP&#xA;file like so

    &#xA;

    ffmpeg     -re     -i some.mp4     -an     -c:v copy -f rtp -sdp_file&#xA;video.sdp     "rtp://127.0.0.1:5004"&#xA;

    &#xA;

    I can see that the generated SDP file – which plays in both ffplay and&#xA;VLC – includes the base64 encoded sprop-parameter-sets field, and&#xA;removing this causes the stream to not play.

    &#xA;

    > cat video.sdp&#xA;v=0&#xA;o=- 0 0 IN IP4 127.0.0.1&#xA;s=No Name&#xA;c=IN IP4 127.0.0.1&#xA;t=0 0&#xA;a=tool:libavformat 58.76.100&#xA;m=video 5004 RTP/AVP 96&#xA;b=AS:1034&#xA;a=rtpmap:96 H264/90000&#xA;a=fmtp:96 packetization-mode=1;&#xA;sprop-parameter-sets=Z2QANKzZQDAA7fiMBagICAoAAAMAAgAAAwDwHjBjLA==,aOvjyyLA;&#xA;profile-level-id=640034&#xA;

    &#xA;

    My own SDP file on the other hand, does not contain this information,&#xA;and VLC hangs for 10s and then stops trying with "no data received".

    &#xA;

    > cat test.sdp&#xA;v=0&#xA;o=- 0 0 IN IP4 127.0.0.1&#xA;s=No Name&#xA;c=IN IP4 127.0.0.1&#xA;t=0 0&#xA;a=tool:libavformat 58.76.100&#xA;m=video 44499 RTP/AVP 96&#xA;b=AS:2000&#xA;a=rtpmap:96 H264/90000&#xA;a=fmtp:96 packetization-mode=1&#xA;

    &#xA;

    So my theory is that my custom code must somehow add this SPS&#xA;information to the SDP file. But despite hours of searching, I could&#xA;not find a structured way to set the extradata field on the AVStream's&#xA;AVCodecParams. The code I'm using is roughly this (I'm sure there's&#xA;unrelated errors in there) :

    &#xA;

    // variables&#xA;std::vector imgbuf;&#xA;AVFormatContext *ofmt_ctx = nullptr;&#xA;AVCodec *out_codec = nullptr;&#xA;AVStream *out_stream = nullptr;&#xA;AVCodecContext *out_codec_ctx = nullptr;&#xA;SwsContext *swsctx = nullptr;&#xA;cv::Mat canvas_;&#xA;unsigned int height_;&#xA;unsigned int width_;&#xA;unsigned int fps_;&#xA;AVFrame *frame_ = nullptr;&#xA;&#xA;AVOutputFormat *format = av_guess_format("rtp", nullptr, nullptr);&#xA;const auto url = std::string("rtp://127.0.0.1:5001");&#xA;avformat_alloc_output_context2(ofmt_ctx, format, format->name, url.c_str());&#xA;&#xA;out_codec = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;stream = avformat_new_stream(ofmt_ctx, out_codec);&#xA;out_codec_ctx = avcodec_alloc_context3(out_codec);&#xA;&#xA;// then, for each incoming image:&#xA;while (receive_image) {&#xA;  static bool first_time = true;&#xA;  if (first_time) {&#xA;    // discover necessary params such as image dimensions from the first&#xA;    // received image&#xA;    first_time = false;&#xA;    height_ = image.rows;&#xA;    width_ = image.cols;&#xA;&#xA;    codec_ctx->codec_tag = 0;&#xA;    codec_ctx->bit_rate = 2e6;&#xA;    // does nothing, unfortunately&#xA;    codec_ctx->thread_count = 1;&#xA;    codec_ctx->codec_id = AV_CODEC_ID_H264;&#xA;    codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    codec_ctx->width = width_;&#xA;    codec_ctx->height = height_;&#xA;    codec_ctx->gop_size = 6;&#xA;    codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;    codec_ctx->framerate = fps_;&#xA;    codec_ctx->time_base = av_inv_q(fps_);&#xA;&#xA;    avcodec_parameters_from_context(stream, out_codec_ctx);&#xA;&#xA;    // this stuff is empty: is that the problem?&#xA;    stream->codecpar->extradata = codec_ctx->extradata;&#xA;    stream->codecpar->extradata_size = codec_ctx->extradata_size;&#xA;&#xA;    AVDictionary *codec_options = nullptr;&#xA;    av_dict_set(&amp;codec_options, "profile", "high", 0);&#xA;    av_dict_set(&amp;codec_options, "preset", "ultrafast", 0);&#xA;    av_dict_set(&amp;codec_options, "tune", "zerolatency", 0);&#xA;&#xA;    // open video encoder&#xA;    avcodec_open2(codec_ctx, codec, &amp;codec_options);&#xA;&#xA;    stream->time_base.num = 1;&#xA;    stream->time_base.den = fps_;&#xA;    avio_open(&amp;(ofmt_ctx->pb), ofmt_ctx->filename, AVIO_FLAG_WRITE);&#xA;&#xA;    /* Write a file for VLC */&#xA;    char buf[200000];&#xA;    AVFormatContext *ac[] = {ofmt_ctx};&#xA;    av_sdp_create(ac, 1, buf, 20000);&#xA;    printf("sdp:\n%s\n", buf);&#xA;    FILE *fsdp = fopen("test.sdp", "w");&#xA;    fprintf(fsdp, "%s", buf);&#xA;    fclose(fsdp);&#xA;&#xA;    swsctx = sws_getContext(width_, height_, AV_PIX_FMT_BGR24, width_, height_,&#xA;                            out_codec_ctx->pix_fmt, SWS_BICUBIC, nullptr,&#xA;                            nullptr, nullptr);&#xA;  }&#xA;&#xA;  if (!frame_) {&#xA;    frame_ = av_frame_alloc();&#xA;&#xA;    std::uint8_t *framebuf = new uint8_t[av_image_get_buffer_size(&#xA;        codec_ctx->pix_fmt, width_, height_, 1)];&#xA;    av_image_fill_arrays(frame_->data, frame_->linesize, framebuf,&#xA;                         codec_ctx->pix_fmt, width, height, 1);&#xA;    frame_->width = width_;&#xA;    frame_->height = height_;&#xA;    frame_->format = static_cast<int>(codec_ctx->pix_fmt);&#xA;    success = avformat_write_header(ofmt_ctx, nullptr);&#xA;  }&#xA;  if (imgbuf.empty()) {&#xA;    imgbuf.resize(height_ * width_ * 3 &#x2B; 16);&#xA;    canvas_ = cv::Mat(height_, width_, CV_8UC3, imgbuf.data(), width_ * 3);&#xA;  } else {&#xA;    image.copyTo(canvas_);&#xA;  }&#xA;&#xA;  const int stride[] = {static_cast<int>(image.step[0])};&#xA;&#xA;  sws_scale(swsctx, &amp;canvas_.data, stride, 0, canvas_.rows, frame_->data,&#xA;            frame_->linesize);&#xA;  frame_->pts &#x2B;= av_rescale_q(1, out_codec_ctx->time_base, stream->time_base);&#xA;&#xA;  AVPacket pkt = {0};&#xA;  avcodec_send_frame(out_codec_ctx, frame_);&#xA;  avcodec_receive_packet(out_codec_ctx, &amp;pkt);&#xA;  av_interleaved_write_frame(ofmt_ctx, &amp;pkt);&#xA;}&#xA;</int></int>

    &#xA;

    Can anyone offer some advice here ?

    &#xA;

    &#xA;

    Update

    &#xA;

    When setting

    &#xA;

    this->out_codec_ctx->flags |=AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;

    &#xA;

    extradata is actually present in the codec context, but I had to move avcodec_parameters_from_context() after avcodec_open2(), as the extradata is empty before opening the codec. I now get sprop-parameter-sets in the SDP file, but VLC still does not play it.

    &#xA;