Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • PyQt6 6.7.0 - How to fix error : No QtMultimedia backends found

    4 février, par Belleroph0N

    Problem on Windows 10 and Windows 11 using Anaconda.

    Here is the full error message for PyQt6=6.7.0:

    No QtMultimedia backends found. Only QMediaDevices, QAudioDevice, QSoundEffect, QAudioSink, and QAudioSource are available.
    Failed to initialize QMediaPlayer "Not available"
    Failed to create QVideoSink "Not available"
    

    Installed PyQt6 using a requirements file:

    PyQt6
    PyQt6-WebEngine
    requests
    pyserial
    pynput
    

    Here are a couple things I tried:

    1. Reroll version back to PyQt6=6.6.1. This results in an error as well: ImportError: DLL load failed while importing QtGui: The specified procedure could not be found.
    2. I thought that missing ffmpeg might be the issue so I installed it, but the issue persists.
    3. Tried the setup on Ubuntu (WSL2) and the issue disappears, but there is just a black screen and nothing gets displayed in the widget. (EDIT: Got this up and running, the problem was with differences in file paths in linux vs windows.)

    I am new to PyQt so any pointers will be helpful!

    Edit: Here is generic code (taken from here) that gives the same error:

    from PyQt6.QtGui import QIcon, QFont
    from PyQt6.QtCore import QDir, Qt, QUrl, QSize
    from PyQt6.QtMultimedia import QMediaPlayer
    from PyQt6.QtMultimediaWidgets import QVideoWidget
    from PyQt6.QtWidgets import (QApplication, QFileDialog, QHBoxLayout, QLabel, QStyleFactory,
            QPushButton, QSizePolicy, QSlider, QStyle, QVBoxLayout, QWidget, QStatusBar)
    
    
    class VideoPlayer(QWidget):
    
        def __init__(self, parent=None):
            super(VideoPlayer, self).__init__(parent)
    
            self.mediaPlayer = QMediaPlayer()
    
            btnSize = QSize(16, 16)
            videoWidget = QVideoWidget()
    
            openButton = QPushButton("Open Video")   
            openButton.setToolTip("Open Video File")
            openButton.setStatusTip("Open Video File")
            openButton.setFixedHeight(24)
            openButton.setIconSize(btnSize)
            openButton.setFont(QFont("Noto Sans", 8))
            openButton.setIcon(QIcon.fromTheme("document-open", QIcon("D:/_Qt/img/open.png")))
            openButton.clicked.connect(self.abrir)
    
            self.playButton = QPushButton()
            self.playButton.setEnabled(False)
            self.playButton.setFixedHeight(24)
            self.playButton.setIconSize(btnSize)
            self.playButton.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPlay))
            self.playButton.clicked.connect(self.play)
    
            self.positionSlider = QSlider(Qt.Orientation.Horizontal)
            self.positionSlider.setRange(0, 0)
            self.positionSlider.sliderMoved.connect(self.setPosition)
    
            self.statusBar = QStatusBar()
            self.statusBar.setFont(QFont("Noto Sans", 7))
            self.statusBar.setFixedHeight(14)
    
            controlLayout = QHBoxLayout()
            controlLayout.setContentsMargins(0, 0, 0, 0)
            controlLayout.addWidget(openButton)
            controlLayout.addWidget(self.playButton)
            controlLayout.addWidget(self.positionSlider)
    
            layout = QVBoxLayout()
            layout.addWidget(videoWidget)
            layout.addLayout(controlLayout)
            layout.addWidget(self.statusBar)
    
            self.setLayout(layout)
    
            #help(self.mediaPlayer)
            self.mediaPlayer.setVideoOutput(videoWidget)
            self.mediaPlayer.playbackStateChanged.connect(self.mediaStateChanged)
            self.mediaPlayer.positionChanged.connect(self.positionChanged)
            self.mediaPlayer.durationChanged.connect(self.durationChanged)
            self.mediaPlayer.errorChanged.connect(self.handleError)
            self.statusBar.showMessage("Ready")
    
        def abrir(self):
            fileName, _ = QFileDialog.getOpenFileName(self, "Select Media",
                    ".", "Video Files (*.mp4 *.flv *.ts *.mts *.avi)")
    
            if fileName != '':
                self.mediaPlayer.setSource(QUrl.fromLocalFile(fileName))
                self.playButton.setEnabled(True)
                self.statusBar.showMessage(fileName)
                self.play()
    
        def play(self):
            if self.mediaPlayer.playbackState() == QMediaPlayer.PlaybackState.PlayingState:
                self.mediaPlayer.pause()
            else:
                self.mediaPlayer.play()
    
        def mediaStateChanged(self, state):
            if self.mediaPlayer.playbackState() == QMediaPlayer.PlaybackState.PlayingState:
                self.playButton.setIcon(
                        self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPause))
            else:
                self.playButton.setIcon(
                        self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPlay))
    
        def positionChanged(self, position):
            self.positionSlider.setValue(position)
    
        def durationChanged(self, duration):
            self.positionSlider.setRange(0, duration)
    
        def setPosition(self, position):
            self.mediaPlayer.setPosition(position)
    
        def handleError(self):
            self.playButton.setEnabled(False)
            self.statusBar.showMessage("Error: " + self.mediaPlayer.errorString())
    
    if __name__ == '__main__':
        import sys
        app = QApplication(sys.argv)
        player = VideoPlayer()
        player.setWindowTitle("Player")
        player.resize(900, 600)
        player.show()
        sys.exit(app.exec())
    

    The videos I want to play are in the same folder as this .py file. The conda env (python 3.9.2) I am working on has the following packages:

    certifi                     2024.6.2
    charset-normalizer          3.3.2
    idna                        3.7
    pip                         24.0
    pynput                      1.7.6
    PyQt6                       6.7.0
    PyQt6-Qt6                   6.7.1
    PyQt6-sip                   13.6.0
    PyQt6-WebEngine             6.7.0
    PyQt6-WebEngine-Qt6         6.7.1
    PyQt6-WebEngineSubwheel-Qt6 6.7.1
    pyserial                    3.5
    requests                    2.31.0
    setuptools                  69.5.1
    six                         1.16.0
    urllib3                     2.2.1
    wheel                       0.43.0
    

    PS: MacOS seems to have the same issue.

  • Comparing the video/audio output of ffmpeg commands between versions to test for regessions

    4 février, par lavantgarde

    Our software uses ffmpeg to do various video/audio encoding (e.g. changing volume, re-encoding to a different video format (e.g. yuv420p), scaling, etc.)

    Every few months we upgrade ffmpeg versions, and we've found that sometimes parameters change and regressions are introduced.

    What ffmpeg tools could we use to create unit tests to validate certain commands for regressions?

    I believe checking hashes won't be enough; doing visual inspections manually is also something we'd like to avoid to automate.

    Here's an example pseudocode:

    var ffmpegV1 = "C:\ffmpegv1.exe";
    var ffmpegV2 = "C:\ffmpegv2.exe";
    
    var inputVideo = "C:\video.mp4";
    
    var outputVideoV1 = "C:\OutputV1.mp4";
    var outputVideoV2 = "C:\OutputV2.mp4";
    
    
    ffmpegV1.Encode($"-y -i {inputVideo} -ar 22050 -ab 64k -ac 1 -s 120x40 -crf 30 -g 150 OutputV1.mp4");
    
    
    ffmpegV1.Encode($"-y -i {inputVideo} -ar 22050 -ab 64k -ac 1 -s 120x40 -crf 30 -g 150 OutputV2.mp4");
    
    
    
    // This is where I want to figure out how I can programmatically determine that the videos are the same, or within some tolerance of difference, e.g.
    
    bool isAudioTheSame = FfmpegTest.CompareAudio(outputVideoV1, outputVideoV2, Epsilon.Tolerance);
    
    bool isVideoTheSame = FfmpegTest.CompareVideo(outputVideoV1, outputVideoV2, Epsilon.Tolerance);
    
    

    I'm not a video/audio expert, so I'm not really sure how to flesh these out. Do I just compare the bytes? Or is there another ffmpeg tool/command to use?

  • Enable Quality Selector Control in Angular Using Video.js

    3 février, par Abhay Singh

    I am using Video.js in an Angular 19.1.3 application, with version 8.21.0 of Video.js. I have successfully set up an HLS stream using a master index.m3u8 file, and the player automatically switches to lower quality segments when the network is slow, and to higher quality when the network is good. This part works as expected.

    However, I would like to add a manual quality selection option to allow users to choose the video quality themselves. Despite trying several plugins (such as videojs-hls-quality-selector and videojs-contrib-quality-levels), I haven't been able to get it working.

    Can anyone guide me on how to implement this feature in Video.js, ensuring that the quality selector is available for manual selection?

    Below is my Components code -

    import {AfterViewInit, Component} from '@angular/core';
    import videojs from 'video.js';
    import '@videojs/http-streaming';
    import 'video.js/dist/video-js.css';
    
    @Component({
      selector: 'app-home',
      imports: [],
      templateUrl: './home.component.html',
      styleUrl: './home.component.css'
    })
    export class HomeComponent implements AfterViewInit {
      
      ngAfterViewInit(): void {
        const player = videojs('my-video', {
          autoplay: false,
          controls: true,
          preload: 'auto',
          fluid: true,
          aspectRatio: '16:9',
        })
      
      }
    }
    

    Below is my HTML code -

      
    
  • Configuration error when configuring the FFMPEG compilation with NVCC/CUDA [closed]

    3 février, par Lerenn

    I'm trying to compile the last FFMPEG version (49726a922fd2b358feb7753488d415180da5121c) on Fedora 41 with some libraries, including the CUDA libraries.

    Everything works well when compiling without CUDA, but I have 2 cryptic errors when trying to run the configure command with the NVCC:

      nvcc -gencode arch=compute_60,code=sm_60 -O2 -std=c++11 -m64 -ptx -c -o /tmp/ffconf.q0uMcStN/test.o /tmp/ffconf.q0uMcStN/test.cu
      nvcc warning : Support for offline compilation for architectures prior to 'sm/lto>_75' will be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
      /usr/include/c++/14/type_traits(1610): error: "__is_nothrow_new_constructible" is not a function or static data member
            constexpr bool __is_nothrow_new_constructible
                        ^
    
      /usr/include/c++/14/type_traits(1610): error: "constexpr" is not valid here
            constexpr bool __is_nothrow_new_constructible
            ^
    
      2 errors detected in the compilation of "/tmp/ffconf.q0uMcStN/test.cu".
      ERROR: failed checking for nvcc.
    

    I tried compiling it with default gcc (gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)) but my NVCC version (Build cuda_12.8.r12.8/compiler.35404655_0) seems to support only the GCC version 13.2: https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html.

    I have compiled it and ran the configure command again but it seems that I have the same errors.

    Here is the configure command:

      PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" \
            ./configure \
            --cc=gcc-13.2 \
            --extra-libs=-lpthread --prefix="/usr/local" \
            --extra-cflags="-I/usr/local/include -I/usr/local/cuda/include" \
            --extra-ldflags="-L/usr/local/lib -L/usr/local/cuda/lib64" \
            --pkg-config-flags="--static" --enable-gpl --enable-nonfree \
            --enable-libfdk-aac --enable-libmp3lame --enable-libopus \
            --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 \
            --enable-libvidstab --enable-libaom \
            --enable-cuda-nvcc --enable-libnpp \
            --disable-static --enable-shared
    

    If you have any idea or lead on the matter, I would be really grateful.

  • What are the alternatives for ffserver ?

    3 février, par Benjamin

    Since the ffmpeg no longer support ffserver, then which server could I use to steamming videos transcoded by ffmpeg?