Recherche avancée

Médias (0)

Mot : - Tags -/médias

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (111)

  • 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

  • Soumettre bugs et patchs

    10 avril 2011

    Un logiciel n’est malheureusement jamais parfait...
    Si vous pensez avoir mis la main sur un bug, reportez le dans notre système de tickets en prenant bien soin de nous remonter certaines informations pertinentes : le type de navigateur et sa version exacte avec lequel vous avez l’anomalie ; une explication la plus précise possible du problème rencontré ; si possibles les étapes pour reproduire le problème ; un lien vers le site / la page en question ;
    Si vous pensez avoir résolu vous même le bug (...)

Sur d’autres sites (11157)

  • node.js ffmpeg pass directly to aws s3 bucket

    30 décembre 2022, par Eivydas Vickus

    How to pass ffmpeg output directly to aws s3 bucket ? It should not store output file on my pc. This is my code.

    


    &#xA;    import {&#xA;      DeleteObjectCommand,&#xA;      GetObjectCommand,&#xA;      PutObjectCommand,&#xA;      PutObjectCommandInput,&#xA;      S3,&#xA;      S3Client,&#xA;    } from &#x27;@aws-sdk/client-s3&#x27;;&#xA;    import { Inject, Injectable } from &#x27;@nestjs/common&#x27;;&#xA;    import { ConfigType } from &#x27;@nestjs/config&#x27;;&#xA;    import { nanoid } from &#x27;nanoid&#x27;;&#xA;    import awsConfig from &#x27;./aws.config&#x27;;&#xA;    import * as path from &#x27;path&#x27;;&#xA;    import { VideoInterface } from &#x27;../video/video.interface&#x27;;&#xA;    import { PassThrough } from &#x27;node:stream&#x27;;&#xA;&#xA;    @Injectable()&#xA;    export class S3BucketService {&#xA;      public readonly client = new S3Client({&#xA;        region: this.config.AWS_BUCKET_REGION,&#xA;        credentials: {&#xA;          accessKeyId: this.config.AWS_ACCESS_KEY,&#xA;          secretAccessKey: this.config.AWS_SECRET_KEY,&#xA;        },&#xA;      });&#xA;      constructor(&#xA;        @Inject(awsConfig.KEY)&#xA;        private readonly config: ConfigType<typeof awsconfig="awsconfig">,&#xA;      ) {}&#xA;&#xA;      async videoPut(putObjectInput: Omit) {&#xA;        return new PutObjectCommand({&#xA;          ...putObjectInput,&#xA;          Bucket: this.config.AWS_BUCKET_NAME,&#xA;        });&#xA;      }&#xA;&#xA;      async uploadFile({ fileName, file, folder }: VideoInterface) {&#xA;        const fullPath = path.normalize(`${folder}/${fileName}`);&#xA;        return await this.client.send(&#xA;          await this.videoPut({&#xA;            Key: fullPath,&#xA;            Body: file,&#xA;          }),&#xA;        );&#xA;      }&#xA;     }&#xA;</typeof>

    &#xA;

    &#xA;        const passthroughs = new PassThrough();&#xA;        await new Promise<void>(async (resolve, reject) => {&#xA;          ffmpeg(fs.createReadStream(file.path))&#xA;            .format(&#x27;webm&#x27;)&#xA;            .outputOptions([&#xA;              `-vf scale=${videoOptions[2].scale}`,&#xA;              `-b:v ${videoOptions[2].avgBitRate}`,&#xA;              `-minrate ${videoOptions[2].minBitRate}`,&#xA;              `-maxrate ${videoOptions[2].maxBitRate}`,&#xA;              `-tile-columns ${videoOptions[2].tileColumns}`,&#xA;              `-g ${videoOptions[2].g}`,&#xA;              `-threads ${videoOptions[2].threads}`,&#xA;              `-quality ${videoOptions[2].quality}`,&#xA;              `-crf ${videoOptions[2].crf}`,&#xA;              `-c:v ${videoOptions[2].videoCodec}`,&#xA;              `-c:a ${videoOptions[2].audioCodec}`,&#xA;              `-speed ${videoOptions[2].speed}`,&#xA;              `-y`,&#xA;            ])&#xA;            .pipe(passthroughs, { end: true })&#xA;            .on(&#x27;error&#x27;, (err) => {&#xA;              reject(err);&#xA;              throw new InternalServerErrorException(err);&#xA;            })&#xA;            .on(&#x27;data&#x27;, (data) => {&#xA;              console.log({ data });&#xA;            })&#xA;            .on(&#x27;end&#x27;, async () => {&#xA;              console.log(&#x27;Video conversion complete&#x27;);&#xA;              resolve();&#xA;            });&#xA;        });&#xA;&#xA;        await this.s3BucketService.uploadFile({&#xA;          folder: AwsFolder.VIDEOS,&#xA;          file: passthroughs,&#xA;          fileName: `${nanoid()}_${videoOptions[2].scale}.webm`,&#xA;        });&#xA;&#xA;</void>

    &#xA;

    However i am getting error Error: Output stream closed. I saw on google different variants with Passthrough none of them are working. So how it should be done ? By The Way I am using @aws-sdk/client-s3 and most solutions on google is using aws sdk-2. Maybe streams work different with version 3 ?

    &#xA;

  • website performance issues when using ffmpeg on separate server

    10 décembre 2018, par Rich

    I am currently working on a site that uses wordpress and ffmpeg. I have it setup so that I have 3 servers - main, database, ffmpeg. So far I have it all working, however I am still running into issues when I am trying to encode a video.

    Whenever I start encoding a video, if I try opening any other links in a new tab, it gets stuck on loading until ffmpeg is done. I dont understand why, since im using multiple servers.

    My specs for my servers —

    Main (web server) - 4 vCPUs / 8GB RAM / 160GB Disk

    Database server - 2 vCPUs / 4GB RAM / 80GB Disk

    Ffmpeg server - 8 vCPUs / 32GB / 640GB Disk

    They are all in the same region as well, and I have private IPs as public for them. Public IPs uses IPv4.

    On my template page I have a form that the users fills out and uploads images, then using ajax it sends the info to my ffmpeg functions in my functions.php file.

    Images are uploaded to the main server and then on that server in my functions.php file I use ssh2 to login to the ffmpeg server and run different commands, for example —

    $server   = "FFMPEG SERVER IP"; // server IP/hostname of the SSH server
    $username = "user"; // username for the user you are connecting as on the SSH server
    $password = "pass"; // password for the user you are connecting as on the SSH server
    // Establish a connection to the SSH Server. Port is the second param.
    $connection = ssh2_connect($server, 22);
    // Authenticate with the SSH server
    ssh2_auth_password($connection, $username, $password);
    $sftp = ssh2_sftp($connection);
    ssh2_sftp_mkdir($sftp, $thepathw);

    $command = '/usr/local/bin/ffmpeg -threads 1 -i '.$thepath .'/audio.mp3 -safe 0 -f concat -i '.$thepath.'/paths.txt -vf "scale=1280:720,setsar=1" -pix_fmt yuv420p -c:a aac -af "volume=-5dB" -c:v libx264 -movflags +faststart '.$fixedtime.' -y '.$output.' 2>&amp;1';

    // Execute a command on the connected server and capture the response
    $stream = ssh2_exec($connection, $command);
    // Sets blocking mode on the stream
    stream_set_blocking($stream, true);
    // Get the response of the executed command in a human readable form
    $output1 = stream_get_contents($stream);
    // echo output
    echo $output1;

    The video file that is created is then saved to the ffmpeg server.

    This all works as should and Im able to create videos, but the rest of the site doesnt seem to respond/load until ffmpeg is done. This is a big problem since I plan on having multiple users at once on the site.

    So how can I improve this setup so that the ffmpeg server doesnt slow down the main server, and multiple users can safely use the site ?

    Im also open to the idea of getting another server to upload my images to, instead of on the main. Im not sure if that would help though cause it seems like a lot of pulling/sending data between multiple sources/IPs may slow down the response time.

    Any suggestions is appreciated, thanks.

  • ffmpeg concatenating videos of different fps while keeping the total length not changed

    23 novembre 2017, par A_Matar

    I wanna pad an mp4 video stream with another video clip of a static image that I created using :

    def generate_white_vid (duration):
       output_filename = os.path.join(p_path,'white_vid_'+" 0:.2f}".format(duration)+'.mp4')
       ffmpeg_create_vid_from_static_img = 'ffmpeg -loop 1 -i /path/WhiteBackground.jpg -c:v libx264 -t %f -pix_fmt yuv420p -vf scale=1920:1080 %s' % (duration, output_filename)
       p = subprocess.Popen(ffmpeg_create_vid_from_static_img, shell=True)
       p.communicate()
       return output_filename

    I use the following to concatenate :

    def concat_vids(clip_paths):
       filenames_txt = open('clips_to_join.txt','w')
       for clip in clip_paths:
           filenames_txt.write ('file \''+ clip+'\'\n')
       filenames_txt.close()
       output_filename = clip_paths[0].split('.', 2)[0]
       output_file_path = os.path.join(root_path, output_filename+'-padded.mp4')
       # join the clips
       ffmpeg_command = ["ffmpeg", "-f", "concat", "-safe", "0", "-i", "clips_to_join.txt", "-codec", "copy", output_file_path] # output_filename = ch0X-start_time-end_time
       p = subprocess.Popen(ffmpeg_command)
       p.communicate() # wait till the subprocess finishes. You can send commands to process as well.
       return output_file_path

    When I check the length of the resulting video after concatenation, I find that it is not equal to the sum of the two segments that I concatenated, and sometimes it is even less by some seconds !!

    Here is how I get the video length in seconds :

    def ffmpeg_len(vid_path):
       '''
       Returns length in seconds using ffmpeg
       '''
       ffmpeg_get_mediafile_length = ['sh', '-c', 'ffmpeg -i "$1" 2>&amp;1 | grep Duration', '_', vid_path]
       p = subprocess.Popen(ffmpeg_get_mediafile_length, stdout=subprocess.PIPE, stderr=subprocess.PIPE)    
       output, err = p.communicate()
       length_regexp = 'Duration: (\d{2}):(\d{2}):(\d{2})(\.\d+),'
       re_length = re.compile(length_regexp)
       matches = re_length.search(output)
       if matches:
           video_length = int(matches.group(1)) * 3600 + \
                           int(matches.group(2)) * 60 + \
                           int(matches.group(3)) + float(matches.group(4))
           return video_length
       else:
           print("Can't determine video length.")
           print err
           raise SystemExit

    My guess is that maybe the concatenation unifies the fps rate for the all the clips to be joined, if this is the case, how to prevent this from happening ? How can I get a video of the desired length exactly.

    Maybe it worth mentioning that the video to padded is very short 0.42 second, the original video is 210.58 and the resultant video is 210.56 !

    I have verified that ffmpeg does generate the desired padding region and it is of the desired length 0.42 I got a 0.43 segment when I forced 30 fps but it is okay.