Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Librosa.load File Not Found Error using Anaconda

    12 décembre 2017, par Jornam

    These two commands illustrate my problem perfectly. The file exists, but Librosa/Audioread reports a file not found error.

    >>> os.path.isfile('/var/scratch/jwessels/MGR/doc/experiments/Techno.mp3')
    True
    >>> librosa.load('/var/scratch/jwessels/MGR/doc/experiments/Techno.mp3')
    Traceback (most recent call last):
      File "", line 1, in 
      File "/var/scratch/jwessels/anaconda/lib/python2.7/site-packages/librosa/core/audio.py", line 107, in load
    with audioread.audio_open(os.path.realpath(path)) as input_file:
      File "/var/scratch/jwessels/anaconda/lib/python2.7/site-packages/audioread/__init__.py", line 109, in audio_open
    return ffdec.FFmpegAudioFile(path)
      File "/var/scratch/jwessels/anaconda/lib/python2.7/site-packages/audioread/ffdec.py", line 150, in __init__
    self._get_info()
      File "/var/scratch/jwessels/anaconda/lib/python2.7/site-packages/audioread/ffdec.py", line 206, in _get_info
    raise IOError('file not found')
    IOError: file not found
    

    I use Anaconda, python 2.7, and Audioread is powered by ffmpeg. I'm on a remote Linux server using SSH.

  • ffmpeg - is there a way to -map 0:m:language:eng if it exists, otherwise use the default ?

    12 décembre 2017, par momomo

    If a source has 'eng' as an audio track, use that, otherwise use the default or audio track zero?

    Is this possible?

    I have tried:

     -map 0:m:language:eng? -map 0:a:0?
    

    But that ends up always using the default one.

  • ffmpeg HLS live stream

    12 décembre 2017, par Chris Orfitelli

    I'm trying to create a HLS stream on a windows 10 box running ffmpeg with a blackmagic capture card as the input. I'm pretty new at this and trying to fiddle my way threw is driving me bananas.

    I'm having issues with my m3u8 file not working. I can play all my segmented .ts files just fine but the m3u8 file is a bit beyond me.

    ffmpeg -f dshow -video_size 1280x720 -framerate 59.94 -rtbufsize 702000k -i video="Decklink Video Capture" -threads 0 -map 0 -codec:v h264_nvenc -flags +cgop -g 1 -hls_time 5 -hls_wrap 6 c:\inetpub\wwwroot\out.m3u8 
    

    its creating a m3u8 file that looks like this

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:6
    #EXT-X-MEDIA-SEQUENCE:2
    #EXTINF:5.003333,out2.ts
    #EXTINF:4.986656,out3.ts
    #EXTINF:5.003333,out4.ts
    #EXTINF:5.003333,out5.ts
    #EXTINF:4.986656,out0.ts
    
  • cannot seek to frame 0 in opencv ?

    12 décembre 2017, par Wang

    For some video I cannot seek to frame <11 with cap.set(cv2.CAP_PROP_POS_FRAMES, x). Any x <11 will result in seek to frame 11th. any x<=0 will result in seek to frame 10th. Why does this happen? How can I fix this?

    def check_frame_seek(fname, frames, x, msec=False, seek=True):
        cap = cv2.VideoCapture(fname)
        _info = "start frame: {:d}; seek to {}".format(
            int(cap.get(cv2.CAP_PROP_POS_FRAMES)),
            x
        )
        if seek:
            if msec:
                _ret = cap.set(cv2.CAP_PROP_POS_MSEC, x)
                _info +="ms;"
            else:
                _ret = cap.set(cv2.CAP_PROP_POS_FRAMES, x)
                _info +="frame;"
            _info += "support seek?({});".format(_ret)
        _ret, framenow = cap.read()
    
        if _ret:
            for _i, _frame in enumerate(frames):
                if not _frame is None:
                    if (np.all(framenow == _frame)):
                        _info +="loaded=={}.".format(_i)
        else:
            _info += "cannot read."
        cap.release()
        print(_info)
    
    
    def load_all_frames(fname):
        cap = cv2.VideoCapture(fname)
        frames = []
        _ret, _frame = cap.read()
        while (_ret):
            print(
                "frame: {:d}".format(
                    int(cap.get(cv2.CAP_PROP_POS_FRAMES))
                )
            )
            frames.append(_frame)
            _ret, _frame = cap.read()
        print(
            "total frame number: {}; cap.get = {}".format(
                len(frames),
                cap.get(cv2.CAP_PROP_FRAME_COUNT)
            )
        )
        return frames
    
    def main():
        fname = "video"
        frames  = load_all_frames(fname)
    
        check_frame_seek(fname, frames, 0)
        check_frame_seek(fname, frames, -1)
        check_frame_seek(fname, frames, 49)
        check_frame_seek(fname, frames, 50)
        check_frame_seek(fname, frames, 51)
        check_frame_seek(fname, frames, 1)
        check_frame_seek(fname, frames, 10)
        check_frame_seek(fname, frames, 11)
        check_frame_seek(fname, frames, 12)
        check_frame_seek(fname, frames, 30)
    

    The out put is:

    total frame number: 50; cap.get = 49.0
    
    [h264 @ 0x55aabd321540] Missing reference picture
    [h264 @ 0x55aabd321540] decode_slice_header error
    [h264 @ 0x55aabd350120] Missing reference picture
    [h264 @ 0x55aabd3505e0] Missing reference picture
    [h264 @ 0x55aabd350aa0] reference picture missing during reorder
    [h264 @ 0x55aabd350aa0] reference picture missing during reorder
    [h264 @ 0x55aabd350aa0] reference picture missing during reorder
    [h264 @ 0x55aabd350aa0] Missing reference picture
    [h264 @ 0x55aabd350aa0] Missing reference picture
    [h264 @ 0x55aabd350aa0] Missing reference picture
    [h264 @ 0x55aabd321540] Missing reference picture
    [h264 @ 0x55aabd350120] mmco: unref short failure
    [h264 @ 0x55aabd350aa0] reference picture missing during reorder
    [h264 @ 0x55aabd350aa0] Missing reference picture
    start frame: 0; seek to 0frame;support seek?(True);loaded==10.
    start frame: 0; seek to -1frame;support seek?(True);loaded==10.
    start frame: 0; seek to 49frame;support seek?(True);loaded==49.
    start frame: 0; seek to 50frame;support seek?(True);loaded==49.
    start frame: 0; seek to 51frame;support seek?(True);loaded==49.
    start frame: 0; seek to 1frame;support seek?(True);loaded==11.
    start frame: 0; seek to 10frame;support seek?(True);loaded==11.
    start frame: 0; seek to 11frame;support seek?(True);loaded==11.
    start frame: 0; seek to 12frame;support seek?(True);loaded==12.
    start frame: 0; seek to 30frame;support seek?(True);loaded==30.
    

    The ffprobe result of the problematic videos:

    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 16:15 DAR 256:135], 50 fps, 50 tbr, 90k tbn, 100 tbc
    

    The ffmpeg:

    ffmpeg version 3.3.3 
    configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --disable-ffserver --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libtheora --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc --enable-libzimg
      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
    
  • Fluent-ffmpeg, node. Merge images and Background audio

    12 décembre 2017, par 0sserc

    I've been trying to create a video out of images and then add a background sound to the resulting video.

    First of all, and I might be doing this wrong on the first place. I create a video for each of the images and then I merge the 3 different videos into the final one.

      let proc = ffmpeg()
        .addInput(image.original)
        .loop(2)
        .fps(1)
        .noAudio()
        .on('start', function (command) {
          console.log('ffmpeg process started:', command)
        })
        .on('error', function(err) {
          console.log('an error happened: ' + err.message);
        })
        .on('end', function() {
          count ++;
          if(count == images.length){
            videosUrl.forEach(function(videoName){
              command = command.addInput(videoName);
            });
            command.addInput('audio.wav')
            command.inputFormat('wav')
            command.mergeToFile('merged.mp4')
            command.on('start', function (command) {
              console.log('ffmpeg process started:', command)
            })
            command.on('error', function(err) {
              console.log('Error ' + err.message);
            })
            command.on('end', function() {
              console.log('Finished!');
              future.return(count);
            });
          }
        })
        .save(url);
    

    If I comment out the audio thing I got the merged video correctly, but if I try to add the audio I get the following error.

    Error ffmpeg exited with code 1: Cannot find a matching stream for unlabeled input pad 3 on filter Parsed_concat_0
    

    Any help would be appreciated!