Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • javaCV ffmpeg Android N Linker error

    8 février 2017, par B. Noble

    I'm hoping I can get some help on an issue I cannot seem to solve. I am trying to use javaCV FFmpegFrameGrabber to capture an RTSP stream. I have followed the instructions on configuring javaCV manually. I have ffmpeg.jar, javacv.jar, and javacpp.jar in the libs folder and the .so files in jniLibs/armeabi-v7a. I am using javaCV version 1.3.1.

    When I Run the application on a device running Android 5.0.1, it runs fine, but I've tried it on several devices running Android 7+ and I consistently get the error:

    E/linker: library "/system/lib/libdl.so" ("/system/lib/libdl.so") needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace:

    Any suggestions on how to get this working on Android 7+?

  • ffmpeg installation undefined reference to

    8 février 2017, par user1683302

    I used this official link to download ffmpeg and compile it. I know it creates a static library and I have to reference the library folder. When i try to compile this tutorial . i get this errors

    tutorial01.c: In function ‘main’:
    tutorial01.c:96:5: warning: ‘codec’ is deprecated [-Wdeprecated- declarations]
     if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
     ^
    In file included from tutorial01.c:27:0:
     /home/osboxes/ffmpeg_build/include/libavformat/avformat.h:893:21: note:  declared here
     AVCodecContext *codec;
                     ^
    tutorial01.c:104:3: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
    pCodecCtxOrig=pFormatCtx->streams[videoStream]->codec;
    ^
    In file included from tutorial01.c:27:0:
    /home/osboxes/ffmpeg_build/include/libavformat/avformat.h:893:21: note: declared here
     AVCodecContext *codec;
                     ^
    tutorial01.c:113:3: warning: ‘avcodec_copy_context’ is deprecated  [-Wdeprecated-declarations]
     if(avcodec_copy_context(pCodecCtx, pCodecCtxOrig) != 0) {
     ^
    In file included from tutorial01.c:26:0:
    /home/osboxes/ffmpeg_build/include/libavcodec/avcodec.h:4240:5: note: declared here
    int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
     ^
    tutorial01.c:131:3: warning: ‘avpicture_get_size’ is deprecated   [-Wdeprecated-declarations]
     numBytes=avpicture_get_size(AV_PIX_FMT_RGB24, pCodecCtx->width,
     ^
     In file included from tutorial01.c:26:0:
     /home/osboxes/ffmpeg_build/include/libavcodec/avcodec.h:5467:5: note: declared here
     int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
     ^
      tutorial01.c:138:3: warning: ‘avpicture_fill’ is deprecated [-Wdeprecated-declarations]
       avpicture_fill((AVPicture *)pFrameRGB, buffer, AV_PIX_FMT_RGB24,
       ^
      In file included from tutorial01.c:26:0:
      /home/osboxes/ffmpeg_build/include/libavcodec/avcodec.h:5452:5: note: declared here
      int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
     ^
       tutorial01.c:160:7: warning: ‘avcodec_decode_video2’ is deprecated [-Wdeprecated-declarations]
           avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
           ^
     In file included from tutorial01.c:26:0:
      /home/osboxes/ffmpeg_build/include/libavcodec/avcodec.h:4811:5: note: declared here
      int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
     ^
      tutorial01.c:177:5: warning: ‘av_free_packet’ is deprecated [-Wdeprecated-declarations]
      av_free_packet(&packet);
      ^
     In file included from tutorial01.c:26:0:
     /home/osboxes/ffmpeg_build/include/libavcodec/avcodec.h:4472:6: note: declared here
     void av_free_packet(AVPacket *pkt);
      ^
    /tmp/ccHYDd9j.o: In function `main':
    tutorial01.c:(.text+0x178): undefined reference to `av_register_all'
    tutorial01.c:(.text+0x19f): undefined reference to `avformat_open_input'
    tutorial01.c:(.text+0x1c1): undefined reference to `avformat_find_stream_info'
    tutorial01.c:(.text+0x1f6): undefined reference to `av_dump_format'
    tutorial01.c:(.text+0x2ab): undefined reference to `avcodec_find_decoder'
    tutorial01.c:(.text+0x2ea): undefined reference to `avcodec_alloc_context3'
    tutorial01.c:(.text+0x304): undefined reference to `avcodec_copy_context'
    tutorial01.c:(.text+0x348): undefined reference to `avcodec_open2'
    tutorial01.c:(.text+0x35b): undefined reference to `av_frame_alloc'
    tutorial01.c:(.text+0x367): undefined reference to `av_frame_alloc'
    tutorial01.c:(.text+0x3a4): undefined reference to `avpicture_get_size'
    tutorial01.c:(.text+0x3ba): undefined reference to `av_malloc'
    tutorial01.c:(.text+0x3ef): undefined reference to `avpicture_fill'
    tutorial01.c:(.text+0x439): undefined reference to `sws_getContext'
    tutorial01.c:(.text+0x47d): undefined reference to `avcodec_decode_video2'
    tutorial01.c:(.text+0x4de): undefined reference to `sws_scale'
    tutorial01.c:(.text+0x527): undefined reference to `av_free_packet'
    tutorial01.c:(.text+0x53d): undefined reference to `av_read_frame'
    tutorial01.c:(.text+0x551): undefined reference to `av_free'
    tutorial01.c:(.text+0x560): undefined reference to `av_frame_free'
    tutorial01.c:(.text+0x56f): undefined reference to `av_frame_free'
    tutorial01.c:(.text+0x57b): undefined reference to `avcodec_close'
    tutorial01.c:(.text+0x58a): undefined reference to `avcodec_close'
    tutorial01.c:(.text+0x599): undefined reference to `avformat_close_input'
    collect2: error: ld returned 1 exit status
    

    i used this sudo gcc -I /home/osboxes/ffmpeg_build/include -L /home/osboxes/ffmpeg_build/lib -lavcode -lavformat -lavutil -lswscale -lz -lm tutorial01.c

    my ffmpeg is

     ffmpeg version N-82113-g490c6bd Copyright (c) 2000-2016 the FFmpeg developers
       built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
       configuration: --prefix=/home/osboxes/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/osboxes/ffmpeg_build/include --extra-ldflags=- L/home/osboxes/ffmpeg_build/lib --bindir=/home/osboxes/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libopus --enable-libx264 --enable-nonfree
      libavutil      55. 33.100 / 55. 33.100
      libavcodec     57. 63.103 / 57. 63.103
      libavformat    57. 55.100 / 57. 55.100
      libavdevice    57.  0.103 / 57.  0.103
      libavfilter     6. 64.100 /  6. 64.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  2.100 /  2.  2.100
      libpostproc    54.  0.100 / 54.  0.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    

    the tutorial code was update to work on new ffmpeg versions.I'm using VM Ubuntu 16.0.4 64 bit fresh install on windows 10 host.

    so why I'm having all of these errors ?

    Update: I moved to Ubuntu 12.04 VM and ffmpeg 0.11, I instilled it with opencv 2.4.2 here is the link . This should work yet i don't why I'm having hard time compiling such small program.

    ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
     built on Oct 25 2016 13:39:37 with gcc 4.6.3
      configuration: --enable-gpl --enable-libfaac --enable-libmp3lame    --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared --enable-pic
     libavutil      51. 54.100 / 51. 54.100
     libavcodec     54. 23.100 / 54. 23.100
     libavformat    54.  6.100 / 54.  6.100
     libavdevice    54.  0.100 / 54.  0.100
     libavfilter     2. 77.100 /  2. 77.100
     libswscale      2.  1.100 /  2.  1.100
     libswresample   0. 15.100 /  0. 15.100
     libpostproc    52.  0.100 / 52.  0.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    

    yet i still have the problem but it is less sever

     gcc -o tutorial01 tutorial01.c -Wl,--start-group -lavcodec -lavformat  -lswscale -lavutil -lz -lm -Wl,--end-group     
      /tmp/ccnFfu84.o: In function `main':
      tutorial01.c:(.text+0x500): undefined reference to `avcodec_free_frame'
      tutorial01.c:(.text+0x511): undefined reference to `avcodec_free_frame'
      collect2: ld returned 1 exit status
    

    i tried this ldconfig -p | grep av

      libxklavier.so.16 (libc6,x86-64) => /usr/lib/libxklavier.so.16
      libwavpack.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux gnu/libwavpack.so.1
    libjavascriptcoregtk-3.0.so.0 (libc6,x86-64) => /usr/lib/libjavascriptcoregtk-3.0.so.0
    libdvdnavmini.so.4 (libc6,x86-64) => /usr/lib/libdvdnavmini.so.4
    libdvdnav.so.4 (libc6,x86-64) => /usr/lib/libdvdnav.so.4
    libavutil.so.51 (libc6,x86-64) => /usr/local/lib/libavutil.so.51
    libavutil.so.51 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavutil.so.51
    libavutil.so (libc6,x86-64) => /usr/local/lib/libavutil.so
    libavformat.so.54 (libc6,x86-64) => /usr/local/lib/libavformat.so.54
    libavformat.so.53 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavformat.so.53
    libavformat.so (libc6,x86-64) => /usr/local/lib/libavformat.so
    libavfilter.so.2 (libc6,x86-64) => /usr/local/lib/libavfilter.so.2
    libavfilter.so (libc6,x86-64) => /usr/local/lib/libavfilter.so
    libavdevice.so.54 (libc6,x86-64) => /usr/local/lib/libavdevice.so.54
    libavdevice.so (libc6,x86-64) => /usr/local/lib/libavdevice.so
    libavc1394.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavc1394.so.0
    libavcodec.so.54 (libc6,x86-64) => /usr/local/lib/libavcodec.so.54
    libavcodec.so.53 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavcodec.so.53
    libavcodec.so (libc6,x86-64) => /usr/local/lib/libavcodec.so
    libavahi-ui-gtk3.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-ui-gtk3.so.0
    libavahi-gobject.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-gobject.so.0
    libavahi-glib.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-glib.so.1
    libavahi-core.so.7 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-core.so.7
    libavahi-common.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-common.so.3
    libavahi-common.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-common.so
    libavahi-client.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-client.so.3
    libavahi-client.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libavahi-client.so
    

    Update2

    I changged avcodec_free_frame to av_free and the file complied

    Dranger code is old

    Update 3 i downloaded ffmpeg 1.0.10 which has the same library version that is the tutorial tested on. Everything complied without any problem now.

  • Non-RSA TLS1.2 Packet decryption

    7 février 2017, par Joseph Wahba

    I am trying to decrypt a pcap file. This pcap file contains a capture of an HLS encrypted video stream. The pcap contains TLSv1.2 packets.

    Below are some information from the pcap file

    Server Hello message Cipher Suite:

    TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384.

    EC Diffie-Hellman server Params: pubkey (1)

    The Certificate Status message:

    Signature Hash Algorithm Hash: SHA256

    Signature Hash Algorithm Signature: ECDSA

    Client Key Exchange Message

    EC Diffie-Hellman server Params: pubkey (2)

    I tried to follow this Wireshark SSL decryption tutorial. But it seems that it works only for RSA encryptions. I have been researching for a while and found this discussion. I am quoting an extract from this discussion:

    There is an important parameter to mind: decryption of a passively recorded session (with a copy of the server private key) works only if the key exchange was of type RSA or static DH; with "DHE" and "ECDHE" cipher suites, you won't be able to decrypt such a session, even with knowledge of the server private key. In that case, you will need either the negotiated "master secret", or to use the server private key to actively intercept the connection

    It's note worthy that I have the client private key. In my case, the client is FFmpeg video streamer (FFplay). I had a look also on the TLS v1.2 RFC.

    My question:

    Is it possible to do a decryption in this scenario ? If yes, what do I need to have to do so?

    Is the decryption done using the client's private key or using the pre_shared_master (i.e. Diffie-Hellman) ?

  • Where is moviepy getting the video fps from ?

    7 février 2017, par Gloin

    I am using the Python 3 moviepy module for video editing, and I have a few videos that are taken in slow motion. When imported into moviepy, they are massively sped up, and then sit on the last frame for the rest of their duration. Note that, the videos are supposed to be normal for the first couple and last couple of seconds, then slow in the middle.

    Unfortunately, I cannot provide the actual video for you to test with, but here is the relevant metadata (fetched with the command ffprobe -v quiet -print_format json -show_format -show_streams slo-mo_movie.mov)

    "r_frame_rate": "240/1",                               
    "avg_frame_rate": "1679400/39481",
    "time_base": "1/2400",
    

    For comparison, here is the equivalent metadata from a video taken, I think, from the same phone, but without slo-mo:

    "r_frame_rate": "30/1",
    "avg_frame_rate": "143160/4771",
    "time_base": "1/600",
    

    I can import the videos in to moviepy with clip = VideoFileClip("path/to/file.mp4"), and then for each run print(clip.fps). The first video prints 2400 (not a typo from me!), and the second 30.

    Here is the moviepy code (in moviepy/video/io/ffmpeg_reader.py) at line 293) that gets the fps:

    # Get the frame rate. Sometimes it's 'tbr', sometimes 'fps', sometimes
    # tbc, and sometimes tbc/2...
    # Current policy: Trust tbr first, then fps. If result is near from x*1000/1001
    # where x is 23,24,25,50, replace by x*1000/1001 (very common case for the fps).
    
    try:
        match = re.search("( [0-9]*.| )[0-9]* tbr", line)
        tbr = float(line[match.start():match.end()].split(' ')[1])
        result['video_fps'] = tbr
    
    except:
        match = re.search("( [0-9]*.| )[0-9]* fps", line)
        result['video_fps'] = float(line[match.start():match.end()].split(' ')[1])
    
    
    # It is known that a fps of 24 is often written as 24000/1001
    # but then ffmpeg nicely rounds it to 23.98, which we hate.
    coef = 1000.0/1001.0
    fps = result['video_fps']
    for x in [23,24,25,30,50]:
        if (fps!=x) and abs(fps - x*coef) < .01:
            result['video_fps'] = x*coef
    
    if check_duration:
        result['video_nframes'] = int(result['duration']*result['video_fps'])+1
        result['video_duration'] = result['duration']
    else:
        result['video_nframes'] = 1
        result['video_duration'] = None
    # We could have also recomputed the duration from the number
    # of frames, as follows:
    # >>> result['video_duration'] = result['video_nframes'] / result['video_fps']
    

    If I set the slo-mo video's fps using moviepy to 24, it outputs it the same (very fast, then still on the last frame), but if I set the slo-mo video's fps to 20, then it outputs it correctly.

    Obviously video players like VLC player and Quicktime can correctly work out what frame speed to play, but moviepy/ffmpeg fails. Moviepy/ffmpeg is getting the wrong fps from somewhere.

    So, how can I get moviepy to automatically output them as they are supposed to be without human trial and error like above?

  • FFMpeg Concatenation Filters : Stream specifier ':0' in filtergraph matches no streams

    7 février 2017, par Anthony Eden

    I am developing an application that relies heavily on FFMpeg to perform various transformations on audio files. I am currently testing my FFMpeg configuration on the command line.

    I am trying to concatenate multiple audio files which are in different formats (Primarily MP3, MP2 & WAV). I have been using the official TRAC documentation (https://trac.ffmpeg.org/wiki/How%20to%20concatenate%20(join%2C%20merge)%20media%20files#differentcodec) to help me with this and have created the following command:

    ffmpeg -i OHIn.wav -i OHOut.wav -filter_complex '[0:0] [1:0] concat=n=2:a=1 [a]' -map '[a]' output.wav
    

    However, when I run this on Mac OS X using version 2.0.1 of FFMpeg, I get the following error message:

    Stream specifier ':0' in filtergraph description [0:0] [1:0] concat=n=2:a=1 [a] matches no streams.
    

    Here is my full output from the terminal:

    ~/ffmpeg -i OHIn.wav -i OHOut.wav -filter_complex '[0:0] [1:0] concat=n=2:a=1 [a]' -map '[a]' output.wav
    
    ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers
      built on Aug 15 2013 10:56:46 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
      configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86_64 --enable-runtime-cpudetect
      libavutil      52. 38.100 / 52. 38.100
      libavcodec     55. 18.102 / 55. 18.102
      libavformat    55. 12.100 / 55. 12.100
      libavdevice    55.  3.100 / 55.  3.100
      libavfilter     3. 79.101 /  3. 79.101
      libswscale      2.  3.100 /  2.  3.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  3.100 / 52.  3.100
    Guessed Channel Layout for  Input Stream #0.0 : stereo
    Input #0, wav, from 'OHIn.wav':
      Duration: 00:00:06.71, bitrate: 1411 kb/s
        Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    Guessed Channel Layout for  Input Stream #1.0 : stereo
    Input #1, wav, from 'OHOut.wav':
      Duration: 00:00:07.19, bitrate: 1411 kb/s
        Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    Stream specifier ':0' in filtergraph description [0:0] [1:0] concat=n=2:a=1 [a] matches no streams.
    

    I do not understand why this does not work. FFMpeg shows that the streams 0:0 and 1:0 exist in the source files. The only other similar problems online have surrounded the use of the single quote in Windows, however testing of this confirm it does not apply to my Mac command line.

    Any help would be much appreciated.