最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python操作音視頻ffmpeg-python對(duì)比pyav選擇

 更新時(shí)間:2023年11月28日 08:43:19   作者:ponponon  
這篇文章主要介紹了python操作音視頻的選擇:ffmpeg-python對(duì)比pyav,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

ffmpeg 音視頻操作

ffmpeg 是音視頻領(lǐng)域的王者,對(duì)音視頻的操作,離不開 ffmpeg

在 python 生態(tài)下面使用 ffmpeg 有兩個(gè)著名的庫

fmpeg-python 對(duì)比 pyav

那推薦用哪個(gè)呢?

當(dāng)然是后者:pyav

為什么?他兩有什么區(qū)別?

那就是調(diào)用 ffmpeg 的方式不同

ffmpeg-python 是直接調(diào)用 ffmpeg 這個(gè)可執(zhí)行程序來操作音視頻的,這就要求你本地安裝 ffmpeg。而且每次操作,都相當(dāng)于是起了一個(gè) ffmpeg進(jìn)程,非常的低效。

而 pyav 是鏈接了 ffmpeg 的動(dòng)態(tài)鏈接庫 libav,所以不存在每次操作都啟動(dòng)一個(gè) ffmpeg 進(jìn)程的問題,更加高效優(yōu)雅

使用 ffmpeg-python,如果本地沒有安裝 ffmpeg,就會(huì)報(bào)錯(cuò)如下:

In [1]: import ffmpeg
   ...: stream = ffmpeg.input('input.mp4')
   ...: stream = ffmpeg.hflip(stream)
   ...: stream = ffmpeg.output(stream, 'output.mp4')
   ...: ffmpeg.run(stream)
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[1], line 5
      3 stream = ffmpeg.hflip(stream)
      4 stream = ffmpeg.output(stream, 'output.mp4')
----> 5 ffmpeg.run(stream)

File /usr/local/lib/python3.11/site-packages/ffmpeg/_run.py:313, in run(stream_spec, cmd, capture_stdout, capture_stderr, input, quiet, overwrite_output)
    289 @output_operator()
    290 def run(
    291     stream_spec,
   (...)
    297     overwrite_output=False,
    298 ):
    299     """Invoke ffmpeg for the supplied node graph.
    300 
    301     Args:
   (...)
    311     Returns: (out, err) tuple containing captured stdout and stderr data.
    312     """
--> 313     process = run_async(
    314         stream_spec,
    315         cmd,
    316         pipe_stdin=input is not None,
    317         pipe_stdout=capture_stdout,
    318         pipe_stderr=capture_stderr,
    319         quiet=quiet,
    320         overwrite_output=overwrite_output,
    321     )
    322     out, err = process.communicate(input)
    323     retcode = process.poll()

File /usr/local/lib/python3.11/site-packages/ffmpeg/_run.py:284, in run_async(stream_spec, cmd, pipe_stdin, pipe_stdout, pipe_stderr, quiet, overwrite_output)
    282 stdout_stream = subprocess.PIPE if pipe_stdout or quiet else None
    283 stderr_stream = subprocess.PIPE if pipe_stderr or quiet else None
--> 284 return subprocess.Popen(
    285     args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
    286 )

File /usr/local/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File /usr/local/lib/python3.11/subprocess.py:1950, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1948     if errno_num != 0:
   1949         err_msg = os.strerror(errno_num)
-> 1950     raise child_exception_type(errno_num, err_msg, err_filename)
   1951 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

以上就是python 操作音視頻的選擇:ffmpeg-python 對(duì)比 pyav的詳細(xì)內(nèi)容,更多關(guān)于python mpeg-python對(duì)比pyav的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 樹莓派+攝像頭實(shí)現(xiàn)對(duì)移動(dòng)物體的檢測(cè)

    樹莓派+攝像頭實(shí)現(xiàn)對(duì)移動(dòng)物體的檢測(cè)

    這篇文章主要為大家詳細(xì)介紹了樹莓派+攝像頭實(shí)現(xiàn)對(duì)移動(dòng)物體的檢測(cè),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-06-06
  • python GUI庫圖形界面開發(fā)之PyQt5信號(hào)與槽基本操作

    python GUI庫圖形界面開發(fā)之PyQt5信號(hào)與槽基本操作

    這篇文章主要介紹了python GUI庫圖形界面開發(fā)之PyQt5信號(hào)與槽基本操作,需要的朋友可以參考下
    2020-02-02
  • 利用Python 制作二維碼

    利用Python 制作二維碼

    這篇文章主要介紹的是如何利用Python 制作二維碼,文章從介紹python 二維碼制作的第三方庫QRCode 和MyQR展開話題,需要的小伙伴可以參考一下文章的具體內(nèi)容
    2021-09-09
  • Python制作摩斯密碼翻譯器

    Python制作摩斯密碼翻譯器

    摩斯密碼是一種將文本信息作為一系列通斷的音調(diào)、燈光或咔嗒聲傳輸?shù)姆椒ǎ疚膶⒔榻B如何通過Python制作摩斯密碼翻譯器,感興趣的童鞋可以關(guān)注一下
    2021-11-11
  • Python實(shí)現(xiàn)功能全面的學(xué)生管理系統(tǒng)

    Python實(shí)現(xiàn)功能全面的學(xué)生管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了Python實(shí)現(xiàn)功能全面的學(xué)生管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • python實(shí)現(xiàn)彈跳小球

    python實(shí)現(xiàn)彈跳小球

    這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)彈跳小球,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-05-05
  • 解決jupyter notebook啟動(dòng)后沒有token的坑

    解決jupyter notebook啟動(dòng)后沒有token的坑

    這篇文章主要介紹了解決jupyter notebook啟動(dòng)后沒有token的坑,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • 更新pip3與pyttsx3文字語音轉(zhuǎn)換的實(shí)現(xiàn)方法

    更新pip3與pyttsx3文字語音轉(zhuǎn)換的實(shí)現(xiàn)方法

    今天小編就為大家分享一篇更新pip3與pyttsx3文字語音轉(zhuǎn)換的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08
  • 最新評(píng)論

    辽阳县| 萍乡市| 通河县| 高青县| 阳新县| 玉屏| 黔西县| 东山县| 西吉县| 阿瓦提县| 松桃| 墨江| 通江县| 长阳| 兰州市| 霸州市| 昌图县| 仪陇县| 佳木斯市| 揭阳市| 禄劝| 盈江县| 博客| 蒲江县| 轮台县| 安义县| 浏阳市| 乌鲁木齐市| 天峨县| 汝州市| 涟水县| 中宁县| 上饶市| 准格尔旗| 英德市| 新巴尔虎右旗| 怀仁县| 沧源| 永福县| 桓台县| 九龙县|