Recherche avancée

Médias (1)

Mot : - Tags -/flac

Sur d’autres sites (114)

  • Inserting image to video as a watermark using FFMPEG on Android phone

    4 octobre 2018, par Deepak Prasad

    I was trying to add an image to video as a watermark on android phone.
    I am using below command.

    String [] complexCommand = {"ffmpeg","-i","/storage/emulated/0/Vd/sample.mp4","-i",
                       "/storage/emulated/0/Vd/icon.png","-filter_complex","overlay=10:main_h-overlay_h-10","/storage/emulated/0/Vd/out.mp4"};

    But it’s giving me the error.

    D/FFmpeg: Failed 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-android/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/Vd/sample.mp4':
         Metadata:
           major_brand     : isom
           minor_version   : 512
           compatible_brands: isomiso2avc1mp41
           creation_time   : 1970-01-01 00:00:00
           encoder         : Lavf53.24.2
         Duration: 00:00:05.31, start: 0.000000, bitrate: 1589 kb/s
           Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1205 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
           Metadata:
             creation_time   : 1970-01-01 00:00:00
             handler_name    : VideoHandler
           Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 384 kb/s (default)
           Metadata:
             creation_time   : 1970-01-01 00:00:00
             handler_name    : SoundHandler
       Input #1, png_pipe, from '/storage/emulated/0/Vd/icon.png':
         Duration: N/A, bitrate: N/A
           Stream #1:0: Video: png, rgba(pc), 96x96 [SAR 3779:3779 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
       [NULL @ 0x42303a60] Unable to find a suitable output format for 'ffmpeg'
       ffmpeg: Invalid argument

    Both the source video and source image, I have stored on the android phone under some path. And I am using that complete path.

    Thanks.

  • ffmpeg : Combine/merge multiple mp4 videos not working, output only contains the first video

    17 août 2021, par dtbaker

    Here is the command I am using to combine multiple videos :

    



    ffmpeg -i 75_540_38HQ2.mp4 -i 76_70_20.mp4 -i 76_173_80.mp4 -i 81_186_35.mp4 -vcodec copy -acodec copy Mux1.mp4

    



    The resulting Mux1.mp4 does not contain all videos. Only the first video (75_540_38HQ2.mp4). The file size of the source and resulting video is below (as you can see, resulting video is slightly larger than first vid) :

    



    
$ ls -lh
-rw-r—r— 1 dbaker dbaker  42M 2011-03-24 11:59 75_540_38HQ2.mp4
-rw-r—r— 1 dbaker dbaker 236M 2011-03-24 12:09 76_173_80.mp4
-rw-r—r— 1 dbaker dbaker  26M 2011-03-24 12:05 76_70_20.mp4
-rw-r—r— 1 dbaker dbaker  54M 2011-03-24 12:15 81_186_35.mp4
-rw-r—r— 1 dbaker dbaker  44M 2011-03-24 14:48 Mux1.mp4


    



    Here is the output of the ffmpeg command. To me it looks ok, showing the multiple source inputs and the single output.

    



    
FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
  built on Mar 21 2011 18:05:32 with gcc 4.4.5
  configuration : —enable-gpl —enable-version3 —enable-nonfree —enable-postproc —enable-libfaac —enable-libmp3lame —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libtheora —enable-libvorbis —enable-libvpx —enable-libx264 —enable-libxvid —enable-x11grab
  libavutil     50.36. 0 / 50.36. 0
  libavcore      0.16. 1 /  0.16. 1
  libavcodec    52.108. 0 / 52.108. 0
  libavformat   52.93. 0 / 52.93. 0
  libavdevice   52. 2. 3 / 52. 2. 3
  libavfilter    1.74. 0 /  1.74. 0
  libswscale     0.12. 0 /  0.12. 0
  libpostproc   51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '75_540_38HQ2.mp4' :
  Metadata :
    major_brand : isom
    minor_version : 512
    compatible_brands : isomiso2avc1mp41
    creation_time : 1970-01-01 00:00:00
    encoder : Lavf52.93.0
  Duration : 00:00:29.99, start : 0.000000, bitrate : 11517 kb/s
    Stream #0.0(eng) : Video : h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 11575 kb/s, 29.94 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata :
      creation_time : 1970-01-01 00:00:00
    Stream #0.1(eng) : Audio : aac, 48000 Hz, stereo, s16, 127 kb/s
    Metadata :
      creation_time : 1970-01-01 00:00:00
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '76_70_20.mp4' :
  Metadata :
    major_brand : isom
    minor_version : 512
    compatible_brands : isomiso2avc1mp41
    creation_time : 1970-01-01 00:00:00
    encoder : Lavf52.93.0
  Duration : 00:00:19.98, start : 0.000000, bitrate : 10901 kb/s
    Stream #1.0(eng) : Video : h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 10804 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata :
      creation_time : 1970-01-01 00:00:00
    Stream #1.1(eng) : Audio : aac, 48000 Hz, stereo, s16, 128 kb/s
    Metadata :
      creation_time : 1970-01-01 00:00:00
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '76_173_80.mp4' :
  Metadata :
    major_brand : isom
    minor_version : 512
    compatible_brands : isomiso2avc1mp41
    creation_time : 1970-01-01 00:00:00
    encoder : Lavf52.93.0
  Duration : 00:03:09.99, start : 0.000000, bitrate : 10393 kb/s
    Stream #2.0(eng) : Video : h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 10321 kb/s, 29.96 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata :
      creation_time : 1970-01-01 00:00:00
    Stream #2.1(eng) : Audio : aac, 48000 Hz, stereo, s16, 128 kb/s
    Metadata :
      creation_time : 1970-01-01 00:00:00

Seems stream 0 codec frame rate differs from container frame rate : 119.88 (120000/1001) -> 30000.00 (30000/1)
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '81_186_35.mp4' :
  Metadata :
    major_brand : isom
    minor_version : 512
    compatible_brands : isomiso2avc1mp41
    creation_time : 1970-01-01 00:00:00
    encoder : Lavf52.93.0
  Duration : 00:00:35.00, start : 0.000000, bitrate : 12700 kb/s
    Stream #3.0(eng) : Video : h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 12620 kb/s, 59.91 fps, 30k tbr, 60k tbn, 119.88 tbc
    Metadata :
      creation_time : 1970-01-01 00:00:00
    Stream #3.1(eng) : Audio : aac, 48000 Hz, stereo, s16, 128 kb/s
    Metadata :
      creation_time : 1970-01-01 00:00:00
Output #0, mp4, to 'Mux1.mp4' :
  Metadata :
    major_brand : isom
    minor_version : 512
    compatible_brands : isomiso2avc1mp41
    creation_time : 1970-01-01 00:00:00
    encoder : Lavf52.93.0
    Stream #0.0(eng) : Video : libx264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], q=2-31, 11575 kb/s, 30k tbn, 29.97 tbc
    Metadata :
      creation_time : 1970-01-01 00:00:00
    Stream #0.1(eng) : Audio : libfaac, 48000 Hz, stereo, 128 kb/s
    Metadata :
      creation_time : 1970-01-01 00:00:00
Stream mapping :
  Stream #0.0 -> #0.0
  Stream #2.1 -> #0.1
Press [q] to stop encoding
frame=  883 fps=632 q=-1.0 Lsize=   44730kB time=29.40 bitrate=12465.1kbits/s    
video:41678kB audio:2969kB global headers:0kB muxing overhead 0.184548%


    



    Am I doing something blindingly stupid here ?

    



    The source videos came from a video camera, and are small snippets taken with ffmpeg -i bigfile.mp4 -ss 20 -t 10 -vcodec copy etc..

    



    Thanks heaps !!
Dave

    




    



    Edit : couldn't solve it so I just use avidemux GUI tool. It seemed to append the MP4's just fine.

    



    Must be a problem with MP4's or just the ones that come off a gopro camera.

    


  • Having trouble obtaining the time from RTP Timestamps obtained through OpenCV

    24 août 2019, par Fr0sty

    I am finding it a bit difficult trying to understand whether or not the hack around with FFmpeg and OpenCV really provided a RTP timestamp. My last post helped a little bit but got me stuck in trying to validate the timestamps obtained through this work around by modifying ffmpeg and opencv.

    FFmpeg version : 4.1.0
    OpenCV version : 3.4.1

    import cv2
    import time
    from datetime import datetime, date

    uri = 'rtsp://admin:password@192.168.1.66:554/Streaming/Channels/101'
    cap = cv2.VideoCapture(uri)
    '''One is the offset between the two epochs. Unix uses an epoch located at 1/1/1970-00:00h (UTC) and NTP uses 1/1/1900-00:00h.
    This leads to an offset equivalent to 70 years in seconds (there are 17 leap years between the two dates so the offset is'''
    time_offset = 2208988800 # (70*365 + 17)*86400 = 2208988800 (in seconds)
    # offset = 3775484294
    days = 43697
    pdat = "1900-01-01 00:00:00:00"
    mdat = "2019-08-23 22:02:44:00" # str(datetime.now()) + str(datetime.now().time())
    pdate = datetime.strptime(pdat, "%Y-%m-%d %H:%M:%S:%f").date()
    mdate = datetime.strptime(mdat, "%Y-%m-%d %H:%M:%S:%f").date()
    delta = (mdate - pdate).days
    offset = delta * 86400
    def time_delta(s):
       return (s - time_offset)

    while True:
       frame_exists, curr_frame = cap.read()
       if frame_exists:
           seconds = cap.getRTPTimeStampSeconds()
           fraction = cap.getRTPTimeStampFraction()
           timestamp = cap.getRTPTimeStampTs()
           unix_offset = seconds - time_offset
           msec = int((int(fraction) / 0xFFFFFFFF) * 1000.0)
           ts = float(str(unix_offset) + "." + str(msec))
           # print("Timestamp per Frame:%i" % timestamp)
           print((datetime.fromtimestamp(float(ts) + offset)))
    cap.release()

    My Output :

    On August 23, 2019 at 22:02

    ...
    2019-08-23 13:59:52.781000
    2019-08-23 13:59:52.726000
    2019-08-23 13:59:52.671000
    2019-08-23 13:59:52.616000
    2019-08-23 13:59:52.561000
    2019-08-23 13:59:52.506000
    2019-08-23 13:59:52.451000
    2019-08-23 13:59:52.396000
    2019-08-23 13:59:52.342000
    2019-08-23 13:59:52.287000
    2019-08-23 13:59:52.232000
    2019-08-23 13:59:52.177000
    2019-08-23 13:59:52.122000
    2019-08-23 13:59:52.067000
    2019-08-23 13:59:52.012000
    2019-08-23 13:59:53.570000
    2019-08-23 13:59:53.020000
    2019-08-23 13:59:53.847000
    2019-08-23 13:59:53.792000

    I’ve noticed how the time increments weirdly (that’s not suppose to happen in the real, current time), such as the last two lines and a few others in between in the output. A bit flabbergasted as to what went wrong. Also trying this out on multiple IP cameras, with each showing a different timestamp probably related to when they were turned on.