Recherche avancée

Médias (33)

Mot : - Tags -/creative commons

Autres articles (96)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

Sur d’autres sites (10320)

  • video proccesing : extract frames and encrypt them then insert them back to the video in java using xuggler

    24 juillet 2015, par Anas M. Jubara

    I’m working on a video encryption application .. the main idea is to input the video file to the application and the application should output it in an encrypted form... am using xuggler library to manipulate the video and get to the frames and AES for encryption.
    my code works fine for accessing the frames and encrypting them, what i need help with is how to write the encrypted frame back to the video file to replace the original one without corrupting the video file for the video players.
    Here is my code

    package xuggler;

    import com.xuggle.mediatool.IMediaReader;
    import com.xuggle.mediatool.IMediaWriter;
    import com.xuggle.mediatool.MediaListenerAdapter;
    import com.xuggle.mediatool.ToolFactory;
    import com.xuggle.mediatool.event.IVideoPictureEvent;
    import com.xuggle.xuggler.Global;
    import com.xuggle.xuggler.ICodec;

    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.Transparency;
    import java.awt.image.BufferedImage;
    import java.awt.image.ColorModel;
    import java.awt.image.ComponentColorModel;
    import java.awt.image.DataBuffer;
    import java.awt.image.DataBufferByte;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;

    import java.io.File;

    import java.security.InvalidKeyException;
    import java.security.NoSuchAlgorithmException;
    import java.security.SecureRandom;

    import java.util.concurrent.TimeUnit;
    import java.util.logging.Level;
    import java.util.logging.Logger;

    import javax.crypto.BadPaddingException;
    import javax.crypto.Cipher;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.KeyGenerator;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.SecretKey;

    import javax.imageio.ImageIO;


    public class DecodeAndCaptureFrames extends MediaListenerAdapter
    {

    // The number of seconds between frames.
         public static final double SECONDS_BETWEEN_FRAMES = 5;

     //The number of micro-seconds between frames.
     public static final long MICRO_SECONDS_BETWEEN_FRAMES =(long)      (Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);

     // Time of last frame write
     private static long mLastPtsWrite = Global.NO_PTS;

    private static final double FRAME_RATE = 50;

    private static final int SECONDS_TO_RUN_FOR = 20;

    private static final String outputFilename = "D:\\K.mp4";

    public static IMediaWriter writer = ToolFactory.makeWriter(outputFilename);
    //receive BufferedImage and returns its byte data
       public static byte[] get_byte_data(BufferedImage image) {
       WritableRaster raster = image.getRaster();
       DataBufferByte buffer = (DataBufferByte) raster.getDataBuffer();
       return buffer.getData();
    }


    //create new_img with the attributes of image
    public static BufferedImage user_space(BufferedImage image) {
       //create new_img with the attributes of image
       BufferedImage new_img = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
       Graphics2D graphics = new_img.createGraphics();
       graphics.drawRenderedImage(image, null);
       graphics.dispose(); //release all allocated memory for this image
       return new_img;
    }

    public static BufferedImage toImage(byte[] imagebytes, int width, int height) {
       DataBuffer buffer = new DataBufferByte(imagebytes, imagebytes.length);
       WritableRaster raster = Raster.createInterleavedRaster(buffer, width, height,
          3 * width, 3, new int[]{2, 1, 0}, (Point) null);

       ColorModel cm = new ComponentColorModel(ColorModel.getRGBdefault().getColorSpace(),
               false, true, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
       return new BufferedImage(cm, raster, true, null);
    }

    public static byte[] encrypt(byte[] orgnlbytes, String key) throws NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException {
       byte[] encbytes = null;
       try {
           Cipher cipher = Cipher.getInstance("AES");
           KeyGenerator keyGen = KeyGenerator.getInstance("AES");
           SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
           // cryptograph. secure random
           random.setSeed(key.getBytes());

           keyGen.init(128, random);
           // for example
           SecretKey secretKey = keyGen.generateKey();
           try {
               cipher.init(Cipher.ENCRYPT_MODE, secretKey);
           } catch (InvalidKeyException ex) {
               Logger.getLogger(DecodeAndCaptureFrames.class.getName()).log(Level.SEVERE, null, ex);
           }
           encbytes = cipher.doFinal(orgnlbytes);
       }
       catch (NoSuchAlgorithmException ex) {
           Logger.getLogger(DecodeAndCaptureFrames.class.getName()).log(Level.SEVERE, null, ex);
       }        catch (NoSuchPaddingException ex)
       {
           System.out.print("can not encrypt buffer");
       }

       return encbytes;
    }


     /**
      * The video stream index, used to ensure we display frames from one
      * and only one video stream from the media container.
      */

     private int mVideoStreamIndex = -1;

     /**
      * Takes a media container (file) as the first argument, opens it and
      *  writes some of it's video frames to PNG image files in the
      *  temporary directory.
      *
      * @param args must contain one string which represents a filename
      */

     public static void main(String[] args)
     {
       // create a new mr. decode and capture frames


       DecodeAndCaptureFrames decodeAndCaptureFrames;
       decodeAndCaptureFrames = new DecodeAndCaptureFrames("D:\\K.mp4");
     }

     /** Construct a DecodeAndCaptureFrames which reads and captures
      * frames from a video file.
      *
      * @param filename the name of the media file to read
      */


     //makes reader to the file and read the data of it
     public DecodeAndCaptureFrames(String filename)
     {
       // create a media reader for processing video

      IMediaReader reader = ToolFactory.makeReader(filename);

    // stipulate that we want BufferedImages created in BGR 24bit color space
    reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);


    // note that DecodeAndCaptureFrames is derived from
    // MediaReader.ListenerAdapter and thus may be added as a listener
    // to the MediaReader. DecodeAndCaptureFrames implements
    // onVideoPicture().

    reader.addListener(this);

    // read out the contents of the media file, note that nothing else
    // happens here.  action happens in the onVideoPicture() method
    // which is called when complete video pictures are extracted from
    // the media source

    while (reader.readPacket() == null)
     do {} while(false);
     }

    /**
      * Called after a video frame has been decoded from a media stream.
      * Optionally a BufferedImage version of the frame may be passed
      * if the calling {@link IMediaReader} instance was configured to
      * create BufferedImages.
      *
      * This method blocks, so return quickly.
      */

     public void onVideoPicture(IVideoPictureEvent event)
     {
       try
       {
         // if the stream index does not match the selected stream index,
         // then have a closer look

     if (event.getStreamIndex() != mVideoStreamIndex)
     {
       // if the selected video stream id is not yet set, go ahead an
       // select this lucky video stream

       if (-1 == mVideoStreamIndex)
         mVideoStreamIndex = event.getStreamIndex();

       // otherwise return, no need to show frames from this video stream

       else
         return;
     }

     // if uninitialized, backdate mLastPtsWrite so we get the very
     // first frame

     if (mLastPtsWrite == Global.NO_PTS)
       mLastPtsWrite = event.getTimeStamp() - MICRO_SECONDS_BETWEEN_FRAMES;

     // if it's time to write the next frame

     if (event.getTimeStamp() - mLastPtsWrite >= MICRO_SECONDS_BETWEEN_FRAMES)
     {
       // Make a temporary file name

      // File file = File.createTempFile("frame", ".jpeg");

       // write out PNG

    //        ImageIO.write(event.getImage(), "png", file);

       BufferedImage orgnlimage = event.getImage();
           orgnlimage = user_space(orgnlimage);
           byte[] orgnlimagebytes = get_byte_data(orgnlimage);
           byte[] encryptedbytes = encrypt(orgnlimagebytes, "abc");
           BufferedImage encryptedimage = toImage(encryptedbytes, orgnlimage.getWidth(), orgnlimage.getHeight());


           ImageIO.write(encryptedimage, "png", File.createTempFile("frame", ".png"));
    //         indicate file written

       double seconds = ((double)event.getTimeStamp())
         / Global.DEFAULT_PTS_PER_SECOND;
    //        System.out.printf("at elapsed time of %6.3f seconds wrote: %s\n",seconds, file);

       // update last write time

       mLastPtsWrite += MICRO_SECONDS_BETWEEN_FRAMES;
     }
    }
    catch (Exception e)
    {
     e.printStackTrace();
    }
     }

    }
  • Unresolved symbols when linking ffmpeg 2.7.1 on OSX 10.10.4/amd64 with Xcode 6.4

    9 juillet 2015, par Corey Brenner

    I am seeing a problem linking against ffmpeg 2.7.1 (as installed by homebrew just today). Though the libraries in question are referenced on the command line, and though the linker admits to pulling in the correct libraries, and though the libraries themselves have the desired symbols (verified with NM), the symbols I need from the ffmpeg libraries do not show up.

    My host and target platform is Mac x86_64, Xcode 6.4, OS X v10.10.4.

    ("ERROR (LINK.dll) : " is from my build system)

    Thanks in advance !

    ERROR (LINK.dll): /usr/bin/clang -dynamiclib -single_module -install_name @loader_path/ourapp_ffmpeg_test.5.0.0.dylib -compatibility_version 5.0.0 -current_version 5.0.0 -v -Wl,-t -arch x86_64 -mmacosx-version-min=10.7 -g -o "/Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourapp/decoders/ourapp_ffmpeg_test/dll/shared/ourapp_ffmpeg_test.5.0.0.dylib" /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourapp/decoders/ourapp_ffmpeg_test/pic/main.o /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourbaselib/lib/pic/libourbaselib.a -L"/usr/local/lib" -lavformat -lavcodec -lswscale -lavutil -framework IOKit -framework CoreServices -liconv -lstdc++
    ERROR (LINK.dll): Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
    ERROR (LINK.dll): Target: x86_64-apple-darwin14.4.0
    ERROR (LINK.dll): Thread model: posix
    ERROR (LINK.dll):  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -dylib -dylib_compatibility_version 5.0.0 -dylib_current_version 5.0.0 -arch x86_64 -dylib_install_name @loader_path/ourapp_ffmpeg_test.5.0.0.dylib -macosx_version_min 10.7.0 -single_module -o /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourapp/decoders/ourapp_ffmpeg_test/dll/shared/ourapp_ffmpeg_test.5.0.0.dylib -L/usr/local/lib -t /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourapp/decoders/ourapp_ffmpeg_test/pic/main.o /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourbaselib/lib/pic/libourbaselib.a -lavformat -lavcodec -lswscale -lavutil -framework IOKit -framework CoreServices -liconv -lstdc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.osx.a
    ERROR (LINK.dll): Undefined symbols for architecture x86_64:
    ERROR (LINK.dll):   "av_frame_free(AVFrame**)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_shutdown(ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "av_read_frame(AVFormatContext*, AVPacket*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_frame_get(ourapp_ffmpeg_handle_s*, AVFrame**, int*, int*) in main.o
    ERROR (LINK.dll):   "avcodec_close(AVCodecContext*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_shutdown(ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "av_dump_format(AVFormatContext*, int, char const*, int)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "av_frame_alloc()", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "av_free_packet(AVPacket*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_frame_get(ourapp_ffmpeg_handle_s*, AVFrame**, int*, int*) in main.o
    ERROR (LINK.dll):   "avpicture_fill(AVPicture*, unsigned char const*, AVPixelFormat, int, int)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "av_register_all()", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_init() in main.o
    ERROR (LINK.dll):   "avpicture_get_size(AVPixelFormat, int, int)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "avcodec_copy_context(AVCodecContext*, AVCodecContext const*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "avcodec_find_decoder(AVCodecID)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "avformat_close_input(AVFormatContext**)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_shutdown(ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "sws_getCachedContext(SwsContext*, int, int, AVPixelFormat, int, int, AVPixelFormat, int, SwsFilter*, SwsFilter*, double const*)", referenced from:
    ERROR (LINK.dll):       get_scalecontext(SwsContext**, AVStream const*, int, int, AVPixelFormat) in main.o
    ERROR (LINK.dll):   "avcodec_decode_video2(AVCodecContext*, AVFrame*, int*, AVPacket const*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_frame_get(ourapp_ffmpeg_handle_s*, AVFrame**, int*, int*) in main.o
    ERROR (LINK.dll):   "avcodec_alloc_context3(AVCodec const*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "sws_getColorspaceDetails(SwsContext*, int**, int*, int**, int*, int*, int*, int*)", referenced from:
    ERROR (LINK.dll):       get_scalecontext(SwsContext**, AVStream const*, int, int, AVPixelFormat) in main.o
    ERROR (LINK.dll):   "sws_setColorspaceDetails(SwsContext*, int const*, int, int const*, int, int, int, int)", referenced from:
    ERROR (LINK.dll):       get_scalecontext(SwsContext**, AVStream const*, int, int, AVPixelFormat) in main.o
    ERROR (LINK.dll):   "avformat_find_stream_info(AVFormatContext*, AVDictionary**)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "av_free(void*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_shutdown(ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "av_malloc(unsigned long)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_decode_init(char const*, ourapp_ffmpeg_handle_s*) in main.o
    ERROR (LINK.dll):   "sws_scale(SwsContext*, unsigned char const* const*, int const*, int, int, unsigned char* const*, int const*)", referenced from:
    ERROR (LINK.dll):       ourapp_ffmpeg_frame_get(ourapp_ffmpeg_handle_s*, AVFrame**, int*, int*) in main.o
    ERROR (LINK.dll): ld: symbol(s) not found for architecture x86_64
    ERROR (LINK.dll): /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourapp/decoders/ourapp_ffmpeg_test/pic/main.o
    ERROR (LINK.dll): /usr/local/lib/libavformat.dylib
    ERROR (LINK.dll): /usr/local/lib/libavcodec.dylib
    ERROR (LINK.dll): /usr/local/lib/libswscale.dylib
    ERROR (LINK.dll): /usr/local/lib/libavutil.dylib
    ERROR (LINK.dll): /System/Library/Frameworks//IOKit.framework/IOKit
    ERROR (LINK.dll): /System/Library/Frameworks//CoreServices.framework/CoreServices
    ERROR (LINK.dll): /usr/lib/libiconv.dylib
    ERROR (LINK.dll): /usr/lib/libSystem.dylib
    ERROR (LINK.dll): /usr/lib/libstdc++.dylib
    ERROR (LINK.dll): /System/Library/Frameworks//CFNetwork.framework/CFNetwork
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    ERROR (LINK.dll): /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    ERROR (LINK.dll): /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
    ERROR (LINK.dll): /usr/lib/system/libcache.dylib
    ERROR (LINK.dll): /usr/lib/system/libcommonCrypto.dylib
    ERROR (LINK.dll): /usr/lib/system/libcompiler_rt.dylib
    ERROR (LINK.dll): /usr/lib/system/libcopyfile.dylib
    ERROR (LINK.dll): /usr/lib/system/libcorecrypto.dylib
    ERROR (LINK.dll): /usr/lib/system/libdispatch.dylib
    ERROR (LINK.dll): /usr/lib/system/libdyld.dylib
    ERROR (LINK.dll): /usr/lib/system/libkeymgr.dylib
    ERROR (LINK.dll): /usr/lib/system/liblaunch.dylib
    ERROR (LINK.dll): /usr/lib/system/libmacho.dylib
    ERROR (LINK.dll): /usr/lib/system/libquarantine.dylib
    ERROR (LINK.dll): /usr/lib/system/libremovefile.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_asl.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_blocks.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_c.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_configuration.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_coreservices.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_coretls.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_dnssd.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_info.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_kernel.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_m.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_malloc.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_network.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_networkextension.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_notify.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_platform.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_pthread.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_sandbox.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_secinit.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_stats.dylib
    ERROR (LINK.dll): /usr/lib/system/libsystem_trace.dylib
    ERROR (LINK.dll): /usr/lib/system/libunc.dylib
    ERROR (LINK.dll): /usr/lib/system/libunwind.dylib
    ERROR (LINK.dll): /usr/lib/system/libxpc.dylib
    ERROR (LINK.dll): /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourbaselib/lib/pic/libourbaselib.a(ourbaselib_memory.o)
    ERROR (LINK.dll): /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourbaselib/lib/pic/libourbaselib.a(ourbaselib_atomic.o)
    ERROR (LINK.dll): /Users/myname/src/oursdk/devel/main/out/mac/x86-64/system/debug/obj/source/ourbaselib/lib/pic/libourbaselib.a(ourbaselib_stacktrace.o)
    ERROR (LINK.dll): clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • ffmpeg Progress Bar - Encoding Percentage in PHP

    11 juillet 2016, par Jimbo

    I’ve written a whole system in PHP and bash on the server to convert and stream videos in HTML5 on my VPS. The conversion is done by ffmpeg in the background and the contents is output to block.txt.

    Having looked at the following posts :

    Can ffmpeg show a progress bar ?

    and

    ffmpeg video encoding progress bar

    amongst others, I can’t find a working example.

    I need to grab the currently encoded progress as a percentage.

    The first post I linked above gives :

    $log = @file_get_contents('block.txt');

    preg_match("/Duration:([^,]+)/", $log, $matches);
    list($hours,$minutes,$seconds,$mili) = split(":",$matches[1]);
    $seconds = (($hours * 3600) + ($minutes * 60) + $seconds);
    $seconds = round($seconds);

    $page = join("",file("$txt"));
    $kw = explode("time=", $page);
    $last = array_pop($kw);
    $values = explode(' ', $last);
    $curTime = round($values[0]);
    $percent_extracted = round((($curTime * 100)/($seconds)));

    echo $percent_extracted;

    The $percent_extracted variable echoes zero, and as maths is not my strong point, I really don’t know how to progress here.

    Here’s one line from the ffmpeg output from block.txt (if it’s helpful)

    time=00:19:25.16 bitrate= 823.0kbits/s frame=27963 fps= 7 q=0.0 size=
    117085kB time=00:19:25.33 bitrate= 823.1kbits/s frame=27967 fps= 7
    q=0.0 size= 117085kB time=00:19:25.49 bitrate= 823.0kbits/s
    frame=27971 fps= 7 q=0.0 size= 117126kB

    Please help me output this percentage, once done I can create my own progress bar. Thanks.