Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (68)

Sur d’autres sites (11230)

  • Problem with ffmpeg and name change while loading on server

    29 novembre 2020, par Pajtim

    I am testing a code in php / ffmpeg it is watermark. It works very well after uploading the video but the problem is that the video should only be with an "input.mp4" name.

    


    I have set the path where the video should be saved and the name of each video is changed move_uploaded_file($_FILES["video"]["tmp_name"], "./" . ('input.mp4')); after it is uploaded to "input.mp4" but even this did not solve the problem.

    


    So it only works when you upload the video from the beginning named input.mp4.

    


    Is there an option ffmpeg to accept each name as input when uploading video with another name ?

    


    

    

    <form action="video.php" method="post" enctype="multipart/form-data">&#xA;         <div class="form-group">&#xA;                    <label>Select video</label>&#xA;                    <input type="file" class="form-control" />&#xA;                </div>&#xA; &#xA;                &#xA;                <input type="submit" class="btn btn-primary" value="submit" />&#xA;        </form>

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    $video = $_FILES["video"]["name"];&#xA;$image = $_FILES["image"]["name"];&#xA;move_uploaded_file($_FILES["video"]["tmp_name"], "./" . (&#x27;input.mp4&#x27;));&#xA;&#xA;// then you have to resize the selected image to lower resolution&#xA;$command = "/usr/local/bin/ffmpeg -i " . $image . " -s 128x128 output.jpeg";&#xA; &#xA;// execute that command&#xA;system($command);&#xA; &#xA;// both input files has been selected&#xA;$command = "/usr/local/bin/ffmpeg -i " . $video . " -i output.jpeg";&#xA; &#xA;// now apply the filter to select both files&#xA;// it must enclose in double quotes&#xA;// [0:v] means first input which is video&#xA;// [1:v] means second input which is resized image&#xA;$command .= " -filter_complex \"[0:v][1:v]";&#xA; &#xA;// now we need to tell the position of overlay in video&#xA;$command .= " overlay=80:50\""; // closing double quotes&#xA; &#xA;// save in a separate output file&#xA;$command .= " -c:a copy output.mp4";&#xA; &#xA;// execute the command&#xA;system($command);&#xA;&#xA;echo &#x27;<a href="http://stackoverflow.com/input.mp4" download="download">Download</a>&#x27;;&#xA;

    &#xA;

  • FFMPEG not creating thumbnails and converting videos

    10 juin 2014, par KartikA

    This is what I coded after reading many blogs and about FFMPEG

    $ffmpeg = "C:\\FFMPEG\\bin\\ffmpeg";
    $video_file_path = $_FILES["file"]["name"];
    $converted_video_path = "converted_videos/" . $video_file_path;
    $image = $name .".jpg";
    $imagepath="thumbnail/" . $image;
    echo "<br />";
    echo $video_file_path; echo "<br />";echo "<br />";
    echo $converted_video_path; echo "<br />";echo "<br />";
    echo $image; echo "<br />";echo "<br />";
    echo $imagepath;
    $size = "120x90";  
    $getFromSecond = 6;

    $cmd_thumbnail_create = ("$ffmpeg -i  C:\\xampp\\htdocs\\Media Barron\\assets\\uploaded_videos\\$video_file_path   -an -ss $getFromSecond -s $size C:\\xampp\\htdocs\\Media Barron\\assets\\thumbnail\\$image");

    $cmd_video_conversion = exec("$ffmpeg -i $video_file_path -qscale 4 -vcodec libx264 -f mp4 $converted_video_path.mp4");

    shell_exec($cmd_thumbnail_create);
    shell_exec($cmd_video_conversion);

    PS : I had double quotes on the addresses earlier and also tired "\uploaded_videos\video_file_path", "uploaded_videos\video_file_path", Single quotes, "\C :\xampp\htdocs\Media Barron\assets\uploaded_videos\$video_file_path\"

    This is the New script I have tried recently

     &lt;?php
     $ffmpeg = "C:\\FFMPEG\\bin\\ffmpeg";                                
     $video_file_path = $_FILES["file"]["name"];              
     $ffmpegVideoLocation = "C:\\xampp\\htdoc\\Media  Barron\\uploaded_videos\\".$video_file_path;
     $converted_video_path = "C:\\xampp\\htdoc\\Media Barron\\converted_videos\\" . $video_file_path;
     $image = $name .".jpg";
     $imagepath="thumbnail\\" . $image;
    echo "<br />";
    echo $video_file_path; echo "<br />";echo "<br />";
    echo $ffmpegVideoLocation; echo "<br />";echo "<br />";
    echo $converted_video_path; echo "<br />";echo "<br />";
    echo $image; echo "<br />";echo "<br />";
    echo $imagepath;
    $size = "120x90";  
    $getFromSecond = 6;


    $cmd_thumbnail_create = ("$ffmpeg -i $ffmpegVideoLocation  -an -ss $getFromSecond -s $size  $converted_video_path.jpg");
    $cmd_video_conversion = exec("$ffmpeg -i $ffmpegVideoLocation -qscale 4 -vcodec libx264 -f mp4 $converted_video_path.mp4");

      shell_exec($cmd_video_conversion);

    shell_exec($cmd_thumbnail_create);

    enter image description here

  • FFmpeg(C/libav) VPX to mpeg2video stream cannot be reproduce in VLC

    21 septembre 2017, par caiomcg

    I am currently trying to transcode a VPX(VP8/VP9) video to a mpeg2video and stream it over UDP with mpegts.

    I have initialized all of the contexts and the streams and as long as I stream it to ffplay it works, if I send the stream to VLC or another player, the receiver only display the first frame and do nothing else. If I do the same thing through the command line it works flawlessly - ffmpeg -re -i video.webm -an -f mpegts udp://127.0.0.1:8080

    My output context :

    this->output_codec_ctx_->codec_type    = AVMEDIA_TYPE_VIDEO; // Set media type
    this->output_codec_ctx_->pix_fmt       = AV_PIX_FMT_YUV420P; // Set stream pixel format
    this->output_codec_ctx_->time_base.den = ceil(av_q2d(input_stream->r_frame_rate));     // Add the real video framerate. Eg.: 29.9
    this->output_codec_ctx_->time_base.num = 1;                  // Numerator of the framerate. Eg.: num/29.9
    this->output_codec_ctx_->width         = input_stream->codecpar->width;  // Video width
    this->output_codec_ctx_->height        = input_stream->codecpar->height; // Video height
    this->output_codec_ctx_->bit_rate      = 400000; // Video quality
    this->output_codec_ctx_->gop_size      = 12;
    this->output_codec_ctx_->max_b_frames  = 2;
    this->output_codec_ctx_->framerate     = this->input_codec_ctx_->framerate;
    this->output_codec_ctx_->sample_aspect_ratio     = this->input_codec_ctx_->sample_aspect_ratio;

    My av_dump :

    Output #0, mpegts, to 'udp://127.0.0.1:20010':
     Metadata:
       encoder         : Lavf57.72.101
       Stream #0:0: Video: mpeg2video (Main), 1 reference frame, yuv420p, 480x640 (0x0), q=2-31, 400 kb/s, SAR 1:1 DAR 3:4, 24 fps, 24 tbr, 90k tbn

    FFMPEG av_dump :

    Output #0, mpegts, to 'udp://127.0.0.1:20010':
     Metadata:
       title           : Tears of Steel
       encoder         : Lavf57.72.101
       Stream #0:0: Video: mpeg2video (Main), yuv420p, 480x640 [SAR 1:1 DAR 3:4], q=2-31, 200 kb/s, 24 fps, 90k tbn, 24 tbc (default)
       Metadata:
         encoder         : Lavc57.96.101 mpeg2video
       Side data:
         cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1

    Any ideia on what I may be doing wrong ?