Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFMPEG App not working

    5 juin 2017, par Gio Vanno

    First, I'm a newbie in this compiling with NDK thing, so i decided to use other's project for reference i'm using one from here

    https://github.com/Kernald/ffmpeg-android

    I've copy this project and try to run it, but it giving me this error:

    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.a45vu.myapplication-1/base.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.a45vu.myapplication-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.a45vu.myapplication-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libvideokit.so" at java.lang.Runtime.loadLibrary(Runtime.java:367) at java.lang.System.loadLibrary(System.java:1076) at com.example.a45vu.myapplication.Videokit.(Videokit.java:9) at com.example.a45vu.myapplication.Videokit.getInstance(Videokit.java:0) at com.example.a45vu.myapplication.MainActivity$1.onClick(MainActivity.java:22) at android.view.View.performClick(View.java:5210) at android.view.View$PerformClick.run(View.java:21169) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5451) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

    I've followed this tutorial

    https://enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/

    I don't know what i've missed so far.

    Need a help here

  • Running ffmpeg command on Android results in "Unable to find a suitable output format for ' -map 0:v:0 -map 1:a:0'"

    5 juin 2017, par Akash Dubey

    I am using this command for replacing audio of video and genrate new video having new audio. Here file1 is my video.mp4, file2 is my audio.mp3 and output would be the output.mp4:

    complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};
    

    Below is My code:

        private void changeAudioofVideo(String selectedUri, String videoPath) {
    
        String[] complexCommand;
    
    
        File f = new File("/storage/emulated/0");
        if (!f.getParentFile().exists())
            f.getParentFile().mkdirs();
        if (!f.exists())
            try {
                f.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
    
        file1 = new File(videoPath);
        if (file1.exists()) {
            Log.d("yes", "File 1 exists");
        } else {
            Log.d("no", "File 1 not exists");
        }
    
        file2 = new File(selectedUri);
        if (file2.exists()) {
            Log.d("yes", "File 1 exists");
        } else {
            Log.d("no", "File 1 not exists");
        }
    
        String rootPath = f.getPath();
    
        complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};
    
        FFmpeg ffmpeg = FFmpeg.getInstance(this);
    
        try {
            //Load the binary
            ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
    
                @Override
                public void onStart() {
                }
    
                @Override
                public void onFailure() {
                }
    
                @Override
                public void onSuccess() {
                }
    
                @Override
                public void onFinish() {
                }
            });
        } catch (FFmpegNotSupportedException e) {
            // Handle if FFmpeg is not supported by device
            Toast.makeText(getApplicationContext(), "Not Supported by Device", Toast.LENGTH_LONG).show();
        }
    
        try {
    
            final String finalRootPath = rootPath;
            ffmpeg.execute(complexCommand, new FFmpegExecuteResponseHandler() {
                @Override
                public void onSuccess(String message) {
                    Log.d("Success", message);
    
                    Toast.makeText(getApplicationContext(), "Successful" + finalRootPath.toString(), Toast.LENGTH_LONG).show();
                    Uri path = Uri.parse(finalRootPath + "/output.mp4");
                    playVideo(path.toString());
    
                }
    
                @Override
                public void onProgress(String message) {
                    Log.d("progress", message);
                    pd.show();
                }
    
                @Override
                public void onFailure(String message) {
                    Log.d("failure", message);
                    pd.dismiss();
    
                }
    
                @Override
                public void onStart() {
                    Log.d("Start", "merge started");
                }
    
                @Override
                public void onFinish() {
                    Log.d("finish", "merge finish");
                    pd.dismiss();
                }
            });
        } catch (FFmpegCommandAlreadyRunningException e) {
            e.printStackTrace();
        }
    
    
       }
    

    Below is my output:

       05-26 18:39:35.533 29188-29188/com.example.codal.videotm D/failure: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
                                                                      built with gcc 4.8 (GCC)
                                                                      configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-and    roid/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                      libavutil      55. 17.103 / 55. 17.103
                                                                      libavcodec     57. 24.102 / 57. 24.102
                                                                      libavformat    57. 25.100 / 57. 25.100
                                                                      libavdevice    57.  0.101 / 57.  0.101
                                                                      libavfilter     6. 31.100 /  6. 31.100
                                                                      libswscale      4.  0.100 /  4.  0.100
                                                                      libswresample   2.  0.101 /  2.  0.101
                                                                      libpostproc    54.  0.100 / 54.  0.100
                                                                    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/videokit/out2.mp4':
                                                                      Metadata:
                                                                        major_brand     : isom
                                                                        minor_version   : 512
                                                                        compatible_brands: isomiso2mp41
                                                                        encoder         : Lavf56.23.100
                                                                        comment         : Courtesy of National Geographic.  Used by Permission.
                                                                      Duration: 00:00:04.20, start: 0.046440, bitrate: 577 kb/s
                                                                        Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 160x120 [SAR 9:16 DAR 3:4], 521 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
                                                                        Metadata:
                                                                          handler_name    : VideoHandler
                                                                        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 50 kb/s (default)
                                                                        Metadata:
                                                                          handler_name    : SoundHandler
                                                                    [mp3 @ 0xb86ade60] Skipping 0 bytes of junk at 132692.
                                                                    [mjpeg @ 0xb86c9980] Changing bps to 8
                                                                    [mp3 @ 0xb86ade60] Estimating duration from bitrate, this may be inaccurate
                                                                    Input #1, mp3, from '/storage/emulated/0/Download/01 Kaari Kaari - Dobaara.mp3':
                                                                      Metadata:
                                                                        album           : Dobaara (SongsMp3.Co)
                                                                        artist          : Arko , Asees Kaur
                                                                        album_artist    : Arko & Asees Kaur
                                                                        composer        : Arko
                                                                        performer       : SongsMp3.Co
                                                                        copyright       : SongsMp3.Co
                                                                        disc            : 1/1
                                                                        encoded_by      : iTunes 12.6.0.100
                                                                        genre           : Bollywood
                                                                        TEXT            : SongsMp3.Co
                                                                        TPE4            : SongsMp3.Co
                                                                        TRSN            : SongsMp3.Co
                                                                        TOPE            : SongsMp3.Co
                                                                        TOLY            : SongsMp3.Co
                                                                        publisher       : SongsMp3.Co
                                                                        title           : Kaari Kaari (SongsMp3.Co)
                                                                        track           : 1/1
                                                                        date            : 2017
                                                                      Duration: 00:03:46.72, start: 0.000000, bitrate: 324 kb/s
                                                                        Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
                                                                        Stream #1:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 600x600 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
                                                                        Metadata:
                                                                          comment         : Cover (front)
                                                                    [NULL @ 0xb86cab70] Unable to find a suitable output format for ' -map 0:v:0 -map 1:a:0'
                                                                     -map 0:v:0 -map 1:a:0: Invalid argument
    05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/ViewRootImpl: #3 mView = null
    05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/finish: merge finish
    
  • Add and substract a subtitle using ffmpeg

    5 juin 2017, par J. Doe

    I want to convert a mkv file to a mp4 file. In the mkv file there is a subtitle I don’t want. However, there is another subtitle I want to add.

    The streams are as follow:

    • 0:0 video
    • 0:1 audio
    • 0:2 subtitle

    Input #1 anothersubtitle.srt*

    The command I give is as follow: ffmpeg -i video.mkv -i anothersubtitle.srt -map 0:v -c:v copy -map 0:a -c:a:0 aac -ab:a:0 256k -ar:a:0 48000 -ac:a:0 2 -metadata:s:a:0 language=eng -metadata:s:a:0 title=Stereo -map 1 -map -0:s output.mp4

    Ffmpeg gives an error: Automatic encoder selection failed for output stream #0:2. Default encoder for format ipod (codec none) is probably disabled. Please choose an encoder manually. Error selecting an encoder for stream 0:2

    The error it comes up with is about the stream with the subtitle I don’t want. Adding “-c:s mov_text” or “-scodec mov_text” will still select the unwanted subtitle. This will add the subtitle I want, but it also adds the subtitle I don’t want.

    On this and other sites there are numerous examples to be found to add or subtract a wanted or unwanted stream, but i could not find a way where i can leave one subtitle out and add another one. Can you help me out?

    Edit (adding full console output as requested):

    ffmpeg version 3.3.1 Copyright (c) 2000-2017 the FFmpeg developers
      built with Apple LLVM version 8.1.0 (clang-802.0.42)
      configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
      libavutil      55. 58.100 / 55. 58.100
      libavcodec     57. 89.100 / 57. 89.100
      libavformat    57. 71.100 / 57. 71.100
      libavdevice    57.  6.100 / 57.  6.100
      libavfilter     6. 82.100 /  6. 82.100
      libavresample   3.  5.  0 /  3.  5.  0
      libswscale      4.  6.100 /  4.  6.100
      libswresample   2.  7.100 /  2.  7.100
      libpostproc    54.  5.100 / 54.  5.100
    Input #0, matroska,webm, from 'movie.mkv':
      Metadata:
        encoder         : libebml v1.0.0 + libmatroska v1.0
      Duration: 03:15:12.66, start: 0.000000, bitrate: 9616 kb/s
        Chapter #0:0: start 0.000000, end 203.161000
        Metadata:
          title           : 00:00:00.000
        Chapter #0:1: start 203.161000, end 612.153000
        Metadata:
          title           : 00:03:23.161
        Chapter #0:2: start 612.153000, end 891.307000
        Metadata:
          title           : 00:10:12.153
        Chapter #0:3: start 891.307000, end 1048.714000
        Metadata:
          title           : 00:14:51.307
        Chapter #0:4: start 1048.714000, end 1302.384000
        Metadata:
          title           : 00:17:28.714
        Chapter #0:5: start 1302.384000, end 1428.010000
        Metadata:
          title           : 00:21:42.384
        Chapter #0:6: start 1428.010000, end 1837.669000
        Metadata:
          title           : 00:23:48.010
        Chapter #0:7: start 1837.669000, end 2063.728000
        Metadata:
          title           : 00:30:37.669
        Chapter #0:8: start 2063.728000, end 2503.751000
        Metadata:
          title           : 00:34:23.728
        Chapter #0:9: start 2503.751000, end 2656.737000
        Metadata:
          title           : 00:41:43.751
        Chapter #0:10: start 2656.737000, end 3055.761000
        Metadata:
          title           : 00:44:16.737
        Chapter #0:11: start 3055.761000, end 3309.431000
        Metadata:
          title           : 00:50:55.761
        Chapter #0:12: start 3309.431000, end 3404.860000
        Metadata:
          title           : 00:55:09.431
        Chapter #0:13: start 3404.860000, end 4424.754000
        Metadata:
          title           : 00:56:44.860
        Chapter #0:14: start 4424.754000, end 4625.704000
        Metadata:
          title           : 01:13:44.754
        Chapter #0:15: start 4625.704000, end 5162.115000
        Metadata:
          title           : 01:17:05.704
        Chapter #0:16: start 5162.115000, end 5366.319000
        Metadata:
          title           : 01:26:02.115
        Chapter #0:17: start 5366.319000, end 5521.182000
        Metadata:
          title           : 01:29:26.319
        Chapter #0:18: start 5521.182000, end 5916.869000
        Metadata:
          title           : 01:32:01.182
        Chapter #0:19: start 5916.869000, end 6199.777000
        Metadata:
          title           : 01:38:36.869
        Chapter #0:20: start 6199.777000, end 6576.612000
        Metadata:
          title           : 01:43:19.777
        Chapter #0:21: start 6576.612000, end 6945.981000
        Metadata:
          title           : 01:49:36.612
        Chapter #0:22: start 6945.981000, end 7122.824000
        Metadata:
          title           : 01:55:45.981
        Chapter #0:23: start 7122.824000, end 7379.789000
        Metadata:
          title           : 01:58:42.824
        Chapter #0:24: start 7379.789000, end 7609.310000
        Metadata:
          title           : 02:02:59.789
        Chapter #0:25: start 7609.310000, end 7811.637000
        Metadata:
          title           : 02:06:49.310
        Chapter #0:26: start 7811.637000, end 8024.725000
        Metadata:
          title           : 02:10:11.637
        Chapter #0:27: start 8024.725000, end 8301.376000
        Metadata:
          title           : 02:13:44.725
        Chapter #0:28: start 8301.376000, end 8806.506000
        Metadata:
          title           : 02:18:21.376
        Chapter #0:29: start 8806.506000, end 9255.621000
        Metadata:
          title           : 02:26:46.506
        Chapter #0:30: start 9255.621000, end 9528.018000
        Metadata:
          title           : 02:34:15.621
        Chapter #0:31: start 9528.018000, end 9675.416000
        Metadata:
          title           : 02:38:48.018
        Chapter #0:32: start 9675.416000, end 9981.763000
        Metadata:
          title           : 02:41:15.416
        Chapter #0:33: start 9981.763000, end 10092.332000
        Metadata:
          title           : 02:46:21.763
        Chapter #0:34: start 10092.332000, end 10223.171000
        Metadata:
          title           : 02:48:12.332
        Chapter #0:35: start 10223.171000, end 10528.393000
        Metadata:
          title           : 02:50:23.171
        Chapter #0:36: start 10528.393000, end 10911.359000
        Metadata:
          title           : 02:55:28.393
        Chapter #0:37: start 10911.359000, end 11106.721000
        Metadata:
          title           : 03:01:51.359
        Chapter #0:38: start 11106.721000, end 11331.278000
        Metadata:
          title           : 03:05:06.721
        Chapter #0:39: start 11331.278000, end 11712.659000
        Metadata:
          title           : 03:08:51.278
        Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1040, SAR 1:1 DAR 24:13, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
        Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
        Metadata:
          title           : DTS
        Stream #0:2(eng): Subtitle: subrip
        Metadata:
          title           : English
    Input #1, srt, from 'anothersubtitle.srt':
      Duration: N/A, bitrate: N/A
        Stream #1:0: Subtitle: subrip
    Automatic encoder selection failed for output stream #0:2. Default encoder for format mp4 (codec none) is probably disabled. Please choose an encoder manually.
    Error selecting an encoder for stream 0:2
    
  • segmentation error in c while using ffmpeg

    5 juin 2017, par Amartya2562

    danger's ffmpeg tutorials using c.

    The error I am getting is the following-

    [xcb] Unknown request in queue while dequeuing
    [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
    [xcb] Aborting, sorry about that.
    tutorial07: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
    Aborted (core dumped)
    
  • ffmpeg stream on docker

    5 juin 2017, par Alexander S.

    I am new to the docker and ffmpeg. I am trying to do following POC, using "jrottenberg/ffmpeg" container: stream video from my video camera to docker container, and got it back from docker container. First, I checked, that all working locally. Stream from video camera (I don't know exactly, what are all those parameters, but I found it working):

    ffmpeg -rtbufsize 1500M -re -f dshow -video_size 1280x720 -framerate 30 -r 30 -i video="Lenovo EasyCamera" -pix_fmt yuv420p -vcodec libx264 -vprofile baseline -an -strict experimental -f mpegts udp://localhost:1234

    Now playing the stream:

    ffplay.exe udp://localhost:1234
    

    See video, all fine. Now I am changing localhost to docker-machine ip udp://192.168.99.101:1234

    Running docker container, with port forwarding:

    docker run -p 1234:1234/udp -p 5555:5555/udp jrottenberg/ffmpeg -i udp://0.0.0.0:1234 -f mpegts udp://0.0.0.0:5555

    It seems to work. Here the docker output:

    logs

    PS C:\> docker logs d96094fc41e0 Input #0, mpegts, from 'udp://0.0.0.0:1234': Duration: N/A, start: 21.466667, bitrate: N/A Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 30 fps, 30 tbr, 90k tbn, 60 tbc Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native)) Press [q] to stop, [?] for help Output #0, mpegts, to 'udp://0.0.0.0:5555':ime=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A Metadata: encoder : Lavf57.71.100 Stream #0:0: Video: mpeg2video, yuv420p, 1280x720, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc Metadata: encoder : Lavc57.89.100 mpeg2video Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 frame= 214 fps= 70 q=31.0 size= 990kB time=00:00:11.96 bitrate= 678.1kbits/s speed=3.89x

    ps

    PS C:\> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d96094fc41e0 jrottenberg/ffmpeg "ffmpeg -i udp://0..." 5 minutes ago Up 5 minutes 0.0.0.0:1234->1234/udp, 0.0.0.0:5555->5555/udp hungry_poitras

    But, when i try to connect via ffplay:

    ffplay.exe udp://192.168.99.101:5555

    I see nothing...

    I am using docker toolbox for Windows, and VirtualBox VM. Any ideas?