Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (47)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • (Dés)Activation de fonctionnalités (plugins)

    18 février 2011, par

    Pour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
    SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
    Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
    MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...)

  • Les statuts des instances de mutualisation

    13 mars 2010, par

    Pour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
    Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...)

Sur d’autres sites (9237)

  • Android-FFmpeg adding subtitle to mp4 video does not work

    7 septembre 2022, par ebdaa app

    I am trying to add srt file to a mp4 video using android mobile-ffmpeg , the code works with no error but the generated video does not contain the subtitle

    


    here is the code :

    


     String cmd = "-i " + videoPath + " -vf subtitles=\"" + subtitlePath + ":force_style='Alignment=10,Fontsize=18'\" " + OutputVideoPath;
 FFmpeg.executeAsync(cmd, new ExecuteCallback() {
    @Override
    public void apply(final long executionId, final int returnCode) {
         if (returnCode == RETURN_CODE_SUCCESS) {
         } else {
             
         }
    }
 });


    


    here are the logs

    


    I/mobile-ffmpeg: ffmpeg version v4.4-dev-416
     Copyright (c) 2000-2020 the FFmpeg developers
I/mobile-ffmpeg:   built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)
      configuration: --cross-prefix=arm-linux-androideabi- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm/neon/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=armv7-a --cpu=armv7-a --cc=armv7a-linux-androideabi24-clang --cxx=armv7a-linux-androideabi24-clang++ --extra-libs='-L/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm/neon/cpu-features/lib -lndk_compat' --target-os=android --enable-neon --enable-asm --enable-inline-asm --build-suffix=_neon --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-mediacodec
I/mobile-ffmpeg:   libavutil      56. 55.100 / 56. 55.100
      libavcodec     58. 96.100 / 58. 96.100
I/mobile-ffmpeg:   libavformat    58. 48.100 / 58. 48.100
      libavdevice    58. 11.101 / 58. 11.101
      libavfilter     7. 87.100 /  7. 87.100
      libswscale      5.  8.100 /  5.  8.100
I/mobile-ffmpeg:   libswresample   3.  8.100 /  3.  8.100
I/mobile-ffmpeg: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Download/7b85de4d-6af2-4eea-be9d-0d13c7f7819f/001001.mp4':
      Metadata:
        major_brand     : 
I/mobile-ffmpeg: isom
        minor_version   : 
I/mobile-ffmpeg: 512
        compatible_brands: 
I/mobile-ffmpeg: isomiso2mp41
I/mobile-ffmpeg:     encoder         : 
    Lavf58.48.100
I/mobile-ffmpeg:   Duration: 
    00:00:29.60
    , start: 
I/mobile-ffmpeg: 0.000000
    , bitrate: 
    466 kb/s
I/mobile-ffmpeg:     Stream #0:0
    (und)
I/mobile-ffmpeg: : Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 640x480 [SAR 1:2 DAR 2:3], 336 kb/s
    , 
    5 fps, 
I/mobile-ffmpeg: 5 tbr, 
    10240 tbn, 
    5 tbc
I/mobile-ffmpeg:  (default)
I/mobile-ffmpeg:     Metadata:
          handler_name    : 
    VideoHandler
I/mobile-ffmpeg:     Stream #0:1
I/mobile-ffmpeg: (und)
    : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
     (default)
I/mobile-ffmpeg:     Metadata:
I/mobile-ffmpeg:       handler_name    : 
    SoundHandler
W/mobile-ffmpeg: Codec AVOption preset (Configuration preset) specified for output file #0 (/storage/emulated/0/Download/QuranYaser/7b85de4d-6af2-4eea-be9d-0d13c7f7819f/001001_sub.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
I/mobile-ffmpeg: Stream mapping:
I/mobile-ffmpeg:   Stream #0:0 -> #0:0
I/mobile-ffmpeg:  (mpeg4 (native) -> mpeg4 (native))
I/mobile-ffmpeg:   Stream #0:1 -> #0:1
     (aac (native) -> aac (native))
I/mobile-ffmpeg: Press [q] to stop, [?] for help
    frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
I/mobile-ffmpeg: [Parsed_subtitles_0 @ 0xf35ee820] Shaper: FriBidi 1.0.9 (SIMPLE)
I/mobile-ffmpeg: [Parsed_subtitles_0 @ 0xf35ee820] 
W/mobile-ffmpeg: [Parsed_subtitles_0 @ 0xf35ee820] No usable fontconfig configuration file found, using fallback.
    [Parsed_subtitles_0 @ 0xf35ee820] 
I/mobile-ffmpeg: [Parsed_subtitles_0 @ 0xf35ee820] Using font provider fontconfig
    [Parsed_subtitles_0 @ 0xf35ee820] 
W/mobile-ffmpeg: [graph 0 input from stream 0:0 @ 0xf35ee880] sws_param option is deprecated and ignored
I/mobile-ffmpeg: Output #0, mp4, to '/storage/emulated/0/Download/QuranYaser/7b85de4d-6af2-4eea-be9d-0d13c7f7819f/001001_sub.mp4':
I/mobile-ffmpeg:   Metadata:
        major_brand     : 
    isom
I/mobile-ffmpeg:     minor_version   : 
    512
I/mobile-ffmpeg:     compatible_brands: 
I/mobile-ffmpeg: isomiso2mp41
        encoder         : 
I/mobile-ffmpeg: Lavf58.48.100
        Stream #0:0
I/mobile-ffmpeg: (und)
    : Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 640x480 [SAR 1:2 DAR 2:3], q=2-31, 200 kb/s
    , 
I/mobile-ffmpeg: 5 fps, 
I/mobile-ffmpeg: 10240 tbn, 
    5 tbc
I/mobile-ffmpeg:  (default)
        Metadata:
I/mobile-ffmpeg:       handler_name    : 
    VideoHandler
          encoder         : 
I/mobile-ffmpeg: Lavc58.96.100 mpeg4
        Side data:
I/mobile-ffmpeg:       
    cpb: 
    bitrate max/min/avg: 0/0/200000 buffer size: 0 
    vbv_delay: N/A
I/mobile-ffmpeg:     Stream #0:1
    (und)
I/mobile-ffmpeg: : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
     (default)
        Metadata:
I/mobile-ffmpeg:       handler_name    : 
    SoundHandler
I/mobile-ffmpeg:       encoder         : 
    Lavc58.96.100 aac
I/mobile-ffmpeg: frame=   11 fps=0.0 q=2.0 size=       0kB time=00:00:03.59 bitrate=   0.1kbits/s speed=7.16x    
I/mobile-ffmpeg: frame=   30 fps= 30 q=2.0 size=     256kB time=00:00:07.47 bitrate= 280.5kbits/s speed=7.44x    
I/mobile-ffmpeg: frame=   50 fps= 33 q=2.0 size=     512kB time=00:00:11.54 bitrate= 363.5kbits/s speed=7.67x    
I/mobile-ffmpeg: frame=   71 fps= 35 q=2.0 size=     768kB time=00:00:15.71 bitrate= 400.2kbits/s speed=7.83x    
I/mobile-ffmpeg: frame=   92 fps= 37 q=2.0 size=    1024kB time=00:00:19.78 bitrate= 424.0kbits/s speed=7.88x    
I/mobile-ffmpeg: frame=  110 fps= 36 q=2.0 size=    1280kB time=00:00:23.38 bitrate= 448.5kbits/s speed=7.75x    
I/mobile-ffmpeg: frame=  128 fps= 36 q=2.0 size=    1280kB time=00:00:27.12 bitrate= 386.6kbits/s speed=7.71x    
I/mobile-ffmpeg: frame=  148 fps= 38 q=8.4 Lsize=    1697kB time=00:00:29.40 bitrate= 472.9kbits/s speed=7.56x    
    video:1225kB audio:462kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 
I/mobile-ffmpeg: 0.559634%
I/mobile-ffmpeg: [aac @ 0xbe48c800] Qavg: 163.999


    


    here is a sample of srt file I am trying to merge :

    


    1
00:00:00,000 --> 00:00:03,326
 Text 1

2
00:00:03,326 --> 00:00:09,962
 Text 2

3
00:00:09,962 --> 00:00:16,160
 Text 3

4
00:00:16,160 --> 00:00:22,223
 Text 4


    


    any idea why the generated video does not contain the subtitle ?

    


    Update

    


    Based on below comment , I changed my code to use the latest ffmpeg-kit version , here is the new code

    


    String cmd = "-i " + videoPath + " -vf subtitles=\"" + subtitlePAth + ":force_style='Alignment=10,Fontsize=18\" " + 
   outputVideoPath;

   FFmpegKit.executeAsync(cmd, new FFmpegSessionCompleteCallback() {

        @Override
        public void apply(FFmpegSession session) {

        }
    }, new LogCallback() {

        @Override
        public void apply(com.arthenica.ffmpegkit.Log log) {


        }
    }, new StatisticsCallback() {

        @Override
        public void apply(Statistics statistics) {              

        }
    });`


    


    and here is the updated log

    


      ffmpeg version v4.5-dev-3393-g30322ebe3c Copyright (c) 2000-2021 the FFmpeg developers
    built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
    configuration: --cross-prefix=arm-linux-androideabi- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/storage/light/projects/ffmpeg-kit/prebuilt/android-arm-neon/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=armv7-a --cpu=armv7-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --build-suffix=_neon --ar=arm-linux-androideabi-ar --cc=armv7a-linux-androideabi24-clang --cxx=armv7a-linux-androideabi24-clang++ --ranlib=arm-linux-androideabi-ranlib --strip=arm-linux-androideabi-strip --nm=arm-linux-androideabi-nm --extra-libs='-L/storage/light/projects/ffmpeg-kit/prebuilt/android-arm-neon/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libdav1d --enable-libkvazaar --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-libzimg --disable-openssl --enable-zlib --enable-mediacodec
    libavutil      57. 13.100 / 57. 13.100
    libavcodec     59. 15.102 / 59. 15.102
    libavformat    59. 10.100 / 59. 10.100
    libavdevice    59.  1.100 / 59.  1.100
    libavfilter     8. 21.100 /  8. 21.100
    libswscale      6.  1.102 /  6.  1.102
    libswresample   4.  0.100 /  4.  0.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Download/7b85de4d-6af2-4eea-be9d-0d13c7f7819f/001001.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.10.100
    Duration: 00:00:29.60, start: 0.000000, bitrate: 467 kb/s
    Stream #0:0[0x1](und): Video: mpeg4 (mp4v / 0x7634706D), yuv420p(tv, bt470bg/bt709/bt709), 640x480 [SAR 1:2 DAR 2:3], 336 kb/s, 5 fps, 5 tbr, 10240 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  [mpeg4 @ 0xbacc1080] The "sub_text_format" option is deprecated: Deprecated, does nothing
  [aac @ 0xbacc1400] The "sub_text_format" option is deprecated: Deprecated, does nothing
  Stream mapping:
    Stream #0:0 -> #0:0 (mpeg4 (native) -> mpeg4 (native))
    Stream #0:1 -> #0:1 (aac (native) -> aac (native))
  Press [q] to stop, [?] for help
  [Parsed_subtitles_0 @ 0xf35141e0] libass API version: 0x1502000[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] libass source: commit: 0.15.2-0-gc967a5a3d9ec0d36af1148b3fdf2f307a21dd122[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] Shaper: FriBidi 1.0.11 (SIMPLE) HarfBuzz-ng 3.2.0 (COMPLEX)[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] No usable fontconfig configuration file found, using fallback.[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] Using font provider fontconfig[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] fontselect: failed to find any fallback with glyph 0x0 for font: (Arial, 400, 0)[Parsed_subtitles_0 @ 0xf35141e0] 
  Output #0, mp4, to '/storage/emulated/0/Download/7b85de4d-6af2-4eea-be9d-0d13c7f7819f/001001_sub5.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.10.100
    Stream #0:0(und): Video: mpeg4 (mp4v / 0x7634706D), yuv420p(tv, bt470bg/bt709/bt709, progressive), 640x480 [SAR 1:2 DAR 2:3], q=2-31, 200 kb/s, 5 fps, 10240 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc59.15.102 mpeg4
      Side data:
        cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc59.15.102 aac
  frame=    1 fps=0.0 q=5.7 size=       0kB time=00:00:01.55 bitrate=   0.2kbits/s speed= 2.4x    
  frame=   10 fps=8.7 q=2.0 size=       0kB time=00:00:03.50 bitrate=   0.1kbits/s speed=3.04x    
  frame=   20 fps= 12 q=2.0 size=       0kB time=00:00:05.36 bitrate=   0.1kbits/s speed=3.24x    
  frame=   32 fps= 15 q=2.0 size=     256kB time=00:00:07.87 bitrate= 266.5kbits/s speed=3.65x    
  frame=   45 fps= 17 q=2.0 size=     256kB time=00:00:10.49 bitrate= 199.8kbits/s speed=3.95x    
  frame=   58 fps= 18 q=2.0 size=     512kB time=00:00:12.97 bitrate= 323.2kbits/s speed=4.11x    
  frame=   69 fps= 19 q=2.0 size=     768kB time=00:00:15.23 bitrate= 413.1kbits/s speed=4.16x    
  frame=   81 fps= 19 q=2.0 size=     768kB time=00:00:17.60 bitrate= 357.5kbits/s speed=4.23x    
  frame=   92 fps= 20 q=2.0 size=    1024kB time=00:00:19.85 bitrate= 422.6kbits/s speed=4.26x    
  frame=  102 fps= 20 q=2.0 size=    1024kB time=00:00:21.89 bitrate= 383.1kbits/s speed=4.24x    
  frame=  115 fps= 20 q=2.0 size=    1280kB time=00:00:24.40 bitrate= 429.7kbits/s speed=4.31x    
  frame=  126 fps= 20 q=2.0 size=    1280kB time=00:00:26.67 bitrate= 393.0kbits/s speed=4.32x    
  frame=  139 fps= 21 q=2.0 size=    1536kB time=00:00:29.28 bitrate= 429.8kbits/s speed=4.39x    
  frame=  148 fps= 22 q=8.4 Lsize=    1701kB time=00:00:29.40 bitrate= 473.9kbits/s speed=4.34x    
  video:1225kB audio:466kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.561835%
  [aac @ 0xbacc2200] Qavg: 482.514


    


  • FFMPEG command from Python 3.5 does not actually create audio file

    20 décembre 2017, par Nathan Blaine

    I have a Django web application that accepts user uploaded videos/audio and saves them into a folder ’../WebAppDirectory/media/recordings’.

    I am then using a speech to text API to get a rough transcription of the audio. This is working fine for .wav and .mp4 files, but the web app also accepts videos (.MOV) that I would like to first convert to .wav, then pass off to the API.

    Using ffmpeg from my command line like this

    ffmpeg -i C:\Users\Nathan\Desktop\MeetingRecorderWebAPP\media\recordings\upload_sample.MOV -ab 160k -ac 2 -ar 44100 -vn upload_sample.wav

    Correctly creates the .wav file from the original .MOV.

    However, when I run this from python with

    subprocess.check_call(command, shell=True)

    ffmpeg responds with

    File ’upload_sample.wav’ already exists. Overwrite ? [y/N]

    While Python tells me

    FileNotFoundError : [Errno 2] No such file or directory : ’C :\Users\Nathan\Desktop\MeetingRecorderWebAPP\media\recordings\upload_sample.wav’

    It is also worth noting that I do not see a ’upload_sample.wav’ file in the media/recordings/ directory.

    This leads me to believe that maybe Python and ffmpeg are looking in different folders, but I am not sure where I am going wrong. When I print the command from the subprocess.check_call and copy/paste it into cmd, the file is created as expected.

    Hoping someone with some experience with ffmpeg/Python subprocess can help shed some light ! Here are the files I am working with :

    Folder Structure

    DjangoWebApp
    |---media
    |---|---imgs
    |---|---recordings
    |---|---|---upload_sample.MOV
    |---uploaded_audio_to_text.py

    uploaded_audio_to_text.py

    import speech_recognition as sr
    from os import path
    import os
    import subprocess


    def speech_to_text(file_name):
       AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), 'media','recordings', file_name)
       print("Looking at path: ",AUDIO_FILE)
       # get extension
       AUDIO_FILE_EXT = os.path.splitext(AUDIO_FILE)[1]

       if(AUDIO_FILE_EXT == '.MOV'):
           print("File is not .wav: ", AUDIO_FILE_EXT, "found. Converting...")
           # We will use subprocess and ffmpeg to convert this .MOV file to .wav, so we can send to API
           temp_wav = os.path.splitext(file_name)[0] + '.wav'
           print("New audio file will be: ", temp_wav)
           # build CMD ffmpeg command
           command = "ffmpeg -i "
           command += AUDIO_FILE
           command += " -ab 160k -ac 2 -ar 44100 -vn "
           command += temp_wav

           print("Attempting to run this command: \n",command)
           print(subprocess.check_call(command, shell=True))
           print("Past Subprocess.call")
           AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), 'media','recordings', temp_wav)
           print("AUDIO_FILE now set to: ", AUDIO_FILE)

       else:
           # continue with what we are doing
           pass


       r = sr.Recognizer()
       with sr.AudioFile(AUDIO_FILE) as source:
           audio = r.record(source)  # read the entire audio file
           text_transcription = "Sentinel"
           # recognize speech using Microsoft Bing Voice Recognition
           BING_KEY = "MY_KEY_:)"
           try:
               text_transcription = r.recognize_bing(audio, key=BING_KEY)
           except sr.UnknownValueError:
               print("Microsoft Bing Voice Recognition could not understand audio")
           except sr.RequestError as e:
               print("Could not request results from Microsoft Bing Voice Recognition service; {0}".format(e))

       return text_transcription


    #my tests
    my_relative_file_path = "upload_sample.MOV"
    print(speech_to_text(my_relative_file_path))

    Console output (traceback and my print()’s)

    Looking at path:  C:\Users\Nathan\Desktop\MeetingRecorderWebAPP\media\recordings\upload_sample.MOV
    File is not .wav:  .MOV found. Converting...
    New audio file will be:  upload_sample.wav Attempting to run this command:
    ffmpeg -i C:\Users\Nathan\Desktop\MeetingRecorderWebAPP\media\recordings\upload_sample.MOV -ab 160k -ac 2 -ar 44100 -vn upload_sample.wav
    ffmpeg version git-2017-12-18-74f408c Copyright (c) 2000-2017 the FFmpeg developers   built with gcc 7.2.0 (GCC)  
    ----REMOVED SOME FFMPEG OUTPUT FOR BREVITY----
    File 'upload_sample.wav' already exists. Overwrite ? [y/N] y
    Stream mapping:   Stream #0:1 -> #0:0 (aac (native) -> pcm_s16le (native)) Press [q] to stop, [?] for help Output #0, wav, to 'upload_sample.wav':   Metadata:
       major_brand     : qt  
       minor_version   : 0
       compatible_brands: qt  
       com.apple.quicktime.creationdate: 2017-12-19T16:06:10-0500
       com.apple.quicktime.make: Apple
       com.apple.quicktime.model: iPhone 6
       com.apple.quicktime.software: 10.3.3
       ISFT            : Lavf58.3.100
       Stream #0:0(und): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s (default)
       Metadata:
         creation_time   : 2017-12-19T21:06:11.000000Z
         handler_name    : Core Media Data Handler
         encoder         : Lavc58.8.100 pcm_s16le size=    1036kB time=00:00:06.01 bitrate=1411.3kbits/s speed=N/A     video:0kB audio:1036kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.007352%
    0
    Traceback (most recent call last): Past Subprocess.call  
    File "C:\Users\Nathan\Desktop\MeetingRecorderWebAPP\uploaded_audio_to_text.py", line 53, in <module>
    AUDIO_FILE now set to:  C:\Users\Nathan\Desktop\MeetingRecorderWebAPP\media\recordings\upload_sample.wav
       print(speech_to_text(my_relative_file_path))  
    File "C:\Users\Nathan\Desktop\MeetingRecorderWebAPP\uploaded_audio_to_text.py", line 36, in speech_to_text
       with sr.AudioFile(AUDIO_FILE) as source:  
    File "C:\Users\Nathan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\speech_recognition\__init__.py", line 203, in __enter__
       self.audio_reader = wave.open(self.filename_or_fileobject, "rb")  
    File "C:\Users\Nathan\AppData\Local\Programs\Python\Python36-32\lib\wave.py", line 499, in open
       return Wave_read(f)  
    File "C:\Users\Nathan\AppData\Local\Programs\Python\Python36-32\lib\wave.py", line 159, in __init__
       f = builtins.open(f, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Nathan\\Desktop\\MeetingRecorderWebAPP\\media\\recordings\\upload_sample.wav'

    Process finished with exit code 1
    </module>
  • Php - Get video duration from a file hosted on amazon S3 server

    8 mai 2017, par Michael Lee

    I am developing back-end API with php to get the duration from a video file hosted on amazon S3. The API server is hosted on amazon EC2 and the video file is uploaded on amazon S3. The problem is when I request to API server, it has to response the information of the video file hosted on amazon S3 such as duration, file size, resolution etc. At least, it must response the video. I’ve followed codes by using ffmpeg such as below, but it’s not working.

    &lt;?php
    $file = 'https://videoapptest-bucket.s3.amazonaws.com/video/10/44__55_f03876434e48d5fed7d6982b0cf578de_u_00000.ts';
    $result = shell_exec('ffmpeg -i ' . escapeshellcmd($file) . ' 2>&amp;1');
    preg_match('/(?&lt;=Duration: )(\d{2}:\d{2}:\d{2})\.\d{2}/', $result, $match);
    print_r($match);
    ?>

    How can I get the video duration from a file hosted on amazon s3 with ffmpeg or another tool ?