欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python操作音視頻ffmpeg-python對比pyav選擇

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

ffmpeg 音視頻操作

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

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

fmpeg-python 對比 pyav

那推薦用哪個呢?

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

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

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

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

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

使用 ffmpeg-python,如果本地沒有安裝 ffmpeg,就會報錯如下:

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 對比 pyav的詳細(xì)內(nèi)容,更多關(guān)于python mpeg-python對比pyav的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Python深拷貝與淺拷貝用法實例分析

    Python深拷貝與淺拷貝用法實例分析

    這篇文章主要介紹了Python深拷貝與淺拷貝用法,結(jié)合實例形式分析了Python對象的復(fù)制、深拷貝、淺拷貝等操作原理、用法及相關(guān)注意事項,需要的朋友可以參考下
    2019-05-05
  • Python的mysql數(shù)據(jù)庫的更新如何實現(xiàn)

    Python的mysql數(shù)據(jù)庫的更新如何實現(xiàn)

    這篇文章主要介紹了Python的mysql數(shù)據(jù)庫的更新如何實現(xiàn)的相關(guān)資料,這里提供實例代碼,幫助大家理解應(yīng)用這部分知識,需要的朋友可以參考下
    2017-07-07
  • Python中如何生成GeoJSON數(shù)據(jù)

    Python中如何生成GeoJSON數(shù)據(jù)

    這篇文章主要介紹了Python中生成GeoJSON數(shù)據(jù),無論使用geojson庫還是geopandas庫,都可以生成包含地理空間數(shù)據(jù)的GeoJSON文件,文中介紹了使用這些庫生成GeoJSON數(shù)據(jù)的簡單示例,需要的朋友可以參考下
    2023-10-10
  • Django集成Redis數(shù)據(jù)庫的操作指南

    Django集成Redis數(shù)據(jù)庫的操作指南

    本文將詳細(xì)介紹如何在 Django 項目中集成 Redis 數(shù)據(jù)庫,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • Python讀取mp3中ID3信息的方法

    Python讀取mp3中ID3信息的方法

    這篇文章主要介紹了Python讀取mp3中ID3信息的方法,實例分析了Python中mutagen包的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-03-03
  • Python利用手勢識別實現(xiàn)貪吃蛇游戲

    Python利用手勢識別實現(xiàn)貪吃蛇游戲

    想必大家都玩過貪吃蛇的游戲吧:通過操縱蛇的移動方向能夠讓蛇吃到隨機(jī)出現(xiàn)的食物,吃到的食物越多,蛇就會變得越長。本文將使用手勢識別來完成貪吃蛇這個簡單的游戲,感興趣的可以了解一下
    2022-04-04
  • 詳解python實現(xiàn)讀取郵件數(shù)據(jù)并下載附件的實例

    詳解python實現(xiàn)讀取郵件數(shù)據(jù)并下載附件的實例

    這篇文章主要介紹了詳解python讀取郵件數(shù)據(jù)并下載附件的實例的相關(guān)資料,這里提供實現(xiàn)實例,幫助大家學(xué)習(xí)理解這部分內(nèi)容,需要的朋友可以參考下
    2017-08-08
  • Python中sorted()排序與字母大小寫的問題

    Python中sorted()排序與字母大小寫的問題

    這篇文章主要介紹了Python中sorted()排序與字母大小寫的問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • 基于python+opencv調(diào)用電腦攝像頭實現(xiàn)實時人臉眼睛以及微笑識別

    基于python+opencv調(diào)用電腦攝像頭實現(xiàn)實時人臉眼睛以及微笑識別

    這篇文章主要為大家詳細(xì)介紹了基于python+opencv調(diào)用電腦攝像頭實現(xiàn)實時人臉眼睛以及微笑識別,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • 關(guān)于Python兩個列表進(jìn)行全組合操作的三種方式

    關(guān)于Python兩個列表進(jìn)行全組合操作的三種方式

    這篇文章主要介紹了關(guān)于Python兩個列表進(jìn)行全組合操作的三種方式,兩個元組 (a, b)(c, d),則它們的組合有 a,c a,d b,c b,d,這就叫全組合,需要的朋友可以參考下
    2023-04-04

最新評論