Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Streaming jpegs to a video on my server

    2 décembre 2013, par Andrew Simpson

    I found a solution to my problem IF I was using a Linux/UNIX machine. It is FFServer from the tools from FFMPEG.

    I had been using FFMPEG on my client Winform Desktop C# to convert jpegs into an OGG video file for playback.

    I have now been tasked with uploading the jpegs to my server and rendering it as a video.

    Optimum, I would start an FFMPEG process on my client PC and supply its stdin with jpegs in byte array format. I have achieved this (I have looked around) but is there a way to redirect the stdoutput to my server that can be picked up by my code on the server and render in real-time to my web User?

    I have looked on the ffmpeg web site but I am unsure how to 'fit' it in with my process.

    This is my code so far:

        public byte[] EncodeAndUploadImages(string _args1, string _fn)  
        {
            byte[] _data = null;
            try
            {
                clientBuild = new Process();
                clientBuild.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
                clientBuild.StartInfo.Arguments = " -f mjpeg -r 30 -i - -c:v libtheora -q:v 7 -r 30 -f ogg -";
                clientBuild.StartInfo.FileName = Environment.CurrentDirectory + @"\ffmpeg.exe";
                clientBuild.StartInfo.UseShellExecute = false;
                clientBuild.StartInfo.RedirectStandardOutput = true;
                clientBuild.StartInfo.RedirectStandardError = true;
                clientBuild.StartInfo.RedirectStandardInput = true;
                clientBuild.StartInfo.CreateNoWindow = true;
                clientBuild.StartInfo.LoadUserProfile = false;
                clientBuild.EnableRaisingEvents = true;    
                clientBuild.Start();
    
                using (BinaryWriter bw = new BinaryWriter(clientBuild.StandardInput.BaseStream))
                {
                   //I am simulating a stream of jpegs coming in////////////////
                    for (int i = 1; i < 20; i++)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            System.Diagnostics.Debug.Write(i.ToString("00000"));
                            Bitmap bmp = new Bitmap("h:\\streamin\\" + i.ToString("00000") + ".jpg");
                            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                            bw.Write(ms.ToArray());                           
                            bmp.Dispose();
                            ms.Close();
                        }
                    }
                    bw.Close();
                }
    
                // I need some in my ffmpeg arguments to do something here//////   
                mStandardOutput = clientBuild.StandardOutput.BaseStream;
                mStandardOutput.BeginRead(mReadBuffer, 0, mReadBuffer.Length, StandardOutputReadCallback, null);
                clientBuild.WaitForExit();
                _data = mStandardOutputMs.ToArray();
                mStandardOutput.Close();
            }
            catch (Exception _ex)
            {
    
            }
            finally
            {
                clientBuild.Dispose();
            }
            return _data;
        }
    

    Thanks

  • Applying effects to video while capturing in android ?

    2 décembre 2013, par kalyan pvs

    How can i apply effects to video while capturing i am tried in a lot of ways but output is nothing..i have searched and find one Application VideoFx whaich done what i want..but i didn't get what they are doing..

    i have done the applying effects to the image with using GPUImageProcessing library..For Applying effects shall i have capture normal video and make it to frames and Apply effects to that frames and again recombine those frames into video..is this is the only process or any other alternatives..Most of the stack answers suggest me FFMPEG with using this i get frames from the video ..how to recombine it again??

    I think with using this Camera effects we can apply effects to videos while recording..But i don't know how to apply it with using openGl.

  • Mjpeg text based subtitle extraction/replay

    2 décembre 2013, par user3058117

    I have an MJPEG based avi file that I cannot replay satisfactorily.

    The video I can correctly replay in FFPlay but i cannot replay or demux the text based subtitle stream.

    The file contains time/date stamps in the subtitles embedded as ascii text which i can see between the video packets (when viewed in a hex reader).

    FFmpeg cannot identify the subtitle codec b7t can see that there is a subtitle stream.

    Ive tried a number of filter combinations using GraphStudioNext. I found a couple of working solutions (when previewed in GraphStudio when served to avisynth the subtitles had disappeared again. I checked the filtergraph and the pin out from the avi splitter had misteriously disconnected. I cannot find a way out of this.

    Does anyone have any suggestions on how i might demux the subtitle stream(short of writing a converter to extract the text to srt based on the packet timing)?

    This is my first post so apologies if i havent observed etiquette.

  • Undefined references while using ffmpeg 2.1.1 for Android

    2 décembre 2013, par Kernald

    I'm building ffmpeg following the same pattern as halfninja's build: make the ffmpeg's main available from Java through JNI. I built ffmpeg with the following options:

    ./configure \
        --prefix=$PREFIX \
        --disable-shared \
        --enable-static \
        --disable-doc \
        --disable-ffmpeg \
        --disable-ffplay \
        --disable-ffprobe \
        --disable-ffserver \
        --disable-doc \
        --disable-symver \
        --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
        --target-os=linux \
        --arch=arm \
        --enable-cross-compile \
        --sysroot=$SYSROOT \
        --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
        --extra-ldflags="$ADDI_LDFLAGS"

    $PREFIX, TOOLCHAIN, … being set to corresponding folders from my NDK. $ADDI_CFLAGS is set to -marm and $ADDI_LDFLAGS and $ADDITIONAL_CONFIGURE_FLAGS are both unset. The resulting static libraries are created:

    $ ls -1 android/arm/lib/
    libavcodec.a
    libavdevice.a
    libavfilter.a
    libavformat.a
    libavutil.a
    libswresample.a
    libswscale.a
    pkgconfig

    I expose them with an Android.mk file, ffmpeg being built in $NDK/sources/ffmpeg-2.1.1:

    LOCAL_PATH:= $(call my-dir)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE:= libavdevice
    LOCAL_SRC_FILES:= lib/libavdevice.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE:= libavcodec
    LOCAL_SRC_FILES:= lib/libavcodec.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE:= libavformat
    LOCAL_SRC_FILES:= lib/libavformat.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE:= libswscale
    LOCAL_SRC_FILES:= lib/libswscale.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE:= libavutil
    LOCAL_SRC_FILES:= lib/libavutil.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE:= libavfilter
    LOCAL_SRC_FILES:= lib/libavfilter.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE:= libwsresample
    LOCAL_SRC_FILES:= lib/libswresample.a
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_STATIC_LIBRARY)

    So, up to there, everything looks good. Now, I try to build the ffmpeg binary equivalent as a static library. I copied (and didn't change a single character for now) ffmpeg.c, ffmpeg.h, cmdutils.c, cmdutils.h, ffmpeg_opt.cand ffmpeg_filter.c in my jni folder. I also have two directly JNI-related files in this folder (copied from halfninja's build, I just changed the package name). Here's the relevant Android.mk:

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    LOCAL_C_INCLUDES := /Applications/android-ndk-r9b/sources/ffmpeg-2.1.1
    LOCAL_CFLAGS := -Wdeprecated-declarations
    LOCAL_MODULE := videokit
    ANDROID_LIB := -landroid
    LOCAL_LDLIBS += -llog -ljnigraphics -lz 
    LOCAL_SRC_FILES := videokit/com_rfc_video_ffmpeg_Videokit.c videokit/ffmpeg.c videokit/cmdutils.c videokit/ffmpeg_opt.c videokit/ffmpeg_filter.c
    LOCAL_SHARED_LIBRARIES := libavdevice libavformat libavfilter libavcodec libwscale libavutil libswresample libswscale libpostproc
    include $(BUILD_SHARED_LIBRARY)
    $(call import-module,ffmpeg-2.1.1/android/arm)

    Everything compiles fine, but doesn't link. Here are the first errors:

    [armeabi] SharedLibrary  : libvideokit.so
    /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/videokit/videokit/cmdutils.o: in function print_all_libs_info.constprop.5:jni/videokit/cmdutils.c:1063: error: undefined reference to 'swresample_version'
    /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/videokit/videokit/cmdutils.o: in function print_all_libs_info.constprop.5:jni/videokit/cmdutils.c:1063: error: undefined reference to 'swresample_configuration'
    /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/videokit/videokit/cmdutils.o: in function opt_default:jni/videokit/cmdutils.c:558: error: undefined reference to 'swr_get_class'
    /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/videokit/videokit/cmdutils.o: in function opt_default:jni/videokit/cmdutils.c:561: error: undefined reference to 'swr_alloc'
    /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/videokit/videokit/cmdutils.o: in function opt_default:jni/videokit/cmdutils.c:563: error: undefined reference to 'swr_free'
    /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/videokit/videokit/ffmpeg_opt.o: in function show_help_default:jni/videokit/ffmpeg_opt.c:2464: error: undefined reference to 'swr_get_class'

    What I don't understand is that these functions are defined and available in libswresample.a, which I'm linking to:

    arm-linux-androideabi-nm /Applications/android-ndk-r9b/sources/ffmpeg-2.1.1/android/arm/lib/libswresample.a  | grep -i -e swr_get_class -e swresample_version
    000001d4 T swr_get_class
    00000178 T swresample_version

    What am I doing wrong? Is there another, maybe simpler way to expose ffmpeg as a static library available via JNI? (I don't use halfninja's because I need at least ffmpeg 1.1, while his is in 0.9).

  • Paperclip with heroku and paperclip, migration fails

    2 décembre 2013, par jdartland

    I have a created ruby on rails application and I'm using paperclip to handle my file uploads. Paperclip works just fine on my local machine. But my video upload stops working when I deploy to Heroku. Does anyone know whats going wrong. I also get an error when I try to upload a video which says that the video filename does not exist. The photo upload works but not the Video, I'm using paperclip iwth nested attributes and ffmpeg.

    Upload Error log:

    Paperclip::Error (Asset model missing required attr_accessor for 'video_file_name')
    2013-12-02T14:38:16.867747+00:00 app[web.1]: Paperclip::Error (Asset model missing required attr_accessor for 'video_file_name'):
    2013-12-02T14:38:16.867747+00:00 app[web.1]:   app/controllers/projects_controller.rb:60:in `block in update'
    2013-12-02T14:38:16.867747+00:00 app[web.1]:   app/controllers/projects_controller.rb:59:in `update'
    

    Here is my migration error:

    Migrating to AddAttachmentPhotoToAssets (20131021134721)
    ==  AddAttachmentPhotoToAssets: migrating =====================================
    -- change_table(:assets)
       -> 0.0273s
    ==  AddAttachmentPhotoToAssets: migrated (0.0276s) ============================
    
    Migrating to AddProjectIdToAssets (20131022082744)
    -- add_column(:assets, :project_id, :integer)
    PG::DuplicateColumn: ERROR:  column "project_id" of relation "assets" already exists
    : ALTER TABLE "assets" ADD COLUMN "project_id" integer
    -- add_column(:assets, :project_id, :integer)
    PG::DuplicateColumn: ERROR:  column "project_id" of relation "assets" already exists
    : ALTER TABLE "assets" ADD COLUMN "project_id" integer
    rake aborted!
    PG::DuplicateColumn: ERROR:  column "project_id" of relation "assets" already exists
    : ALTER TABLE "assets" ADD COLUMN "project_id" integer
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
    /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:360:in `add_column'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/schema_statements.rb:379:in `add_column'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:625:in `block in method_missing'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:597:in `block in say_with_time'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:597:in `say_with_time'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:617:in `method_missing'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:383:in `method_missing'
    /app/db/migrate/20131022082744_add_project_id_to_assets.rb:2:in `'
    /app/db/migrate/20131022082744_add_project_id_to_assets.rb:1:in `'
    /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
    /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:718:in `load_migration'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:714:in `migration'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:708:in `disable_ddl_transaction'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:1012:in `use_transaction?'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:922:in `rescue in block in migrate'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:919:in `block in migrate'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:916:in `each'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:916:in `migrate'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `up'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:742:in `migrate'
    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:42:in `block (2 levels) in '
    Tasks: TOP => db:migrate
    (See full trace by running task with --trace)
    

    Here is my table:

     create_table "assets", force: true do |t|
        t.datetime "created_at"
        t.datetime "updated_at"
        t.string   "photo_file_name"
        t.string   "photo_content_type"
        t.integer  "photo_file_size"
        t.datetime "photo_updated_at"
        t.integer  "project_id"
        t.string   "video_file_name"
        t.string   "video_content_type"
        t.integer  "video_file_size"
        t.datetime "video_updated_at"
      end
    add_index "projects", ["permalink"], name: "index_projects_on_permalink", using: :btree
    
      create_table "settings", force: true do |t|
        t.string   "title"
        t.text     "description"
        t.text     "paragraph"
        t.datetime "created_at"
        t.datetime "updated_at"
        t.string   "photo_file_name"
        t.string   "photo_content_type"
        t.integer  "photo_file_size"
        t.datetime "photo_updated_at"
        t.string   "video_file_name"
        t.string   "video_content_type"
        t.integer  "video_file_size"
        t.datetime "video_updated_at"
      end
    

    Would gladly need some help! :)