Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (8)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

Sur d’autres sites (3418)

  • [FFmpeg]how to make codes for converting jpg files to avi(motion jpeg)

    13 avril 2016, par YJJ

    I want to make the code so that I can embed the code to a machine with cameras.

    I have one I have worked on.

    It generates a output avi file, but it doesn’t work.

    I think I didn’t make a logic to input raw images and I don’t know how.

    I want to input 100 jpg images from street_01.jpg to street_99.jpg

    int main(int argc, char* argv[])
    {
       AVFormatContext* pFormatCtx;
       AVOutputFormat* fmt;
       AVStream* video_st;
       AVCodecContext* pCodecCtx;
       AVCodec* pCodec;
       AVPacket pkt;
       uint8_t* picture_buf;
       AVFrame* pFrame;
       int picture_size;
       int y_size;
       int framecnt = 0;
       //FILE *in_file = fopen("src01_480x272.yuv", "rb"); //Input raw YUV data
       FILE *in_file = fopen("street_01.jpg", "rb");       //Input raw YUV data
       int in_w = 2456, in_h = 2058;                       //Input data's width and height
       int framenum = 100;                                 //Frames to encode
       //const char* out_file = "src01.h264";              //Output Filepath
       //const char* out_file = "src01.ts";
       //const char* out_file = "src01.hevc";
       const char* out_file = "output.avi";

       av_register_all();
    /*
       //Method1.
       pFormatCtx = avformat_alloc_context();
       //Guess Format
       fmt = av_guess_format(NULL, out_file, NULL);
       pFormatCtx->oformat = fmt;
    */
       //Method 2.
       avformat_alloc_output_context2(&pFormatCtx, NULL, "avi", out_file);
       fmt = pFormatCtx->oformat;


       //Open output URL
       if (avio_open(&pFormatCtx->pb, out_file, AVIO_FLAG_READ_WRITE) < 0){
           printf("Failed to open output file! \n");
           return -1;
       }

       video_st = avformat_new_stream(pFormatCtx, 0);
       video_st->time_base.num = 1;
       video_st->time_base.den = 25;

       if (video_st == NULL){
           return -1;
       }
       //Param that must set
       pCodecCtx = video_st->codec;
       //pCodecCtx->codec_id =AV_CODEC_ID_HEVC;
       pCodecCtx->codec_id = AV_CODEC_ID_MJPEG;
       //pCodecCtx->codec_id = fmt->video_codec;
       pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
       pCodecCtx->pix_fmt = AV_PIX_FMT_YUV444P;
       pCodecCtx->width = in_w;
       pCodecCtx->height = in_h;
       pCodecCtx->time_base.num = 1;
       pCodecCtx->time_base.den = 25;
       pCodecCtx->bit_rate = 400000;
       pCodecCtx->gop_size = 250;
       //H264
       //pCodecCtx->me_range = 16;
       //pCodecCtx->max_qdiff = 4;
       //pCodecCtx->qcompress = 0.6;
       pCodecCtx->qmin = 10;
       pCodecCtx->qmax = 51;

       //Optional Param
       pCodecCtx->max_b_frames = 3;

       // Set Option
       AVDictionary *param = 0;
       //H264
       if (pCodecCtx->codec_id == AV_CODEC_ID_H264) {
           av_dict_set(&param, "preset", "slow", 0);
           av_dict_set(&param, "tune", "zerolatency", 0);
           //av_dict_set(&param, "profile", "main", 0);
       }
       //H265
       if (pCodecCtx->codec_id == AV_CODEC_ID_H265){
           av_dict_set(&param, "preset", "ultrafast", 0);
           av_dict_set(&param, "tune", "zero-latency", 0);
       }

       //Show some Information
       av_dump_format(pFormatCtx, 0, out_file, 1);

       pCodec = avcodec_find_encoder(pCodecCtx->codec_id);
       if (!pCodec){
           printf("Can not find encoder! \n");
           return -1;
       }
       if (avcodec_open2(pCodecCtx, pCodec, &param) < 0){
           printf("Failed to open encoder! \n");
           return -1;
       }


       pFrame = av_frame_alloc();
       //picture_size = av_image_get_buffer_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, 1);
       picture_size = avpicture_get_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
       picture_buf = (uint8_t *)av_malloc(picture_size);
       avpicture_fill((AVPicture *)pFrame, picture_buf, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);

       //Write File Header
       avformat_write_header(pFormatCtx, NULL);

       av_new_packet(&pkt, picture_size);

       y_size = pCodecCtx->width * pCodecCtx->height;

       for (int i = 0; i/Read raw YUV data
           if (fread(picture_buf, 1, y_size * 3 / 2, in_file) <= 0){
               printf("Failed to read raw data! \n");
               return -1;
           }
           else if (feof(in_file)){
               break;
           }
           pFrame->data[0] = picture_buf;                  // Y
           pFrame->data[1] = picture_buf + y_size;         // U
           pFrame->data[2] = picture_buf + y_size * 5 / 4; // V
           //PTS
           pFrame->pts = i;
           int got_picture = 0;
           //Encode
           int ret = avcodec_encode_video2(pCodecCtx, &pkt, pFrame, &got_picture);
           if (ret < 0){
               printf("Failed to encode! \n");
               return -1;
           }
           if (got_picture == 1){
               printf("Succeed to encode frame: %5d\tsize:%5d\n", framecnt, pkt.size);
               framecnt++;
               pkt.stream_index = video_st->index;
               ret = av_write_frame(pFormatCtx, &pkt);
               av_free_packet(&pkt);
           }
       }
       //Flush Encoder
       int ret = flush_encoder(pFormatCtx, 0);
       if (ret < 0) {
           printf("Flushing encoder failed\n");
           return -1;
       }

       //Write file trailer
       av_write_trailer(pFormatCtx);

       //Clean
       if (video_st){
           avcodec_close(video_st->codec);
           av_free(pFrame);
           av_free(picture_buf);
       }
       avio_close(pFormatCtx->pb);
       avformat_free_context(pFormatCtx);

       fclose(in_file);

       return 0;
    }
  • ffmpeg - escaping single quotes doesn't work [duplicate]

    18 septembre 2022, par XorOrNor

    I've written a small python script for mass converting audio files. It uses ffmpeg. The problem is it doesn't work for files with single quotes in their filenames.

    


    script :

    


    
import os
import subprocess
import sys
from multiprocessing.pool import ThreadPool as Pool

source_dir="/home/kris/Music/test"
output_dir="/home/kris/Music/test_opus"

def worker(file):

    try:    
        dirname=os.path.dirname(file)
        file=file.replace("'","\\\\'")
        filename=file.split('.flac')[0]
        
        input_file=f"'{source_dir}/{file}'"
        output_file=f"'{output_dir}/{filename}.opus'"
        cmd="ffmpeg -n -i "+input_file+" -c:a libopus -b:a 320k "+output_file
        print(cmd)
        result = subprocess.call(cmd,stdout=subprocess.PIPE,shell=True)
    except:
        print('item error')
        

def start():    
    threads=os.cpu_count()  
    pool = Pool(threads)
    files=os.listdir(source_dir)
    for item in files:
        pool.apply_async(worker, (item,))

    pool.close()
    pool.join()
        
start()



    


    Testing :

    


      

    1. Filename : I'm a file.flac

      


    2. 


    3. When escaping single quote ' with double backslashes \\ - file=file.replace("'","\\\\'") the cmd for ffmpeg is :

      


    4. 


    


    ffmpeg -n -i '/home/kris/Music/test/I\\'m a file.flac' -c:a libopus -b:a 320k '/home/kris/Music/test_opus/I\\'m a file.opus'


    


    ffmpeg returns an error : /home/kris/Music/test/I\\m: No such file or directory

    


      

    1. When escaping single quote ' with a single backslash \ - file=file.replace("'","\\'") the cmd for ffmpeg is :
    2. 


    


    ffmpeg -n -i '/home/kris/Music/test/I\'m a file.flac' -c:a libopus -b:a 320k '/home/kris/Music/test_opus/I\'m a file.opus'


    


    I got an error :

    


    /bin/sh: 1: Syntax error: Unterminated quoted string


    


    According to ffmpeg docs : https://ffmpeg.org/ffmpeg-utils.html#toc-Examples escaping with single backslash should work.

    


  • Revision d068d869b9 : sb8x8 integration in rd loop. Work-in-progress, not yet ready for review. TODO

    1er mai 2013, par Ronald S. Bultje

    Changed Paths :
     Modify /vp9/common/vp9_blockd.h


     Modify /vp9/common/vp9_entropymode.c


     Modify /vp9/common/vp9_entropymode.h


     Modify /vp9/common/vp9_enums.h


     Modify /vp9/common/vp9_findnearmv.h


     Modify /vp9/common/vp9_loopfilter.c


     Modify /vp9/common/vp9_onyxc_int.h


     Modify /vp9/common/vp9_reconinter.c


     Modify /vp9/decoder/vp9_decodemv.c


     Modify /vp9/decoder/vp9_decodframe.c


     Modify /vp9/encoder/vp9_bitstream.c


     Modify /vp9/encoder/vp9_block.h


     Modify /vp9/encoder/vp9_encodeframe.c


     Modify /vp9/encoder/vp9_encodeintra.c


     Modify /vp9/encoder/vp9_encodeintra.h


     Modify /vp9/encoder/vp9_encodemb.c


     Modify /vp9/encoder/vp9_encodemb.h


     Modify /vp9/encoder/vp9_modecosts.c


     Modify /vp9/encoder/vp9_onyx_if.c


     Modify /vp9/encoder/vp9_onyx_int.h


     Modify /vp9/encoder/vp9_quantize.c


     Modify /vp9/encoder/vp9_ratectrl.c


     Modify /vp9/encoder/vp9_rdopt.c


     Modify /vp9/encoder/vp9_rdopt.h


     Modify /vp9/encoder/vp9_segmentation.c


     Modify /vp9/encoder/vp9_tokenize.c



    sb8x8 integration in rd loop.

    Work-in-progress, not yet ready for review. TODO items :
    - bitstream writing (encoder) and reading (decoder)
    - decoder reconstruction

    Change-Id : I5afb7284e7e0480847b47cd0097cb469433c9081