Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFMPEG - Dynamic SWF File to MP4

    2 décembre 2014, par Mavichow

    I downloaded FFMPEG at here for my window x64.

    And here is my .php file that stored at Localhost :

    $ffmpeg = 'D:\Software\ffmpeg-20141202-git-4280150-win64-static\bin\ffmpeg.exe';
    $swf    = "http://symmetrydigital-labs.com/junior/kazim/portal/flv/Shahid_Kapoor_07.swf";
    
    $cmd    = "$ffmpeg -i $swf test.mp4";
    shell_exec($cmd);
    

    above code are working great and fine, because the SWF its a static SWF, But when I need to convert this SWF, that require Dynamic Parameter, or the swf is scripted in AS3.

    Then it went error and can't convert to .mp4 file.

    $ffmpeg = 'D:\Software\ffmpeg-20141202-git-4280150-win64-static\bin\ffmpeg.exe';
    $swf    = "http://www.permadi.com/tutorial/flashQueryString/loaderInfoExample.swf?userName=12322";
    
    $cmd    = "$ffmpeg -i $swf test.mp4";
    shell_exec($cmd);
    

    And I try to execute on Command line, and I found out Could not find Codec parameter Error,

    enter image description here

  • building opencv, got undefined reference to avformat_network_init error

    2 décembre 2014, par Chan Kim

    I am using CentOS6.5, I downloaded opencv-2.4.9, made build directory, and under there, ran 'cmake ..' and 'make'. During the make run, I got this error message.

    link error message

    I found avformat_network_init in ffmpeg source, I installed ffmpeg once in my home and then to /usr/lib. but I don't know how to tell cmake where ffmpeg is installed (include header and library).
    Now I see some *.so files from ffmpeg under /usr/lib64. but why can't cmake find the ffmpeg location? Thanks in advance.

  • concat files with ffmpeg using python's subprocess.Popen

    2 décembre 2014, par SaulTigh

    I'm trying to concatenate videos generating such commands as:

    ffmpeg -i /srv/proj/chunks/phrases/lq/ti.mp4 -y -c copy -bsf:v h264_mp4toannexb -f mpegts /tmp/ti.mp4 & ffmpeg -i /srv/proj/chunks/phrases/lq/luchshii.mp4 -y -c copy -bsf:v h264_mp4toannexb -f mpegts /tmp/luchshii.mp4 & ffmpeg -i /srv/proj/chunks/phrases/lq/novii.mp4 -y -c copy -bsf:v h264_mp4toannexb -f mpegts /tmp/novii.mp4 & ffmpeg -i /srv/proj/chunks/phrases/lq/drug.mp4 -y -c copy -bsf:v h264_mp4toannexb -f mpegts /tmp/drug.mp4 & ffmpeg -f mpegts -i "concat:/tmp/ti.mp4|/tmp/luchshii.mp4|/tmp/novii.mp4|/tmp/drug.mp4" -y -c copy -bsf:a aac_adtstoasc /srv/proj/concats/ty-luchshii-novyi-drug.lq.mp4
    

    This command works perfectly when I just ytpe it in terminal, but when I use subprocess.Popen, it hangs on the last processed chunk like this

    What can be wrong?

    P.S: This is how I'm executing my commands:

    def _execute(command_str, **kwargs):
        import subprocess
        import shlex
    
        command = shlex.split(command_str)
    
        try:
            pipe = subprocess.Popen(command, **kwargs)
            pipe.wait()
            stdout, stderr = pipe.communicate()
        except Exception:
            raise ConcatError('cannot concat files')
    
        return stdout
    

    P.P.S: os.system() instead of subprocess.Popen() did the trick, but the problem with subprocess remains.

  • Paperclip autoconvert GIF to MP4

    2 décembre 2014, par Mark Boulder

    I'm trying to autoconvert animated GIFs to MP4 using paperclip-ffmpeg -- but why are the newly created .flv files empty?

    app/models/photo.rb

    class Photo < ActiveRecord::Base
      has_attached_file :attachment, :styles => {
        medium: {format: "flv"},
        thumbnail: {format: "png"}
      }, :processors => [:ffmpeg]
    
      belongs_to :post, class_name: "Forem::Post"
    
      validates_attachment :attachment, presence: true, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"] }
    end
    

    config/environments/development.rb Paperclip.options[:command_path] = "/usr/bin/"

    Please try with this live app: http://runnable.com/VF91dsT_ufU_OLLG/rails-paperclip-gif-to-mp4

    Login: admin@example.com

    Password: admin1234

    Example GIF:

    enter image description here

    ffmpeg

    # ffmpeg
    ffmpeg version 0.8.7-6:0.8.7-1ubuntu2
    # which ffmpeg
    /usr/bin/ffmpeg
    

    Log

    # tail log/development.log
    Started POST "/default/topics" at 2014-12-02 06:47:58 +0000
    Processing by Forem::TopicsController#create as HTML
      Parameters: {"utf8"=>"✓", "authenticity_token"=>"8W8wk42e28JOUnUNvPjgfslVNV//aAmj4nxz/8dfqM0=", "topic"=>{"subject"=>"dfhfhdfhdfhdf", "posts_attribute
    s"=>{"0"=>{"text"=>"sdfsdfsdfsdf", "photos_attributes"=>{"0"=>{"attachment"=>#RackMultipart20141202-40-hqit2u>, @original_filename="gif.gif", @content_type="image/gif", @headers="Content-Disposition: form-data; name=\"topic[posts
    _attributes][0][photos_attributes][0][attachment]\"; filename=\"gif.gif\"\r\nContent-Type: image/gif\r\n">}}}}}, "commit"=>"Create Topic", "forum_id"=>"
    default"}
      User Load (0.3ms)  SELECT  "users".* FROM "users"  WHERE "users"."id" = 1  ORDER BY "users"."id" ASC LIMIT 1
      Forem::Forum Load (0.2ms)  SELECT  "forem_forums".* FROM "forem_forums"  WHERE "forem_forums"."slug" = 'default'  ORDER BY "forem_forums"."name" ASC L
    IMIT 1
      Forem::Category Load (0.1ms)  SELECT  "forem_categories".* FROM "forem_categories"  WHERE "forem_categories"."id" = ? LIMIT 1  [["id", 1]]
    Command :: file -b --mime '/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-17gal7n.gif'
    [paperclip] [ffmpeg] ffprobe "/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg1.gif" 2>&1
    [paperclip] [ffmpeg] Command Success
    [paperclip] [ffmpeg] Making...
    [paperclip] [ffmpeg] Building Destination File: 'd38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg1' + 'flv'
    [paperclip] [ffmpeg] Destination File Built
    [paperclip] [ffmpeg] Adding Geometry
    [paperclip] [ffmpeg] Adding Format
    [paperclip] [ffmpeg] Adding Source
    [paperclip] [ffmpeg] Building Parameters
    [paperclip] [ffmpeg] -i :source -y :dest
    Command :: ffmpeg -i '/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg1.gif' -y '/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg120141202
    -40-t4mbua.flv'
    Command :: file -b --mime '/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg120141202-40-t4mbua.flv'
    [paperclip] [ffmpeg] ffprobe "/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg1.gif" 2>&1
    [paperclip] [ffmpeg] Command Success
    [paperclip] [ffmpeg] Making...
    [paperclip] [ffmpeg] Building Destination File: 'd38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg1' + 'png'
    [paperclip] [ffmpeg] Destination File Built
    [paperclip] [ffmpeg] Adding Geometry
    [paperclip] [ffmpeg] Adding Format
    [paperclip] [ffmpeg] Adding Source
    [paperclip] [ffmpeg] Building Parameters
    [paperclip] [ffmpeg] -ss 3 -i :source -vframes 1 -f image2 -y :dest
    Command :: ffmpeg -ss 3 -i '/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-16dhhg1.gif' -vframes 1 -f image2 -y '/tmp/d38252762d3d4fd229faae637fd13f4e
    20141202-40-16dhhg120141202-40-1d5qljm.png'
       (0.2ms)  begin transaction
      Forem::Topic Exists (0.3ms)  SELECT  1 AS one FROM "forem_topics"  WHERE ("forem_topics"."id" IS NOT NULL) AND "forem_topics"."slug" = 'dfhfhdfhdfhdf'
     LIMIT 1
    Command :: file -b --mime '/tmp/d38252762d3d4fd229faae637fd13f4e20141202-40-zc9uyd.gif'
      SQL (0.7ms)  INSERT INTO "forem_topics" ("created_at", "forum_id", "slug", "subject", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?)  [["created_a
    t", "2014-12-02 06:47:59.655386"], ["forum_id", 1], ["slug", "dfhfhdfhdfhdf"], ["subject", "dfhfhdfhdfhdf"], ["updated_at", "2014-12-02 06:47:59.655386"
    ], ["user_id", 1]]
      SQL (0.3ms)  INSERT INTO "forem_posts" ("created_at", "text", "topic_id", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?)  [["created_at", "2014-12-02
     06:47:59.658316"], ["text", "sdfsdfsdfsdf"], ["topic_id", 24], ["updated_at", "2014-12-02 06:47:59.658316"], ["user_id", 1]]
      Forem::Topic Load (0.1ms)  SELECT  "forem_topics".* FROM "forem_topics"  WHERE "forem_topics"."id" = ? LIMIT 1  [["id", 24]]
      SQL (5.9ms)  UPDATE "forem_topics" SET "last_post_at" = '2014-12-02 06:47:59.658316' WHERE "forem_topics"."id" = 24
      Forem::Subscription Load (0.1ms)  SELECT  "forem_subscriptions".* FROM "forem_subscriptions"  WHERE "forem_subscriptions"."topic_id" = ?  ORDER BY "fo
    rem_subscriptions"."id" ASC LIMIT 1000  [["topic_id", 24]]
      SQL (0.1ms)  UPDATE "forem_posts" SET "notified" = 't' WHERE "forem_posts"."id" = 24
      SQL (0.1ms)  UPDATE "forem_posts" SET "state" = 'approved' WHERE "forem_posts"."id" = 24
    Binary data inserted for `string` type on column `attachment_content_type`
      SQL (0.2ms)  INSERT INTO "photos" ("attachment_content_type", "attachment_file_name", "attachment_file_size", "attachment_updated_at", "created_at", "
    post_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["attachment_content_type", "image/gif"], ["attachment_file_name", "gif.gif"], ["attachment_file_
    size", 1660134], ["attachment_updated_at", "2014-12-02 06:47:58.645579"], ["created_at", "2014-12-02 06:47:59.676633"], ["post_id", 24], ["updated_at",
    "2014-12-02 06:47:59.676633"]]
       (0.1ms)  SELECT COUNT(*) FROM "forem_subscriptions"  WHERE "forem_subscriptions"."topic_id" = ? AND "forem_subscriptions"."subscriber_id" = 1  [["top
    ic_id", 24]]
      SQL (0.1ms)  INSERT INTO "forem_subscriptions" ("subscriber_id", "topic_id") VALUES (?, ?)  [["subscriber_id", 1], ["topic_id", 24]]
      SQL (0.2ms)  UPDATE "forem_topics" SET "state" = 'approved' WHERE "forem_topics"."id" = 24
       (16.3ms)  commit transaction
    Redirected to http://web-fdf7b3ef-c097-41fe-ac7a-1cf06815fcbc.runnable.com/default/topics/dfhfhdfhdfhdf
    Completed 302 Found in 1114ms (ActiveRecord: 25.7ms)
    
  • JavaCV generate video from images Crashes

    2 décembre 2014, par Mohammad Khatri

    I am doing javacv with android since yesterday and getting error while generating video from image (IplImage) using FFmpegFrameRecorder or FrameRecorder while getting succes in imagefiltering using cvCvtColor and cvCvtColor.

    grayscale

    As shown in picture , Grayscale and flip filter is done by clicking second Button (Apply Effect).

    But when clicking (Make Video) it crashes.

    Here is my code for making video from image.

    String path = Environment.getExternalStorageDirectory().getPath() + "/test.mp4";
    Log.i("path", path);
    FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(path, 256, 256);
    try {
    
        recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);
        // recorder.setCodecID(avcodec.AV_CODEC_ID_H263);
        recorder.setFormat("mp4");
        recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
        recorder.start();
        for (int i = 0; i < 10; i++) {
    
            recorder.record(image);
        }
        recorder.stop();
    } catch (Exception e) {
    
        e.printStackTrace();
    }
    

    image is of type IplImage

    getting error on recorder object creation.

    I am using 2 devices

    1)Asus zenfone 5

    Stacktrace

    Caused by: java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avcodec
                at org.bytedeco.javacpp.Loader.load(Loader.java:387)
                at org.bytedeco.javacpp.Loader.load(Loader.java:353)
                at org.bytedeco.javacpp.avformat.(avformat.java:13)
                at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:106)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
                at android.os.AsyncTask$2.call(AsyncTask.java:288)
                at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                at java.lang.Thread.run(Thread.java:841)
         Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avcodec
                at java.lang.Class.classForName(Native Method)
                at java.lang.Class.forName(Class.java:251)
                at org.bytedeco.javacpp.Loader.load(Loader.java:385)
                at org.bytedeco.javacpp.Loader.load(Loader.java:353)
                at org.bytedeco.javacpp.avformat.(avformat.java:13)
                at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:106)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
                at android.os.AsyncTask$2.call(AsyncTask.java:288)
                at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                at java.lang.Thread.run(Thread.java:841)
         Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.javacvex1-1/libjniavcodec.so" has unexpected e_machine: 40
                at java.lang.Runtime.loadLibrary(Runtime.java:364)
                at java.lang.System.loadLibrary(System.java:526)
                at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
                at org.bytedeco.javacpp.Loader.load(Loader.java:410)
                at org.bytedeco.javacpp.Loader.load(Loader.java:353)
                at org.bytedeco.javacpp.avcodec.(avcodec.java:12)
                at java.lang.Class.classForName(Native Method)
                at java.lang.Class.forName(Class.java:251)
                at org.bytedeco.javacpp.Loader.load(Loader.java:385)
                at org.bytedeco.javacpp.Loader.load(Loader.java:353)
                at org.bytedeco.javacpp.avformat.(avformat.java:13)
                at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:106)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
                at android.os.AsyncTask$2.call(AsyncTask.java:288)
                at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                at java.lang.Thread.run(Thread.java:841)
         Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.javacvex1-1/libavcodec.so" has unexpected e_machine: 40
    

    2) Htc me tablet

    (Stacktrace)

    Caused by: java.lang.ExceptionInInitializerError
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
                at android.os.AsyncTask$2.call(AsyncTask.java:264)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
                at java.lang.Thread.run(Thread.java:856)
         Caused by: java.lang.ExceptionInInitializerError
                at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:106)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
                at android.os.AsyncTask$2.call(AsyncTask.java:264)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
                at java.lang.Thread.run(Thread.java:856)
         Caused by: java.lang.ExceptionInInitializerError
                at java.lang.Class.classForName(Native Method)
                at java.lang.Class.forName(Class.java:217)
                at org.bytedeco.javacpp.Loader.load(Loader.java:385)
                at org.bytedeco.javacpp.Loader.load(Loader.java:353)
                at org.bytedeco.javacpp.avformat.(avformat.java:13)
                at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:106)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
                at android.os.AsyncTask$2.call(AsyncTask.java:264)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
                at java.lang.Thread.run(Thread.java:856)
         Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1936]:    76 could not load needed library 'libavcodec.so' for 'libjniavcodec.so' (find_library[1199]:    76 'libavcodec.so' failed to load previously)
                at java.lang.Runtime.loadLibrary(Runtime.java:370)
                at java.lang.System.loadLibrary(System.java:535)
                at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
                at org.bytedeco.javacpp.Loader.load(Loader.java:410)
                at org.bytedeco.javacpp.Loader.load(Loader.java:353)
                at org.bytedeco.javacpp.avcodec.(avcodec.java:12)
                at java.lang.Class.classForName(Native Method)
                at java.lang.Class.forName(Class.java:217)
                at org.bytedeco.javacpp.Loader.load(Loader.java:385)
                at org.bytedeco.javacpp.Loader.load(Loader.java:353)
                at org.bytedeco.javacpp.avformat.(avformat.java:13)
                at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:106)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
                at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
                at android.os.AsyncTask$2.call(AsyncTask.java:264)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
                at java.lang.Thread.run(Thread.java:856)
         Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1936]:    76 could not load needed library 'libswresample.so' for 'libavcodec.so' (load_library[1091]: Library 'libswresample.so' not found)
    

    At last I am putting my build.gradle with jniLibs on left side.

    enter image description here

    No luck with answers from other questions. Stuck since last 24 hours. :(

    Any help will be great.