Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (51)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • 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 ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (11112)

  • NoMethodFoundException when trying to load native methods from jar file

    20 février 2018, par Anuran Barman

    I am trying to load ffmpeg methods in android. My requirement is that I dont want to pack the .so files within the apk.Only if the user wants then only I will download the jar file and load the ffmpeg native methods.After searching I think that loading .so files at run time is not possible.So what I did that I made the so file and created a different android application with only one class FFMPEG.java whose only duty is to call the native methods from ffmpeg library.so I made the jar file and loaded that into my main application with ClassLoader. Constructor is getting called so it means class is loaded but methods are not getting loaded though they are declared public in the jar file. I am trying to stream RTSP video with FFMPEG.Below are my jar file and main application codes.

    public class FFMPEG {

       public FFMPEG(){
           Log.d(FFMPEG.class.getSimpleName(),"constructor called");
       }

       public static native int naInit(String pFileName);
       public static native int[] naGetVideoRes();
       public static native void naSetSurface(Surface pSurface);
       public static native int naSetup(int pWidth, int pHeight);
       public static native void naPlay();
       public static native void naStop();

       public static boolean loadedLibraries;

       static {
           try {
               System.loadLibrary("avutil");
               System.loadLibrary("avcodec");
               System.loadLibrary("avformat");
               System.loadLibrary("swscale");
               System.loadLibrary("avfilter");
               System.loadLibrary("ffmpeg-jni");
               loadedLibraries = true;
           } catch (Throwable e) {
               e.printStackTrace();
           }
       }

       public int libInit(String filename){
           return  naInit(filename);
       }

       public int[] libGetVideoRes(){
           return  naGetVideoRes();
       }
       public void libSetSurface(Surface surface){
           naSetSurface(surface);
       }
       public int libSetup(int width,int height){
           return naSetup(width,height);
       }
       public void libPlay(){
           naPlay();
       }
       public void libStop(){
           naStop();
       }
    }

    My main application activity code.The jar file location in my sdcard named camlib.jar

    @SuppressWarnings("JniMissingFunction")
    public class MainActivity extends AppCompatActivity implements SurfaceHolder.Callback {

       private SurfaceView surfaceView;
       private ProgressBar progressBar;
       private final String TAG=MainActivity.class.getSimpleName();

       private boolean isPlaying;
       private boolean isClassLoaded;
       private boolean isInitialized;
       private String url="";
       Method libInit,libGetVideoRes,libSetSurface,libSetup,libPlay,libStop;
       Object myInstance;
       @Override
       protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
           setContentView(R.layout.activity_main);
           surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
           progressBar = ((ProgressBar) findViewById(R.id.progressBar));
           surfaceView.getHolder().addCallback(this);
           int permission= ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
           if(permission== PackageManager.PERMISSION_GRANTED){
               loadClass();
           }else{
               ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},200);
           }

       }

       @Override
       public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
           super.onRequestPermissionsResult(requestCode, permissions, grantResults);
           if(requestCode==200){
               if(grantResults.length>0){
                   if (grantResults[0]==PackageManager.PERMISSION_GRANTED){
                       loadClass();
                   }else{
                       ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},200);
                   }
               }
           }
       }

       public void loadClass(){
           try {
               final String libPath = Environment.getExternalStorageDirectory() + "/camlib.jar";
               final File tmpDir = getDir("dex", 0);

               final DexClassLoader classloader = new DexClassLoader(libPath, tmpDir.getAbsolutePath(), null, this.getClass().getClassLoader());
               final Class classToLoad = (Class) classloader.loadClass("com.myeglu.obbapplication.FFMPEG");

                myInstance  = classToLoad.newInstance();
                libInit= classToLoad.getMethod("libInit");
                libGetVideoRes=classToLoad.getMethod("libGetVideoRes");
                libSetSurface=classToLoad.getMethod("libSetSurface");
                libSetup=classToLoad.getMethod("libSetup");
                libPlay=classToLoad.getMethod("libPlay");
                libStop=classToLoad.getMethod("libStop");
                isClassLoaded=true;
                new PlayVideo().execute();

           } catch (Exception e) {
               e.printStackTrace();
           }
       }

       private void postInit() {
           if (isInitialized) {
               initPlay();
               progressBar.setVisibility(View.GONE);
           } else {
               finish();
           }
       }

       private void initPlay() {
           try {
               int[] res = (int[])libGetVideoRes.invoke(myInstance);
               Log.d("ANURAN", "res width " + res[0] + ": height " + res[1]);
               if (res[0] <= 0) {
                   res[0] = 480;
               }
               if (res[1] <= 0) {
                   res[1] = 320;
               }
               int[] screenRes = getScreenRes();
               int width, height;
               float widthScaledRatio = screenRes[0] * 1.0f / res[0];
               float heightScaledRatio = screenRes[1] * 1.0f / res[1];
               if (widthScaledRatio > heightScaledRatio) {
                   //use heightScaledRatio
                   width = (int) (res[0] * heightScaledRatio);
                   height = screenRes[1];
               } else {
                   //use widthScaledRatio
                   width = screenRes[0];
                   height = (int) (res[1] * widthScaledRatio);
               }
               Log.d(TAG, "width " + width + ",height:" + height);
               updateSurfaceView(width, height);
               libSetup.invoke(myInstance,width,height);
               playMedia();
           }catch (Exception e){

           }
       }

       private void playMedia() {
           try {
               if (progressBar.getVisibility() == View.VISIBLE) {
                   progressBar.setVisibility(View.GONE);
               }
               libPlay.invoke(myInstance);
               isPlaying = true;
           }catch (Exception e){

           }
       }
       private void updateSurfaceView(int pWidth, int pHeight) {
           //update surfaceview dimension, this will cause the native window to change
           Log.d("ANURAN UPDATE SURFACE", "width " + pWidth + ",height:" + pHeight);
           FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) surfaceView.getLayoutParams();
           params.width = pWidth;
           params.height = pHeight;
           surfaceView.setLayoutParams(params);
       }

       @SuppressLint("NewApi")
       private int[] getScreenRes() {
           int[] res = new int[2];
           Display display = getWindowManager().getDefaultDisplay();
           Point size = new Point();
           display.getSize(size);
           res[0] = size.x;
           res[1] = size.y;
           return res;
       }

       @Override
       protected void onStop() {
           super.onStop();
           Toast.makeText(MainActivity.this,"onStop called",Toast.LENGTH_SHORT).show();
           stopPlaying();
           finish();
       }

       @Override
       public void onBackPressed() {
           stopPlaying();
           finish();
       }

       private void stopPlaying() {
           isPlaying = false;
           try{
               libStop.invoke(myInstance);
           }catch (Exception e){

           }
       }

       @Override
       protected void onDestroy() {
           super.onDestroy();
           stopPlaying();
           finish();
       }



       @Override
       protected void onRestart() {
           super.onRestart();
           Toast.makeText(MainActivity.this,"onRestart called",Toast.LENGTH_SHORT).show();
           progressBar.setVisibility(View.VISIBLE);

       }


       @Override
       public void surfaceChanged(SurfaceHolder holder, int format, int width,
                                  int height) {

           if(isClassLoaded){
               try {
                   libSetSurface.invoke(myInstance,holder.getSurface());
               } catch (IllegalAccessException e) {
                   e.printStackTrace();
               } catch (InvocationTargetException e) {
                   e.printStackTrace();
               }
           }

       }

       @Override
       public void surfaceCreated(SurfaceHolder holder) {

       }

       @Override
       public void surfaceDestroyed(SurfaceHolder holder) {
           if(isClassLoaded) {
               try {
                   libSetSurface.invoke(myInstance, null);
               } catch (IllegalAccessException e) {
                   e.printStackTrace();
               } catch (InvocationTargetException e) {
                   e.printStackTrace();
               }
           }
       }



       private class PlayVideo extends AsyncTask {

           @Override
           protected Void doInBackground(Void... voids) {
               try {
                   int temp=(int)libInit.invoke(myInstance,url);
                   isInitialized=(temp==0);
               } catch (IllegalAccessException e) {
                   e.printStackTrace();
               } catch (InvocationTargetException e) {
                   e.printStackTrace();
               }
               return null;
           }

           @Override
           protected void onPostExecute(Void aVoid) {
               super.onPostExecute(aVoid);
               postInit();
               this.cancel(true);
           }
       }
    }
  • Carrierwave-video "Process hung" error while encoding uncompressed video files

    28 avril 2014, par Cramps

    I have an API for a mobile app that accepts video uploads. This app is for both iOS and Android devices, so for video compatibility’s sake these videos are encoded to H.264 once uploaded to the server using carrierwave-video (ffmpeg wrapper gem for Ruby on Rails). Right now this seems to be working, and videos are uploaded and encoded and can be played in both Android and iOS devices. However, sometimes the process hangs while encoding heavy (uncompressed ?) video files, usually 10+ seconds long. This is the output of ffmpeg :

    Failed to transcode with FFmpeg.
    Check ffmpeg install and verify video is not corrupt or cut short.
    Original error: Process hung. Full output:

    (That’s it, the full output seems empty.)

    These are the encoding parameters I’m using in my Carrierwave Uploader :

    encode_video(:mp4, custom: '-y -vcodec libx264 -acodec libfaac -vpre ultrafast 2> /home/user/log/ffmpeg.log, resolution: '640x640')

    According to the SuperUser question I linked above a solution would be to encode the video twice, once to AVI for compression(?) and then encode to MP4. I don’t know if that would work, but I don’t know how to do this either in my uploader. I would have to encode the output video file of my first (AVI) encoding process.

    Now that there’s some context, my question is : How can I solve this "Process hung" error ?

    In case the answer to that is to go with this double encoding method suggested, how can I achieve this using Carrierwave-video ?

    One last note is that if I try to encode these videos using ffmpeg straight from command-line the videos encode and playback successfully.

    Thank you for your time !

    PD : Wasn’t sure if I should add ruby-on-rails tag. I’ll remove it if necessary !

    Edit
    This is what I get from ffmpeg -i filename.mp4

    ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
     built on Apr 30 2013 11:26:53 with gcc 4.5.4
     configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -march=athlon64 -pipe' --extra-cflags='-O2 -march=athlon64 -pipe' --extra-cxxflags='-O2 -march=athlon64 -pipe' --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --disable-vaapi --disable-vdpau --disable-ffplay --enable-openssl --enable-nonfree --enable-libmp3lame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libaacplus --enable-nonfree --enable-libfaac --enable-nonfree --disable-indev=v4l --disable-indev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl --enable-pthreads --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libvpx --enable-libope  libavutil      51. 35.100 / 51. 35.100
     libavcodec     53. 61.100 / 53. 61.100
     libavformat    53. 32.100 / 53. 32.100
     libavdevice    53.  4.100 / 53.  4.100
     libavfilter     2. 61.100 /  2. 61.100
     libswscale      2.  1.100 /  2.  1.100
     libswresample   0.  6.100 /  0.  6.100
     libpostproc    52.  0.100 / 52.  0.100

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/user/api/uploads/tmp/e54zfghzt9.mp4':


    Metadata:
       major_brand     : isom
       minor_version   : 0
       compatible_brands: isom3gp4
       creation_time   : 2014-04-23 14:56:19
     Duration: 00:00:14.27, start: 0.000000, bitrate: 20757 kb/s
       Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 20993 kb/s, SAR 65536:65536 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc


    Metadata:
         creation_time   : 2014-04-23 14:56:19
         handler_name    : VideoHandle
       Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 190 kb/s


    Metadata:
         creation_time   : 2014-04-23 14:56:19
         handler_name    : SoundHandle

    Then it just starts buffering as such :

    time=00:00:13.20 bitrate=2533.2kbits/s    
    frame=  405 fps=  7 q=24.0 size=    4083kB time=00:00:13.20 bitrate=2533.2kbits/s    
    frame=  407 fps=  7 q=24.0 size=    4083kB time=00:00:13.20 bitrate=2533.2kbits/s    
    frame=  409 fps=  7 q=24.0 size=    4083kB time=00:00:13.20 bitrate=2533.2kbits/s    
    frame=  412 fps=  7 q=24.0 size=    4083kB time=00:00:13.20 bitrate=2533.2kbits/s    
    frame=  417 fps=  7 q=24.0 size=    4083kB time=00:00:13.20 bitrate=2533.2kbits/s    
    frame=  417 fps=  7 q=24.0 Lsize=    4194kB time=00:00:13.90 bitrate=2471.5kbits/s    
    video:3957kB audio:223kB global headers:0kB muxing overhead 0.310939%
    [libx264 @ 0x7f28327ccc50] frame I:2     Avg QP:21.50  size: 25120
    [libx264 @ 0x7f28327ccc50] frame P:415   Avg QP:25.32  size:  9642
    [libx264 @ 0x7f28327ccc50] mb I  I16..4: 35.8%  0.0% 64.2%
    [libx264 @ 0x7f28327ccc50] mb P  I16..4:  8.4%  0.0%  3.2%  P16..4: 43.6% 19.0%  5.6%  0.0%  0.0%    skip:20.2%
    [libx264 @ 0x7f28327ccc50] coded y,uvDC,uvAC intra: 45.2% 53.6% 27.3% inter: 39.4% 27.6% 2.7%
    [libx264 @ 0x7f28327ccc50] i16 v,h,dc,p: 28% 57% 11%  5%
    [libx264 @ 0x7f28327ccc50] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 66% 11%  1%  1%  1%  2%  1%  2%
    [libx264 @ 0x7f28327ccc50] i8c dc,h,v,p: 23% 58% 17%  3%
    [libx264 @ 0x7f28327ccc50] kb/s:2331.88

    `

  • Centos7 Server, Masrer Playlist can't create CODECS when use ffmpeg with libx265 (h.265)

    8 juillet 2020, par Duy Đức Nguyễn Phạm

    I use ffmpeg to stream from a link, when I use libx264 it run very good but when I use libx265, file master playlist can't create CODECS

    


    #ffmpeg

ffmpeg version N-98423-g584f396 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
  configuration: --prefix=/./usr/local/ffmpeg --bindir=/./usr/local/bin/ --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 55.100 / 56. 55.100
  libavcodec     58. 94.100 / 58. 94.100
  libavformat    58. 48.100 / 58. 48.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 86.100 /  7. 86.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100


    


    I check output video by command

    


    #ffprobe -v error -select_streams v:0 -show_entries stream=codec_name   -of default=noprint_wrappers=1:nokey=1 v0_s.m3u8


    


    Then the screen show

    


    hevc
hevc


    


    And this is master playlist comparison example when I use x265 (v0) and x264 (v1)

    


    #EXTM3U
#EXT-X-VERSION:7
#EXT-X-STREAM-INF:BANDWIDTH=401500,RESOLUTION=640x480
v0/prog_index.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2200000,RESOLUTION=1280x720,CODECS="avc1.42c01f"
v1/prog_index.m3u8


    


    Sorry about my English.
Can you help me ? Thank you !