Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFmpeg, error hardcoding subtitles

    24 septembre 2019, par Ricardo

    I'm trying to use ffmpeg to hardcode subtitles, but it gives this error:

    No such filter: 'subtitles'
    Error opening filters!
    

    My ffmpeg command and complete console output:

    root@srv96:/home/Kawaii/web/mysite.com/public_html# ffmpeg -i input.mkv -vf subtitles=input.mkv output.mp4
    ffmpeg version 1.0.10 Copyright (c) 2000-2014 the FFmpeg developers
      built on Jul 25 2014 07:50:40 with gcc 4.7 (Debian 4.7.2-5)
      configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libfdk-aac --enable-libdc1394 --disable-altivec --dis  libavutil      51. 73.101 / 51. 73.101
      libavcodec     54. 59.100 / 54. 59.100
      libavformat    54. 29.104 / 54. 29.104
      libavdevice    54.  2.101 / 54.  2.101
      libavfilter     3. 17.100 /  3. 17.100
      libswscale      2.  1.101 /  2.  1.101
      libswresample   0. 15.100 /  0. 15.100
      libpostproc    52.  0.100 / 52.  0.100
    Input #0, matroska,webm, from 'input.mkv':
      Metadata:
        creation_time   : 2015-11-22 10:34:03
      Duration: 00:12:30.22, start: 0.000000, bitrate: 578 kb/s
        Stream #0:0: Video: h264 (High), yuv420p, 1280x720, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
        Metadata:
          BPS             : 524797
          BPS-eng         : 524797
          DURATION        : 00:12:30.083000000
          DURATION-eng    : 00:12:30.083000000
          NUMBER_OF_FRAMES: 17984
          NUMBER_OF_FRAMES-eng: 17984
          NUMBER_OF_BYTES : 49205170
          NUMBER_OF_BYTES-eng: 49205170
          _STATISTICS_WRITING_APP: mkvmerge v8.3.0 ('Over the Horizon') 64bit
          _STATISTICS_WRITING_APP-eng: mkvmerge v8.3.0 ('Over the Horizon') 64bit
          _STATISTICS_WRITING_DATE_UTC: 2015-11-22 10:34:03
          _STATISTICS_WRITING_DATE_UTC-eng: 2015-11-22 10:34:03
          _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
          _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
        Stream #0:1(jpn): Audio: aac, 48000 Hz, stereo, s16 (default)
        Metadata:
          BPS             : 52275
          BPS-eng         : 52275
          DURATION        : 00:12:30.209000000
          DURATION-eng    : 00:12:30.209000000
          NUMBER_OF_FRAMES: 17583
          NUMBER_OF_FRAMES-eng: 17583
          NUMBER_OF_BYTES : 4902222
          NUMBER_OF_BYTES-eng: 4902222
          _STATISTICS_WRITING_APP: mkvmerge v8.3.0 ('Over the Horizon') 64bit
          _STATISTICS_WRITING_APP-eng: mkvmerge v8.3.0 ('Over the Horizon') 64bit
          _STATISTICS_WRITING_DATE_UTC: 2015-11-22 10:34:03
          _STATISTICS_WRITING_DATE_UTC-eng: 2015-11-22 10:34:03
          _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
          _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
        Stream #0:2: Subtitle: ssa (default)
        Metadata:
          BPS             : 94
          BPS-eng         : 94
          DURATION        : 00:12:29.290000000
          DURATION-eng    : 00:12:29.290000000
          NUMBER_OF_FRAMES: 166
          NUMBER_OF_FRAMES-eng: 166
          NUMBER_OF_BYTES : 8841
          NUMBER_OF_BYTES-eng: 8841
          _STATISTICS_WRITING_APP: mkvmerge v8.3.0 ('Over the Horizon') 64bit
          _STATISTICS_WRITING_APP-eng: mkvmerge v8.3.0 ('Over the Horizon') 64bit
          _STATISTICS_WRITING_DATE_UTC: 2015-11-22 10:34:03
          _STATISTICS_WRITING_DATE_UTC-eng: 2015-11-22 10:34:03
          _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
          _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    [AVFilterGraph @ 0x6e4a60] No such filter: 'subtitles'
    Error opening filters!
    root@srv96:/home/Kawaii/web/mysite.com/public_html#
    

    Am using debian 7.

  • FFmpeg check channels of a 7.1 audio for silence

    24 septembre 2019, par Tina J

    This is a follow-up question from my previous question asked here, where I needed to look for silence within a specific audio track. Here is the ffmpeg life-saver solution where helps to get some metadata:

    ffmpeg -i file -map 0:a:1 -af astats -f null -
    

    But I have other type of input .mp4 files where they have one single track of 8 (i.e. 7.1) audio channels. Apparently these files are transcoded from an original file (somehow the 4 track stereos are squished into these files). Now similar to my previous, I need to know if the original file was 2-channel stereo or 5.1 (6) channel.

    How to know if a specific channel of an audio track (say Center channel) is silent/mute, possibly using ffmpeg? Here is a sample .mp4 file.

  • Recording video report for protractor execution on a remote environment

    23 septembre 2019, par Debasish Mukherjee

    I am executing my protractor test suite from my desktop and I am using a remote selenium server. I have configured the 'protractor-video-reporter' to capture execution for my local windows environment (using ffmpeg codec) and when I execute using my local selenium server, the video capture works fine. But when I execute on remote VMs, it captures my desktop screen. I understand that I need to provide the remote location path to ffmpeg codec, but I do not know how to provide appropriate user credentials so that my automation can invoke the remote plugin? My present configuration is as follows:

    const VideoReporter = require('protractor-video-reporter');
    ...
    let config = {
    ...
     onPrepare: () => {
     ...
     VideoReporter.prototype.jasmineStarted = function () {
    			var self = this;
    			if (self.options.singleVideo) {
    				var videoPath = path.join(self.options.baseDirectory, 'protractor-specs.mpg');
    				self._startScreencast(videoPath);
    				if (self.options.createSubtitles) {
    					self._subtitles = [];
    					self._jasmineStartTime = new Date();
    				}
    			}
    	};
     ...
     jasmine.getEnv().addReporter(new VideoReporter({
    	baseDirectory: './test-output/videoreport',
    	createSubtitles: false,
    	saveSuccessVideos: true,
    	singleVideo: true,
    	ffmpegCmd: "C:/FFmpeg/bin/ffmpeg.exe", /*Probably some changes needed here*/
    	ffmpegArgs: [
    				'-f', 'gdigrab',
    				'-framerate', '30',
    				'-video_size', 'wsxga',
    				'-i', 'desktop',
    				'-q:v', '10',
    	]
    }));
     ...
      }
      ...
    }
    export { config };

    Considering that execution and video capture both has to happen in remote server, please suggest a suitable solution.

  • What's the best way to get video metadata from a MP4 file in ASP.Net MVC using C# ?

    23 septembre 2019, par Maddhacker24

    I've been searching on Google and StackOverflow for a good couple of hours. There seems to be a lot of similar questions on StackOverflow but they are all about 3-5 years old.

    Is using FFMPEG still the best way these days to pull metadata from a video file in a .NET web application? And if so, what's the best C# wrapper out there?

    I've tried MediaToolkit, MediaFile.dll without any luck. I saw ffmpeg-csharpe but that looks like it hasn't been touched in a few years.

    I haven't found any current data on this subject. Is the ability to pull metadata from a video built into the latest version of .NET now?

    I'm basically looking for any direction at this point.

    I should add that whatever I use could be invoked thousands of times per hour so it will need to be efficient.

  • pydub.exceptions.CouldntDecodeError : Decoding failed. ffmpeg returned error code : 1

    23 septembre 2019, par azail765

    This script will work on a 30 second wav file but not a 10 minutes phone call also in wav format. Any help would be appreciated

    I've downloaded ffmpeg.

    # Import necessary libraries 
    from pydub import AudioSegment 
    import speech_recognition as sr 
    import os
    import pydub
    
    
    chunk_count = 0
    directory = os.fsencode(r'C:\Users\zach.blair\Downloads\speechRecognition\New folder')
    # Text file to write the recognized audio 
    fh = open("recognized.txt", "w+")
    for file in os.listdir(directory):
         filename = os.fsdecode(file)
         if filename.endswith(".wav"):
            chunk_count += 1
                 # Input audio file to be sliced 
            audio = AudioSegment.from_file(filename,format="wav") 
    
            ''' 
            Step #1 - Slicing the audio file into smaller chunks. 
            '''
            # Length of the audiofile in milliseconds 
            n = len(audio) 
    
            # Variable to count the number of sliced chunks 
            counter = 1
    
    
    
            # Interval length at which to slice the audio file. 
            interval = 20 * 1000
    
            # Length of audio to overlap.  
            overlap = 1 * 1000
    
            # Initialize start and end seconds to 0 
            start = 0
            end = 0
    
            # Flag to keep track of end of file. 
            # When audio reaches its end, flag is set to 1 and we break 
            flag = 0
    
            # Iterate from 0 to end of the file, 
            # with increment = interval 
            for i in range(0, 2 * n, interval): 
    
                # During first iteration, 
                # start is 0, end is the interval 
                if i == 0: 
                    start = 0
                    end = interval 
    
                # All other iterations, 
                # start is the previous end - overlap 
                # end becomes end + interval 
                else: 
                    start = end - overlap 
                    end = start + interval  
    
                # When end becomes greater than the file length, 
                # end is set to the file length 
                # flag is set to 1 to indicate break. 
                if end >= n: 
                    end = n 
                    flag = 1
    
                # Storing audio file from the defined start to end 
                chunk = audio[start:end] 
    
                # Filename / Path to store the sliced audio 
                filename = str(chunk_count)+'chunk'+str(counter)+'.wav'
    
                # Store the sliced audio file to the defined path 
                chunk.export(filename, format ="wav") 
                # Print information about the current chunk 
                print(str(chunk_count)+str(counter)+". Start = "
                                    +str(start)+" end = "+str(end)) 
    
                # Increment counter for the next chunk 
                counter = counter + 1
    
    
                AUDIO_FILE = filename 
    
                # Initialize the recognizer 
                r = sr.Recognizer() 
    
                # Traverse the audio file and listen to the audio 
                with sr.AudioFile(AUDIO_FILE) as source: 
                    audio_listened = r.listen(source) 
    
                # Try to recognize the listened audio 
                # And catch expections. 
                try:     
                    rec = r.recognize_google(audio_listened) 
    
                    # If recognized, write into the file. 
                    fh.write(rec+" ") 
    
                # If google could not understand the audio 
                except sr.UnknownValueError: 
                        print("Empty Value") 
    
                # If the results cannot be requested from Google. 
                # Probably an internet connection error. 
                except sr.RequestError as e: 
                    print("Could not request results.") 
    
                # Check for flag. 
                # If flag is 1, end of the whole audio reached. 
                # Close the file and break.                  
    fh.close()    
    

    Traceback (most recent call last): File "C:\Users\zach.blair\Downloads\speechRecognition\New folder\speechRecognition3.py", line 17, in audio = AudioSegment.from_file(filename,format="wav") File "C:\Users\zach.blair\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\audio_segment.py", line 704, in from_file p.returncode, p_err)) pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1

    Output from ffmpeg/avlib:

    b"ffmpeg version N-95027-g8c90bb8ebb Copyright (c) 2000-2019 the FFmpeg developers\r\n built with gcc 9.2.1 (GCC) 20190918\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf\r\n libavutil 56. 35.100 / 56. 35.100\r\n libavcodec 58. 58.101 / 58. 58.101\r\n libavformat 58. 33.100 / 58. 33.100\r\n libavdevice 58. 9.100 / 58. 9.100\r\n libavfilter 7. 58.102 / 7. 58.102\r\n libswscale 5. 6.100 / 5. 6.100\r\n libswresample 3. 6.100 / 3. 6.100\r\n libpostproc 55. 6.100 / 55. 6.100\r\nGuessed Channel Layout for Input Stream #0.0 : mono\r\nInput #0, wav, from '2a.wav.wav':\r\n Duration: 00:09:52.95, bitrate: 64 kb/s\r\n Stream #0:0: Audio: pcm_mulaw ([7][0][0][0] / 0x0007), 8000 Hz, mono, s16, 64 kb/s\r\nStream mapping:\r\n Stream #0:0 -> #0:0 (pcm_mulaw (native) -> pcm_s8 (native))\r\nPress [q] to stop, [?] for help\r\n[wav @ 0000024307974400] pcm_s8 codec not supported in WAVE format\r\nCould not write header for output file #0 (incorrect codec parameters ?): Function not implemented\r\nError initializing output stream 0:0 -- \r\nConversion failed!\r\n"