Recherche avancée

Médias (91)

Autres articles (112)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

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

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

Sur d’autres sites (9683)

  • fftools/ffplay : get rid of flush_pkt

    7 février 2021, par Marton Balint
    fftools/ffplay : get rid of flush_pkt
    

    The packet serial can be used instead to detect when a flush is needed.

    Signed-off-by : Marton Balint <cus@passwd.hu>

    • [DH] fftools/ffplay.c
  • ffmpeg takes too long to start

    17 octobre 2020, par Suspended

    I have this command in python script, in a loop :

    &#xA;

    ffmpeg -i somefile.mp4 -ss 00:03:12 -t 00:00:35 piece.mp4 -loglevel error -stats&#xA;

    &#xA;

    It cuts out pieces of input file (-i). Input filename, as well as start time (-ss) and length of the piece I cut out (-t) varies, so it reads number of mp4 files and cuts out number of pieces from each one. During execution of the script it might be called around 100 times. My problem is that each time before it starts, there is a delay of 6-15 seconds and it adds up to significant time. How can I get it to start immediately ?

    &#xA;

    Initially I thought it was process priority problem, but I noticed that even during the "pause", all processors work at 100%, so apparently some work is being done.

    &#xA;

    The script (process_videos.py) :

    &#xA;

    import subprocess&#xA;import sys&#xA;import math&#xA;import time&#xA;&#xA;class TF:&#xA;    """TimeFormatter class (TF).&#xA;This class&#x27; reason for being is to convert time in short&#xA;form, e.g. 1:33, 0:32, or 23 into long form accepted by&#xA;mp4cut function in bash, e.g. 00:01:22, 00:00:32, etc"""&#xA;&#xA;def toLong(self, shrt):&#xA;    """Converts time to its long form"""&#xA;    sx = &#x27;00:00:00&#x27;&#xA;    ladd = 8 - len(shrt)&#xA;    n = sx[:ladd] &#x2B; shrt&#xA;    return n&#xA;&#xA;def toShort(self, lng):&#xA;    """Converts time to short form"""&#xA;    if lng[0] == &#x27;0&#x27; or lng[0] == &#x27;:&#x27;:&#xA;        return self.toShort(lng[1:])&#xA;    else:&#xA;        return lng&#xA;&#xA;def toSeconds(self, any_time):&#xA;    """Converts time to seconds"""&#xA;    if len(any_time) &lt; 3:&#xA;        return int(any_time)&#xA;    tt = any_time.split(&#x27;:&#x27;)&#xA;    if len(any_time) &lt; 6:            &#xA;        return int(tt[0])*60 &#x2B; int(tt[1])&#xA;    return int(tt[0])*3600 &#x2B; int(tt[1])*60 &#x2B; int(tt[2])&#xA;&#xA;def toTime(self, secsInt):&#xA;    """"""&#xA;    tStr = &#x27;&#x27;&#xA;    hrs, mins, secs = 0, 0, 0&#xA;    if secsInt >= 3600:&#xA;        hrs = math.floor(secsInt / 3600)&#xA;        secsInt = secsInt % 3600&#xA;    if secsInt >= 60:&#xA;        mins = math.floor(secsInt / 60)&#xA;        secsInt = secsInt % 60&#xA;    secs = secsInt&#xA;    return str(hrs).zfill(2) &#x2B; &#x27;:&#x27; &#x2B; str(mins).zfill(2) &#x2B; &#x27;:&#x27; &#x2B; str(secs).zfill(2)&#xA;&#xA;def minus(self, t_start, t_end):&#xA;    """"""&#xA;    t_e = self.toSeconds(t_end)&#xA;    t_s = self.toSeconds(t_start)&#xA;    t_r = t_e - t_s&#xA;    hrs, mins, secs = 0, 0, 0&#xA;    if t_r >= 3600:&#xA;        hrs = math.floor(t_r / 3600)&#xA;        t_r = t_r - (hrs * 3600)&#xA;    if t_r >= 60:&#xA;        mins = math.floor(t_r / 60)&#xA;        t_r = t_r - (mins * 60)&#xA;    secs = t_r&#xA;    hrsf = str(hrs).zfill(2)&#xA;    minsf = str(mins).zfill(2)&#xA;    secsf = str(secs).zfill(2)&#xA;    t_fnl = hrsf &#x2B; &#x27;:&#x27; &#x2B; minsf &#x2B; &#x27;:&#x27; &#x2B; secsf&#xA;    return t_fnl&#xA;&#xA;def go_main():&#xA;    tf = TF()&#xA;    vid_n = 0&#xA;    arglen = len(sys.argv)&#xA;    if arglen == 2:&#xA;        with open(sys.argv[1], &#x27;r&#x27;) as f_in:&#xA;            lines = f_in.readlines()&#xA;            start = None&#xA;            end = None&#xA;            cnt = 0&#xA;            for line in lines:&#xA;                if line[:5] == &#x27;BEGIN&#x27;:&#xA;                    start = cnt&#xA;                if line[:3] == &#x27;END&#x27;:&#xA;                    end = cnt&#xA;                cnt &#x2B;= 1&#xA;            if start == None or end == None:&#xA;                print(&#x27;Invalid file format. start = {}, end = {}&#x27;.format(start,end))&#xA;                return&#xA;            else:&#xA;                lines_r = lines[start&#x2B;1:end]&#xA;                del lines&#xA;                print(&#x27;videos to process: {}&#x27;.format(len(lines_r)))&#xA;                f_out_prefix = ""&#xA;                for vid in lines_r:&#xA;                     vid_n &#x2B;= 1&#xA;                    print(&#x27;\nProcessing video {}/{}&#x27;.format(vid_n, len(lines_r)))&#xA;                    f_out_prefix = &#x27;v&#x27; &#x2B; str(vid_n) &#x2B; &#x27;-&#x27;&#xA;                    dat = vid.split(&#x27;!&#x27;)[1:3]&#xA;                    title = dat[0]&#xA;                    dat_t = dat[1].split(&#x27;,&#x27;)&#xA;                    v_pieces = len(dat_t)&#xA;                    piece_n = 0&#xA;                    video_pieces = []&#xA;                    cmd1 = "echo -n \"\" > tmpfile"&#xA;                    subprocess.run(cmd1, shell=True)                    &#xA;                    print(&#x27;  new tmpfile created&#x27;)&#xA;                    for v_times in dat_t:&#xA;                        piece_n &#x2B;= 1&#xA;                        f_out = f_out_prefix &#x2B; str(piece_n) &#x2B; &#x27;.mp4&#x27;&#xA;                        video_pieces.append(f_out)&#xA;                        print(&#x27;  piece filename {} added to video_pieces list&#x27;.format(f_out))&#xA;                        v_times_spl = v_times.split(&#x27;-&#x27;)&#xA;                        v_times_start = v_times_spl[0]&#xA;                        v_times_end = v_times_spl[1]&#xA;                        t_st = tf.toLong(v_times_start)&#xA;                        t_dur = tf.toTime(tf.toSeconds(v_times_end) - tf.toSeconds(v_times_start))&#xA;                        cmd3 = ["ffmpeg", "-i", title, "-ss", t_st, "-t", t_dur, f_out, "-loglevel", "error", "-stats"]&#xA;                        print(&#x27;  cutting out piece {}/{} - {}&#x27;.format(piece_n, len(dat_t), t_dur))&#xA;                        subprocess.run(cmd3)&#xA;                    for video_piece_name in video_pieces:&#xA;                        cmd4 = "echo \"file " &#x2B; video_piece_name &#x2B; "\" >> tmpfile"&#xA;                        subprocess.run(cmd4, shell=True)&#xA;                        print(&#x27;  filename {} added to tmpfile&#x27;.format(video_piece_name))&#xA;                    vname = f_out_prefix[:-1] &#x2B; ".mp4"&#xA;                    print(&#x27;  name of joined file: {}&#x27;.format(vname))&#xA;                    cmd5 = "ffmpeg -f concat -safe 0 -i tmpfile -c copy joined.mp4 -loglevel error -stats"&#xA;                    to_be_joined = " ".join(video_pieces)&#xA;                    print(&#x27;  joining...&#x27;)&#xA;                    join_cmd = subprocess.Popen(cmd5, shell=True)&#xA;                    join_cmd.wait()&#xA;                    print(&#x27;  joined!&#x27;)&#xA;                    cmd6 = "mv joined.mp4 " &#x2B; vname&#xA;                    rename_cmd = subprocess.Popen(cmd6, shell=True)&#xA;                    rename_cmd.wait()&#xA;                    print(&#x27;  File joined.mp4 renamed to {}&#x27;.format(vname))&#xA;                    cmd7 = "rm " &#x2B; to_be_joined&#xA;                    rm_cmd = subprocess.Popen(cmd7, shell=True)&#xA;                    rm_cmd.wait()&#xA;                    print(&#x27;rm command completed - pieces removed&#x27;)&#xA;                cmd8 = "rm tmpfile"&#xA;                subprocess.run(cmd8, shell=True)&#xA;                print(&#x27;tmpfile removed&#x27;)&#xA;                print(&#x27;All done&#x27;)&#xA;    else:&#xA;        print(&#x27;Incorrect number of arguments&#x27;)&#xA;&#xA;############################&#xA;if __name__ == &#x27;__main__&#x27;:&#xA;    go_main()&#xA;

    &#xA;

    process_videos.py is called from bash terminal like this :

    &#xA;

    $ python process_videos.py video_data   &#xA;

    &#xA;

    video_data file has the following format :

    &#xA;

    BEGIN&#xA;!first_video.mp4!3-23,55-1:34,2:01-3:15,3:34-3:44!&#xA;!second_video.mp4!2-7,12-44,1:03-1:33!&#xA;END&#xA;

    &#xA;

    My system details :

    &#xA;

    System:    Host: snowflake Kernel: 5.4.0-52-generic x86_64 bits: 64 Desktop: Gnome 3.28.4&#xA;           Distro: Ubuntu 18.04.5 LTS&#xA;Machine:   Device: desktop System: Gigabyte product: N/A serial: N/A&#xA;Mobo:      Gigabyte model: Z77-D3H v: x.x serial: N/A BIOS: American Megatrends v: F14 date: 05/31/2012&#xA;CPU:       Quad core Intel Core i5-3570 (-MCP-) cache: 6144 KB &#xA;           clock speeds: max: 3800 MHz 1: 1601 MHz 2: 1601 MHz 3: 1601 MHz 4: 1602 MHz&#xA;Drives:    HDD Total Size: 1060.2GB (55.2% used)&#xA;           ID-1: /dev/sda model: ST31000524AS size: 1000.2GB&#xA;           ID-2: /dev/sdb model: Corsair_Force_GT size: 60.0GB&#xA;Partition: ID-1: / size: 366G used: 282G (82%) fs: ext4 dev: /dev/sda1&#xA;           ID-2: swap-1 size: 0.70GB used: 0.00GB (0%) fs: swap dev: /dev/sda5&#xA;Info:      Processes: 313 Uptime: 16:37 Memory: 3421.4/15906.9MB Client: Shell (bash) inxi: 2.3.56&#xA;

    &#xA;
    &#xA;

    UPDATE :

    &#xA;

    Following Charles' advice, I used performance sampling :

    &#xA;

    # perf record -a -g sleep 180&#xA;

    &#xA;

    ...and here's the report :

    &#xA;

    Samples: 74K of event &#x27;cycles&#x27;, Event count (approx.): 1043554519767&#xA;  Children      Self  Command          Shared Object&#xA;-   50.56%    45.86%  ffmpeg           libavcodec.so.57.107.100                                                                                &#xA;   - 3.10% 0x4489480000002825                                                                                                                  &#xA;       0.64% 0x7ffaf24b92f0                                                                                                                   &#xA;   - 2.12% 0x5f7369007265646f                                                                                                                  &#xA;       av_default_item_name                                                                                                                   &#xA;     1.39% 0                                                                                                                                   &#xA;-   44.48%    40.59%  ffmpeg           libx264.so.152                                                                                          &#xA;     5.78% x264_add8x8_idct_avx2.skip_prologue                                                                                                 &#xA;     3.13% x264_add8x8_idct_avx2.skip_prologue                                                                                                 &#xA;     2.91% x264_add8x8_idct_avx2.skip_prologue                                                                                                 &#xA;     2.31% x264_add8x8_idct_avx.skip_prologue                                                                                                  &#xA;     2.03% 0                                                                                                                                   &#xA;     1.78% 0x1                                                                                                                                 &#xA;     1.26% x264_add8x8_idct_avx2.skip_prologue                                                                                                 &#xA;     1.09% x264_add8x8_idct_avx.skip_prologue                                                                                                  &#xA;     1.06% x264_me_search_ref                                                                                                                  &#xA;     0.97% x264_add8x8_idct_avx.skip_prologue                                                                                                  &#xA;     0.60% x264_me_search_ref                                                                                                                  &#xA;-   38.01%     0.00%  ffmpeg           [unknown]                                                                                               &#xA;     4.10% 0                                                                                                                                   &#xA;   - 3.49% 0x4489480000002825                                                                                                                  &#xA;        0.70% 0x7ffaf24b92f0                                                                                                                   &#xA;        0.56% 0x7f273ae822f0                                                                                                                   &#xA;        0.50% 0x7f0c4768b2f0                                                                                                                   &#xA;   - 2.29% 0x5f7369007265646f                                                                                                                  &#xA;        av_default_item_name                                                                                                                   &#xA;     1.99% 0x1                                                                                                                                 &#xA;    10.13%    10.12%  ffmpeg           [kernel.kallsyms]                                                                                       &#xA;-    3.14%     0.73%  ffmpeg           libavutil.so.55.78.100                                                                                  &#xA;     2.34% av_default_item_name                                                                                                                &#xA;-    1.73%     0.21%  ffmpeg           libpthread-2.27.so                                                                                      &#xA;   - 0.70% pthread_cond_wait@@GLIBC_2.3.2                                                                                                      &#xA;      - 0.62% entry_SYSCALL_64_after_hwframe                                                                                                   &#xA;         - 0.62% do_syscall_64                                                                                                                 &#xA;            - 0.57% __x64_sys_futex                                                                                                            &#xA;                 0.52% do_futex                                                                                                                &#xA;     0.93%     0.89%  ffmpeg           libc-2.27.so                                                                                            &#xA;-    0.64%     0.64%  swapper          [kernel.kallsyms]                                                                                       &#xA;     0.63% secondary_startup_64                                                                                                                &#xA;     0.21%     0.18%  ffmpeg           libavfilter.so.6.107.100                                                                                &#xA;     0.20%     0.11%  ffmpeg           libavformat.so.57.83.100                                                                                &#xA;     0.12%     0.11%  ffmpeg           ffmpeg                                                                                                  &#xA;     0.11%     0.00%  gnome-terminal-  [unknown]                                                                                               &#xA;     0.09%     0.07%  ffmpeg           libm-2.27.so                                                                                            &#xA;     0.08%     0.07%  ffmpeg           ld-2.27.so                                                                                              &#xA;     0.04%     0.04%  gnome-terminal-  libglib-2.0.so.0.5600.4&#xA;

    &#xA;

    &#xA;

  • IplImage crop and rotate - Android

    26 février 2015, par Ganesh

    I’m using ffmpeg to video capture for 30 seconds.

    @Override
           public void onPreviewFrame(byte[] data, Camera camera) {
               if (yuvIplimage != null &amp;&amp; recording &amp;&amp; rec)
                   {
                       new SaveFrame().execute(data);
                   }
               }
           }

    save frame class is below

    private class SaveFrame extends AsyncTask {
               long t;
               protected File doInBackground(byte[]... arg) {

                   t = 1000 * (System.currentTimeMillis() - firstTime - pausedTime);
                   toSaveFrames++;
                   File pathCache = new File(Environment.getExternalStorageDirectory()+"/DCIM", (System.currentTimeMillis() / 1000L)+ "_" + toSaveFrames + ".tmp");
                   BufferedOutputStream bos;
                   try {
                       bos = new BufferedOutputStream(new FileOutputStream(pathCache));
                       bos.write(arg[0]);
                       bos.flush();
                       bos.close();
                   } catch (FileNotFoundException e) {
                       e.printStackTrace();
                       pathCache = null;
                       toSaveFrames--;
                   } catch (IOException e) {
                       e.printStackTrace();
                       pathCache = null;
                       toSaveFrames--;
                   }
                   return pathCache;


               }
               @Override
               protected void onPostExecute(File filename)
               {
                   if(filename!=null)
                   {
                       savedFrames++;
                       tempList.add(new FileFrame(t,filename));
                   }
               }
           }

    finally i add all frames with crop and rotation

    private class AddFrame extends AsyncTask {
           private int serial = 0;
           @Override
           protected Void doInBackground(Void... params) {

               for(int i=0; i/                                      final int startY = 640*(480-480)/2;
    //                                      final int lenY = 640*480;
    //                                      yuvIplimage.getByteBuffer().put(bytes, startY, lenY);
    //                                      final int startVU = 640*480+ 640*(480-480)/4;
    //                                      final int lenVU = 640* 480/2;
    //                                      yuvIplimage.getByteBuffer().put(bytes, startVU, lenVU);

                       if (tempList.get(i).time > recorder.getTimestamp()) {
                           recorder.setTimestamp(tempList.get(i).time);
                       }

                       image = cropImage(image);
                       image = rotate(image, 270);
    //                                       image = rotateImage(image);
                       recorder.record(image);
                       Log.i(LOG_TAG, "record " + i);
                       image = null;
                       serial++;
                       publishProgress(serial);
                   } catch (FileNotFoundException e) {
                       e.printStackTrace();
                   } catch (IOException e) {
                       e.printStackTrace();
                   } catch (com.googlecode.javacv.FrameRecorder.Exception e) {
                       e.printStackTrace();
                   }
               }
               return null;
           }
           @Override
           protected void onProgressUpdate(Integer... serial) {
               int value = serial[0];
               creatingProgress.setProgress(value);
           }
           @Override
           protected void onPostExecute(Void v)
           {
               creatingProgress.dismiss();
               if (recorder != null &amp;&amp; recording) {
                   recording = false;
                   Log.v(LOG_TAG,"Finishing recording, calling stop and release on recorder");
                   try {
                       recorder.stop();
                       recorder.release();
                       finish();
                       startActivity(new Intent(RecordActivity.this,AnswerViewActivity.class));
                   } catch (FFmpegFrameRecorder.Exception e) {
                       e.printStackTrace();
                   }
                   recorder = null;
               }
           }
       }

    my crop and rotate method are below

    private IplImage cropImage(IplImage src)
       {
           cvSetImageROI(src, r);
           IplImage cropped = IplImage.create(imageHeight, imageHeight, IPL_DEPTH_8U, 2);
           cvCopy(src, cropped);
           return cropped;
       }

       public static IplImage rotate(IplImage image, double angle) {        
           IplImage copy = opencv_core.cvCloneImage(image);

           IplImage rotatedImage = opencv_core.cvCreateImage(opencv_core.cvGetSize(copy), copy.depth(), copy.nChannels());
           CvMat mapMatrix = opencv_core.cvCreateMat( 2, 3, opencv_core.CV_32FC1 );

           //Define Mid Point
           CvPoint2D32f centerPoint = new CvPoint2D32f();
           centerPoint.x(copy.width()/2);
           centerPoint.y(copy.height()/2);

           //Get Rotational Matrix
           opencv_imgproc.cv2DRotationMatrix(centerPoint, angle, 1.0, mapMatrix);

           //Rotate the Image
           opencv_imgproc.cvWarpAffine(copy, rotatedImage, mapMatrix, opencv_imgproc.CV_INTER_CUBIC +  opencv_imgproc.CV_WARP_FILL_OUTLIERS, opencv_core.cvScalarAll(170));
           opencv_core.cvReleaseImage(copy);
           opencv_core.cvReleaseMat(mapMatrix);        
           return rotatedImage;
       }

    my final video crop and rotate but green frames and colored frames mixed with this.

    How to fix this problem. I’m not aware of iplimage. In some blogs they mention its YUV format. first u need to convert Y and then convert UV.

    How to solve this problem ?