Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • select frame of choice for thumbnail in ffmpeg

    1er octobre 2014, par Rks Rock

    Description

    I have successfully installed and used ffmpeg in my project ... I am able to create thumbnails by selecting a frame at X seconds... But that is not enough what if at X seconds there is a blacked out scene in the video or some scene that does not justify what the video is about ..

    So is there a way that I can make a UI that will give the user to select the frame lets say using a track-bar so that user can drag the track bar to a specific frame and select it as a thumbnail like a poster...

    Any one done that ??

  • Compress Videos using FFMPEG and JNI

    1er octobre 2014, par Mr.G

    I want to create an android application which can locate a video file (which is more than 300 mb) and compress it to lower size mp4 file.

    i already tried to do it with this

    This tutorial is a very effective since you 're compressing a small size video (below than 100 mb)

    So i tried to implement it using JNI .

    i managed to build ffmpeg using this

    But currently what I want to do is to compress videos . I don't have very good knowledge on JNI. But i tried to understand it using following link

    If some one can guide me the steps to compress video after open file it using JNI that whould really great , thanks

  • Executing an exe and reading the OutputStream

    30 septembre 2014, par vlatkozelka

    I have a program called FFprobe which probes media (files/live streams ... ) and outputs result in different formats , for example :

    ffprobe.exe -i test.ts -print_format xml -show_programs
    

    gives this output :

        <?xml version="1.0" encoding="UTF-8"?>
    
        
            
                
                
                
                    
                        
                    
                    
                        
                    
                
             
    ... more programs 
    

    to retrieve this info in java i used ProcessBuilder and a scanner , and then id write to a file once the result is ok ... but it wasnt :

     Process proc = new ProcessBuilder("ffprobe.exe","-i", ... same arguments );
     Scanner sc = new Scanner (proc.getInputStream()) // im 100% sure its not errorStream
     while(sc.hasNext()){
       System.out.println(sc.nextLine());
     }
    

    the app just hangs with no output , i know its hanging cuz the process is still running and scanner has next , but , i don't know why it would do that ?If i execute the same in cmd i would get good result and ofc i can write to file with ">"

    Ive tried it w/o the -print_format option , which gives the info in a plain text on the errorstream(i know its error cuz i was able to write with 2> not >> ) , and i was able to read the error stream in java , but its not meant for parsing cuz very very un-organized .

       Input #0, mpegts, from 'PBR_REC_20140426094852_486.ts':
      Duration: 00:13:34.30, start: 7791.344722, bitrate: 42154 kb/s
      Program 1201 
        Metadata:
          service_name    : Arabica TV
          service_provider: Nilesat
        Stream #0:19[0x7db]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 16:15 DAR 4:3], max. 2348 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
        Stream #0:3[0xbcf]: Audio: mp2, 48000 Hz, stereo, s16p, 384 kb/s
      Program 1202 
        Metadata:
          service_name    : NBN
          service_provider: NILESAT
        Stream #0:10[0x7d1]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 16:15 DAR 4:3], max. 2600 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
        Stream #0:11[0xbba](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 125 kb/s
      Program 1203 
        Metadata:
          service_name    : Heya TV
          service_provider: NILESAT
        Stream #0:5[0x7d2]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 16:15 DAR 4:3], max. 2600 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
        Stream #0:6[0xbbc](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 125 kb/s
      Program 1204  ... more programs
    

    now it might seem organized and "parse-able" and i actually made a parser that worked to some point , but sometimes it doesnt stick to this structure and ruins the whole parsing, its why i need a xml/json ...

    The -print_format im sure outputs to outputstream.

    Im not asking for help on how to use FFprobe as thats not this place's purpose , Im asking why am i not being able to get the output stream from java while it is definitely outputting if i execute in windows .

    I also tried apache commons-exec as i know processbuilder can be a pain ,it did execute perfectly and showed in System.in (black for intput and red for error), but getting the stream with apache is something i couldn't understand , i tried this example

    The xml parser i already taken care of , simply put i just need to execute that first command from java and read the output , but for some reason its not working .

  • Loading and unloading C jni library based on when it's needed

    30 septembre 2014, par Alin

    I finally managed to compile ffmpeg for android and I've been able to use it in my app.

    Here is the scenario of my app:

    • I show the user a gridview with thumbnails of images and videos
    • the user can click on a cell and it is taken to image/video details where he can see the full image or play the video
    • the user can apply an image over an video and this is when ffmpeg is used

    So basically, the user might never actually use the watermarking option or he can do it very rare because the amount of available videos is way smaller than images.

    I am loading the ffmpeg library, first time it is needed by running:

    static {
         System.loadLibrary("ffmpeglib");
    }
    

    Now here are my questions:

    1. loading the library like this, uses app's memory and resources ?
    2. can I unload the library, or better said, is it needed to unload it ? I have not found any java code like System.unloadLibrary to take care of unloading
    3. Since the library might be used rarely, wouldn't a load => do encoding => unload be a better approach ? Or maybe having it loaded would allow easy reuse since no loading is necessary.
    4. If I use an IntentService to load the library and make the encoding, when the service completes the job, does the library gets unloaded ?
  • maintain aspect ratio while creating thumbnails in ffmpeg

    30 septembre 2014, par Rks Rock

    Description :

    So after a thorough search I went with the answers I found on Stack Overflow about video uploading and thumbnail creation by using ffmpeg .. I am using the following code to create the thumbnail of the video I am uploading .. every thing was working fine until I modified my code to maintain the aspect ratio of the created thumbnails as well .

    $ffmpeg = "C:\\ffmpeg\\bin\\ffmpeg";
                    $videoFile = $_FILES['vid']['tmp_name'];
                    $videoFilename = "1.jpg";
                    $size = "120x90";
                    $getseconds = 5;
                    $cmd = "$ffmpeg -i $videoFile -vf scale='min(300\, iw):-1' -ss $getseconds -s $size -vframes 1 $videoFilename";
    

    Now nothing is working ... what am I doing wrong .. anyone??