Recherche avancée

Médias (1)

Mot : - Tags -/wave

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 (7558)

  • Error Error sending packet to decoder -1094995529 when extracting audio from MP4 using FFmpeg C API

    28 août 2024, par Saad Out03

    I am trying to extract audio from an MP4 file and save it as an MP3 using the FFmpeg C API. My code is able to identify the audio stream, set up the codec contexts, and start reading packets. However, I encounter an error when sending packets to the decoder.

    


    Purpose of the Code :

    


      

    • Open the input video file and retrieve the stream information.
    • 


    • Identify the audio stream and set up decoding with the appropriate codec.
    • 


    • Set up the output format for the MP3 file and configure codec parameters.
    • 


    • Read packets from the input file and send them to the decoder.
    • 


    


    Here's the part of the code that reads packets and sends them to the decoder :

    


        // read packets
    AVFrame *pframe = av_frame_alloc();
    if (!pframe)
        return (printf("Could not allocate packet frame\n"), 1);
    AVPacket pkt;
    while (1)
    {
        if (av_read_frame(fmt_ctx, &pkt) < 0)
            break;
        printf("packet stream index %d\n", pkt.stream_index);
        if ((pkt.stream_index) == audio_stream_index)
        {
            printf("packet size %d\n", pkt.size);
            int ret = avcodec_send_packet(cd_ctx, &pkt);
            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
                printf("EAGAIN or EOF\n");
            else if (ret < 0)
                return (printf("Error sending packet to decoder %d\n", ret), 1);
        }
    }



    


    Error output :

    


    format mov,mp4,m4a,3gp,3g2,mj2 duration 2.550000
nb of streams 2
stream 0 => id: 1 => type: video
stream 1 => id: 2 => type: audio
audio stream index 1
Output #0, mp3, to 'audio.mp3':
  Stream #0:0: Audio: mp3 (libmp3lame) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    reading packets....
packet stream index 0
packet stream index 0
packet stream index 1
packet size 371
Error sending packet to decoder -1094995529



    


    What could be causing this error, and how can I correct it ? Any guidance on proper handling of packets with FFmpeg’s C API would be greatly appreciated.

    


    Full code for context :

    


    #include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include &#xA;&#xA;#define RED "\033[0;31m"&#xA;#define GREEN "\033[0;32m"&#xA;#define RESET "\033[0m"&#xA;&#xA;int main(int ac, char **av)&#xA;{&#xA;    if (ac != 3)&#xA;    {&#xA;        printf("Usage: %s <input file="file" /> <output file="file">\n", av[0]);&#xA;        return 1;&#xA;    }&#xA;&#xA;    AVCodec *codec = NULL;&#xA;    AVCodecContext *cd_ctx = NULL;&#xA;    AVOutputFormat *out_format = NULL;&#xA;    AVFormatContext *out_ctx = NULL;&#xA;    AVCodec *out_codec = NULL;&#xA;    AVStream *in_stream = NULL, *out_stream = NULL;&#xA;&#xA;    // allocate format context&#xA;    AVFormatContext *fmt_ctx = avformat_alloc_context();&#xA;    if (!fmt_ctx)&#xA;        return (printf("Could not allocate format context\n"), 1);&#xA;&#xA;    // open input file&#xA;    if (avformat_open_input(&amp;fmt_ctx, av[1], NULL, NULL) != 0)&#xA;        return (printf("Could not open input file\n"), 1);&#xA;&#xA;    printf("format %s duration %f\n",&#xA;            fmt_ctx->iformat->name,&#xA;            (double)(fmt_ctx->duration / 1000000) / (double)60);&#xA;    &#xA;    // get stream info&#xA;    if (avformat_find_stream_info(fmt_ctx, NULL) &lt; 0)&#xA;        return (printf("Could not get stream info\n"), 1);&#xA;    &#xA;    printf("nb of streams %d\n", fmt_ctx->nb_streams);&#xA;    int audio_stream_index = -1;&#xA;    // loop through streams&#xA;    for (unsigned int i = 0; i &lt; fmt_ctx->nb_streams; i&#x2B;&#x2B;)&#xA;    {&#xA;        printf("stream %d => id: %d => type: ", i, fmt_ctx->streams[i]->id);&#xA;        // check stream type&#xA;        if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)&#xA;        {&#xA;            printf("audio\n");&#xA;&#xA;            audio_stream_index = i;&#xA;            printf("audio stream index %d\n", audio_stream_index);&#xA;        }&#xA;        else if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;            printf("video\n");&#xA;        else&#xA;            printf("other\n");&#xA;    }&#xA;&#xA;&#xA;    // get codec&#xA;    codec = avcodec_find_decoder(fmt_ctx->streams[audio_stream_index]->codecpar->codec_id);&#xA;    if (!codec)&#xA;        return (printf("Could not find codec\n"), 1);&#xA;&#xA;    // allocate codec context&#xA;    cd_ctx = avcodec_alloc_context3(codec);&#xA;    if (!cd_ctx)&#xA;        return (printf("Could not allocate codec context\n"), 1);&#xA;    &#xA;    // open codec&#xA;    if (avcodec_open2(cd_ctx, codec, NULL) &lt; 0)&#xA;        return (printf("Could not open codec\n"), 1);&#xA;    &#xA;    // get codec format&#xA;    out_format = av_guess_format(NULL, av[2], NULL);&#xA;    if (!out_format)&#xA;        return (printf("Could not guess out format\n"), 1);&#xA;&#xA;    // allocate output context&#xA;    out_ctx = NULL;&#xA;    if (avformat_alloc_output_context2(&amp;out_ctx, NULL, NULL, av[2]) &lt; 0)&#xA;        return (printf("Could not allocate context for output\n"), 1);&#xA;&#xA;    // find encoder for output format&#xA;    out_codec = avcodec_find_encoder(out_format->audio_codec);&#xA;    if (!out_codec)&#xA;        return (printf("Could not find encoder\n"), 1);&#xA;    &#xA;    in_stream = fmt_ctx->streams[audio_stream_index];&#xA;&#xA;    // create new stream&#xA;    if ((out_stream = avformat_new_stream(out_ctx, out_codec)) == NULL)&#xA;        return (printf("Could not create new stream\n"), 1);&#xA;    &#xA;    // Fill output codec context with desired sample rate, sample fmt, channel etc.&#xA;    AVCodecParameters *in_codecpar = in_stream->codecpar;&#xA;    AVCodecParameters *out_codecpar = out_stream->codecpar;&#xA;    int ret = avcodec_parameters_copy(out_codecpar, in_codecpar);&#xA;    if (ret &lt; 0)&#xA;        return (printf("Could not copy codec parameters\n"), 1);&#xA;&#xA;    // Set codec ID to MP3&#xA;    out_codecpar->codec_id = AV_CODEC_ID_MP3;&#xA;&#xA;    // Ensure codec parameters match MP3 requirements&#xA;    out_codecpar->format = AV_SAMPLE_FMT_FLTP; // Set to a format suitable for MP3&#xA;    out_codecpar->codec_type = AVMEDIA_TYPE_AUDIO;&#xA;    out_codecpar->sample_rate = 44100; // Set the desired sample rate, e.g., 44100 Hz&#xA;    out_codecpar->channel_layout = AV_CH_LAYOUT_STEREO; // Stereo layout&#xA;    out_codecpar->channels = 2; // Number of audio channels&#xA;&#xA;    av_dump_format(out_ctx, 0, av[2], 1);&#xA;&#xA;    // open output file&#xA;    if (avio_open(&amp;out_ctx->pb, av[2], AVIO_FLAG_WRITE) > 0)&#xA;        return (printf("Could not open out file\n"), 1);&#xA;    &#xA;    // write headers&#xA;    if (avformat_write_header(out_ctx, NULL) &lt; 0)&#xA;        return (printf("Could not write headers\n"), 1);&#xA;    &#xA;&#xA;    printf("\treading packets....\n");&#xA;&#xA;&#xA;    // read packets&#xA;    AVFrame *pframe = av_frame_alloc();&#xA;    if (!pframe)&#xA;        return (printf("Could not allocate packet frame\n"), 1);&#xA;    AVPacket pkt;&#xA;    while (1)&#xA;    {&#xA;        if (av_read_frame(fmt_ctx, &amp;pkt) &lt; 0)&#xA;            break;&#xA;        printf("packet stream index %d\n", pkt.stream_index);&#xA;        if ((pkt.stream_index) == audio_stream_index)&#xA;        {&#xA;            printf("packet size %d\n", pkt.size);&#xA;            int ret = avcodec_send_packet(cd_ctx, &amp;pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                printf("EAGAIN or EOF\n");&#xA;            else if (ret &lt; 0)&#xA;                return (printf("Error sending packet to decoder %d\n", ret), 1);&#xA;        }&#xA;    }&#xA;&#xA;    printf("done\n");&#xA;    return 0;&#xA;}&#xA;&#xA;</output>

    &#xA;

  • Have problems using FFMPEG to save RGB image sequence to .mp4

    28 septembre 2021, par Clubs

    I render some images with OpenGL and need to compose them into a video file. Each of the images is a sequence of uint8_t values representing a sRGB color component (image array looks like ...rgbrgbrgb...)

    &#xA;&#xA;

    I know very little about video processing and have no experience with ffmpeg libraries at all. I made a little test program using these sources as reference :

    &#xA;&#xA;

    https://ffmpeg.org/doxygen/trunk/encode_video_8c-example.html

    &#xA;&#xA;

    How to convert RGB from YUV420p for ffmpeg encoder ?

    &#xA;&#xA;

    The test program is supposed to make a video about growing green vertical stripe. I'm just trying to figure out how to make a video using some source of raw RGB data.

    &#xA;&#xA;

    Here is my code :

    &#xA;&#xA;

    #include <iostream>&#xA;#include <vector>&#xA;#include <algorithm>&#xA;&#xA;extern "C" {&#xA;    #include <libavcodec></libavcodec>avcodec.h>&#xA;    #include <libavutil></libavutil>opt.h>&#xA;    #include <libavutil></libavutil>imgutils.h>&#xA;    #include <libswscale></libswscale>swscale.h>&#xA;}&#xA;&#xA;static void encode( AVCodecContext* enc_ctx,&#xA;                    AVFrame* frame, AVPacket* pkt,&#xA;                    FILE* outfile                  )&#xA;{&#xA;    int ret;&#xA;    ret = avcodec_send_frame(enc_ctx, frame);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error sending a frame for encoding\n";&#xA;        return;&#xA;    }&#xA;    while (ret >= 0) {&#xA;        ret = avcodec_receive_packet(enc_ctx, pkt);&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;            return;&#xA;        else if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error during encoding\n");&#xA;            exit(1);&#xA;        }&#xA;        fwrite(pkt->data, 1, pkt->size, outfile);&#xA;        av_packet_unref(pkt);&#xA;    }&#xA;}&#xA;&#xA;static constexpr int w = 1920, h = 1080;&#xA;static constexpr float fps = 20.f, time = 5.f;&#xA;static constexpr int nFrames = static_cast<int>(fps * time);&#xA;static std::vector imageRGB(w * h * 3, 0);&#xA;&#xA;static void UpdateImageRGB()&#xA;{&#xA;    static int d = 50;&#xA;    imageRGB.assign(w * h * 3, 0);&#xA;    for (int i = 0; i &lt; h; &#x2B;&#x2B;i)&#xA;        for ( int j = std::max(0, w / 2 - d);&#xA;              j &lt; std::min(w, w / 2 &#x2B; d);&#xA;              &#x2B;&#x2B;j                             )&#xA;        {&#xA;            imageRGB[(w * i &#x2B; j) * 3 &#x2B; 0] = 50;&#xA;            imageRGB[(w * i &#x2B; j) * 3 &#x2B; 1] = 200;&#xA;            imageRGB[(w * i &#x2B; j) * 3 &#x2B; 2] = 50;&#xA;        }&#xA;    d &#x2B;= 5;&#xA;}&#xA;&#xA;int main()&#xA;{&#xA;    int ret = 0;&#xA;    auto filename = "test.mp4";&#xA;&#xA;    auto codec = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;    if (!codec) {&#xA;        std::cerr &lt;&lt; "Codec \"x.264\" not found\n";&#xA;        return 1;&#xA;    }&#xA;    auto c = avcodec_alloc_context3(codec);&#xA;    if (!c) {&#xA;        std::cerr &lt;&lt; "Could not allocate video codec context\n";&#xA;        return 1;&#xA;    }&#xA;    auto pkt = av_packet_alloc();&#xA;    if (!pkt) return 1;&#xA;&#xA;    // 1.8 bits / (pixel * frame)&#xA;    c->bit_rate = static_cast(1.8f * w * h * fps);&#xA;    /* resolution must be a multiple of two */&#xA;    c->width = w;&#xA;    c->height = h;&#xA;    /* frames per second */&#xA;    c->time_base = AVRational{ 1, static_cast<int>(fps) };&#xA;    c->framerate = AVRational{ static_cast<int>(fps), 1 };&#xA;&#xA;    c->gop_size = 10;&#xA;    c->max_b_frames = 1;&#xA;    c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;    av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;    av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;&#xA;    ret = avcodec_open2(c, codec, NULL);&#xA;    if (ret &lt; 0) {&#xA;        char str[AV_ERROR_MAX_STRING_SIZE];&#xA;        std::cerr &lt;&lt; "Could not open codec: "&#xA;                  &lt;&lt; av_make_error_string(str, AV_ERROR_MAX_STRING_SIZE, ret)&#xA;                  &lt;&lt; "\n";&#xA;        return 1;&#xA;    }&#xA;&#xA;    FILE * f;&#xA;    fopen_s(&amp;f, filename, "wb");&#xA;    if (!f) {&#xA;        std::cerr &lt;&lt; "Could not open " &lt;&lt; filename &lt;&lt; &#x27;\n&#x27;;&#xA;        return 1;&#xA;    }&#xA;&#xA;    auto frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        std::cerr &lt;&lt; "Could not allocate video frame\n";&#xA;        return 1;&#xA;    }&#xA;    frame->format = c->pix_fmt;&#xA;    frame->width = c->width;&#xA;    frame->height = c->height;&#xA;    ret = av_frame_get_buffer(frame, 0);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; stderr, "Could not allocate the video frame data\n";&#xA;        return 1;&#xA;    }&#xA;&#xA;    SwsContext* ctx = sws_getContext( w, h, AV_PIX_FMT_RGB24,&#xA;                                      w, h, AV_PIX_FMT_YUV420P,&#xA;                                      0, 0, 0, 0                );&#xA;&#xA;    for (int i = 0; i &lt; nFrames; i&#x2B;&#x2B;)&#xA;    {&#xA;        ret = av_frame_make_writable(frame);&#xA;        UpdateImageRGB();&#xA;        static const uint8_t* rgbData[1] = { &amp;imageRGB[0] };&#xA;        static constexpr int rgbLinesize[1] = { 3 * w };&#xA;        sws_scale( ctx, rgbData, rgbLinesize, 0, h,&#xA;                   frame->data, frame->linesize     );&#xA;        frame->pts = i;&#xA;        /* encode the image */&#xA;        encode(c, frame, pkt, f);&#xA;    }&#xA;    encode(c, NULL, pkt, f);&#xA;&#xA;    fclose(f);&#xA;    avcodec_free_context(&amp;c);&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_free(&amp;pkt);&#xA;    return 0;&#xA;}&#xA;</int></int></int></algorithm></vector></iostream>

    &#xA;&#xA;

    The program generates 33.9k video file with further console output :

    &#xA;&#xA;

    [libx264 @ 0000020c18681800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2&#xA;[libx264 @ 0000020c18681800] profile High, level 5.0, 4:2:0, 8-bit&#xA;[libx264 @ 0000020c18681800] frame I:11    Avg QP: 0.00  size:   639&#xA;[libx264 @ 0000020c18681800] frame P:74    Avg QP: 0.32  size:   174&#xA;[libx264 @ 0000020c18681800] frame B:15    Avg QP: 2.26  size:   990&#xA;[libx264 @ 0000020c18681800] consecutive B-frames: 70.0% 30.0%&#xA;[libx264 @ 0000020c18681800] mb I  I16..4: 100.0%  0.0%  0.0%&#xA;[libx264 @ 0000020c18681800] mb P  I16..4:  0.6%  0.0%  0.0%  P16..4:  2.1%  0.0%  0.0%  0.0%  0.0%    skip:97.3%&#xA;[libx264 @ 0000020c18681800] mb B  I16..4:  0.1%  0.0%  0.0%  B16..8:  0.6%  0.0%  0.0%  direct: 0.6%  skip:98.7%  L0:39.8% L1:60.2% BI: 0.0%&#xA;[libx264 @ 0000020c18681800] final ratefactor: -46.47&#xA;[libx264 @ 0000020c18681800] 8x8 transform intra:0.0%&#xA;[libx264 @ 0000020c18681800] direct mvs  spatial:0.0% temporal:100.0%&#xA;[libx264 @ 0000020c18681800] coded y,uvDC,uvAC intra: 0.0% 0.1% 0.1% inter: 0.0% 0.1% 0.1%&#xA;[libx264 @ 0000020c18681800] i16 v,h,dc,p: 99%  0%  1%  0%&#xA;[libx264 @ 0000020c18681800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  0%  0% 100%  0%  0%  0%  0%  0%  0%&#xA;[libx264 @ 0000020c18681800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46%  0% 54%  0%  0%  0%  0%  0%  0%&#xA;[libx264 @ 0000020c18681800] i8c dc,h,v,p: 96%  1%  3%  0%&#xA;[libx264 @ 0000020c18681800] Weighted P-Frames: Y:0.0% UV:0.0%&#xA;[libx264 @ 0000020c18681800] ref P L0: 70.2%  0.0% 29.8%  0.0%  0.0%&#xA;[libx264 @ 0000020c18681800] kb/s:55.61&#xA;

    &#xA;&#xA;

      &#xA;
    1. "Media Player Classic" on Windows plays this video but the time slider doesn't move, and the video cannot be fast-forwarded to some frame
    2. &#xA;

    3. VLC cannot play the video at all. It launches, shows me VLC logo, and time slider (which is unusually big) jumps from left to right, not responding to my clicks
    4. &#xA;

    5. If I set time = 0.05 to make a video of only 1 frame, I cannot play it even with "Media Player Classic". I want to make an algorithm to convert the arbitrary number of raw RGB images into the video files, even if there's only one image, and with arbitrary image size (that is, width and height may be odd).
    6. &#xA;

    7. As I said, I don't really understand what am I doing. There are low-level codec settings in lines 83-84. Are they all right ?
    8. &#xA;

    9. Do I have to manually set a bit rate (line 75) ? Shouldn't it be calculated automatically by the codec ?
    10. &#xA;

    &#xA;

  • 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