AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1737607

Life is complex's questions

Martin Hope
Life is complex
Asked: 2024-02-11 22:55:20 +0800 CST

使用 ffmpeg 分析 AVI 音频

  • 5

我刚开始使用ffmpeg. 我有一些 AVI 文件,我认为应该有音频,但我无法使用 VLC 播放音频。我尝试使用它ffmpeg来分析 AVI 文件的音频。

import subprocess

def has_audio(filename):
    result = subprocess.run(["ffprobe", "-v", "error", "-show_entries",
                             "format=nb_streams", "-of",
                             "default=noprint_wrappers=1:nokey=1", filename],
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT)
    return int(result.stdout) -1

print(has_audio('filename.avi'))

下面是其中一个 AVI 文件的输出。该文件看起来有音频,但也许我错误地读取了输出。我还尝试了这个问题中的代码,它告诉我视频有音频。

如何使用任一或其他应用程序确保该文件有音频或没有音频ffmpeg?

avi @ 0x7fddac005140] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'filename.avi':
  Metadata:
    date            : 2010-06-29
  Duration: 00:00:06.83, start: 0.000000, bitrate: 10607 kb/s
  Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080, 9878 kb/s, 30 fps, 30 tbr, 30 tbn
  Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 32000 Hz, 1 channels, s16, 512 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    date            : 2010-06-29
    encoder         : Lavf60.3.100
  Stream #0:0: Audio: pcm_s16le, 32000 Hz, mono, s16, 512 kb/s
    Metadata:
      encoder         : Lavc60.3.100 pcm_s16le
size=N/A time=00:00:05.99 bitrate=N/A speed=1.52e+03x       
video:0kB audio:375kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_volumedetect_0 @ 0x7fdd9b704080] n_samples: 192000
[Parsed_volumedetect_0 @ 0x7fdd9b704080] mean_volume: -44.3 dB
[Parsed_volumedetect_0 @ 0x7fdd9b704080] max_volume: -16.2 dB
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_16db: 3
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_17db: 0
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_18db: 9
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_19db: 9
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_20db: 15
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_21db: 16
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_22db: 12
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_23db: 25
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_24db: 19
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_25db: 25
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_26db: 22
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_27db: 13
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_28db: 17
[Parsed_volumedetect_0 @ 0x7fdd9b704080] histogram_29db: 13

这是输出MediaInfo

Bit rate: 12884197, Frame rate: 30.000, Format: JPEG
Duration (raw value): 6833
Duration (other values:
['6 s 833 ms',
 '6 s 833 ms',
 '6 s 833 ms',
 '00:00:06.833',
 '00:00:06:25',
 '00:00:06.833 (00:00:06:25)']
Track data:
{'alignment': 'Aligned',
 'bit_depth': 16,
 'bit_rate': 512000,
 'bit_rate_mode': 'CBR',
 'channel_s': 1,
 'codec_id': '1',
 'codec_id_url': 'http://www.microsoft.com/windows/',
 'commercial_name': 'PCM',
 'count': '285',
 'count_of_stream_of_this_kind': '1',
 'delay': 0,
 'delay__origin': 'Stream',
 'delay_relative_to_video': 0,
 'duration': 6000,
 'format': 'PCM',
 'format_settings': 'Little / Signed',
 'format_settings__endianness': 'Little',
 'format_settings__sign': 'Signed',
 'interleave__duration': 1139,
 'kind_of_stream': 'Audio',
 'other_alignment': ['Aligned on interleaves'],
 'other_bit_depth': ['16 bits'],
 'other_bit_rate': ['512 kb/s'],
 'other_bit_rate_mode': ['Constant'],
 'other_channel_s': ['1 channel'],
 'other_delay': ['00:00:00.000', '00:00:00.000'],
 'other_delay__origin': ['Raw stream'],
 'other_delay_relative_to_video': ['00:00:00.000', '00:00:00.000'],
 'other_duration': ['6 s 0 ms',
                    '6 s 0 ms',
                    '6 s 0 ms',
                    '00:00:06.000',
                    '00:00:06.000'],
 'other_format': ['PCM'],
 'other_interleave__duration': ['1139',
                                '1139  ms (34.17 video frames)',
                                '34.17'],
 'other_kind_of_stream': ['Audio'],
 'other_sampling_rate': ['32.0 kHz'],
 'other_stream_size': ['375 KiB (4%)',
                       '375 KiB',
                       '375 KiB',
                       '375 KiB',
                       '375.0 KiB',
                       '375 KiB (4%)'],
 'other_track_id': ['1'],
 'proportion_of_this_stream': '0.04238',
 'samples_count': '192000',
 'sampling_rate': 32000,
 'stream_identifier': '0',
 'stream_size': 384000,
 'streamorder': '1',
 'track_id': 1,
 'track_type': 'Audio'}
audio
  • 2 个回答
  • 67 Views
Martin Hope
Life is complex
Asked: 2022-10-11 11:11:40 +0800 CST

使用 PowerShell 根据时间范围在应用程序日志中搜索字符串

  • 7

2022 年 11 月 10 日更新

我添加了时间框架参数,但我收到了空正文的错误消息。我该如何防止这种情况?

这是我当前的脚本:

$Subject = "EventLogAlert {0:yyyy-MM-dd HH:mm:ss} on $env:COMPUTERNAME" -f (Get-Date)

$Server = "smtp.server" 
$From = "From@domain.com" 


$To = "SOMENAME@domain.com"
$Pwd = ConvertTo-SecureString "******" -AsPlainText –Force

#(Warning! Use a very restricted account for the sender, because the password stored in the script will be not encrypted)
$Cred = New-Object System.Management.Automation.PSCredential("From@domain.com" , $Pwd)

$encoding = [System.Text.Encoding]::UTF8


$EndTime = Get-Date
$StartTime = (Get-Date).AddMinutes(-15)


$events    = Get-WinEvent -FilterHashtable @{LogName="Application";ID=400;ProviderName="ProviderNameGoesHere";StartTime=$StartTime;EndTime=$EndTime} |
             Where-Object {$_.Message -like '*StingToLookFor*'} |
             Select-Object -Property TaskDisplayName,ID,TimeCreated,Message -First 1


$Body = $events

Send-MailMessage -From $From -To $To -SmtpServer $Server -Body "$Body"  -Subject $Subject -Credential $Cred -Encoding $encoding

错误信息:

At C:\ps\script_name:1 char:1

+ script name: script_name.ps1

+ ~~~~~~

    + CategoryInfo          : ObjectNotFound: (script:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

Get-WinEvent : No events were found that match the specified selection criteria.

At C:\ps\script_name.ps1:22 char:14

+ ... events    = Get-WinEvent -FilterHashtable @{LogName="Application";ID= ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (:) [Get-WinEvent], Exception

    + FullyQualifiedErrorId : NoMatchingEventsFound,Microsoft.PowerShell.Commands.GetWinEventComm

   and

Send-MailMessage : Cannot validate argument on parameter 'Body'. The argument is null or empty.

Provide an argument that is not null or empty, and then try the command again.

At C:\ps\script_name.ps1:29 char:64

+ ... Message -From $From -To $To -SmtpServer $Server -Body "$Body"  -Subje ...

+                                                           ~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Send-MailMessage], ParameterBindingValidationExce

   ption

    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.Send

   MailMessage

原帖 2022 年 10 月 10 日

我是 PowerShell 的新手。我正在开发一个脚本来监视特定字符串的应用程序日志。下面的脚本有效,但我需要帮助限制搜索的时间范围。现在它搜索整个日志。我只想搜索最后 15 分钟,并且仅在此时间范围内匹配时才发送电子邮件。该脚本通过任务计划程序每 10 分钟运行一次。

有人可以指导我解决这个问题吗?

#Mail SMTP Setup Section
$Subject = "EventLogAlert {0:yyyy-MM-dd HH:mm:ss} on $env:COMPUTERNAME" -f (Get-Date)
$Server = "smtp.server" 
$From = "From@domain.com" 

$To = "SOMENAME@domain.com"
$Pwd = ConvertTo-SecureString "enterpassword" -AsPlainText –Force password
$Cred = New-Object System.Management.Automation.PSCredential("From@domain.com" , $Pwd) #Sender account credentials

$encoding = [System.Text.Encoding]::UTF8 


$events    = Get-WinEvent -FilterHashtable @{LogName="Application";ID=400;ProviderName="ProviderNameGoesHere"} | 
             Where-Object {$_.Message -like '*StingToLookFor*'} | 
             Select-Object -Property TaskDisplayName,ID,TimeCreated,Message



$Body=Get-WinEvent -FilterHashtable @{LogName="Application";ID=400;ProviderName='ProviderNameGoesHere'} | Select TimeCreated,Message | select-object -First 1


Send-MailMessage -From $From -To $To -SmtpServer $Server -Body "$Body"  -Subject $Subject -Credential $Cred -Encoding $encoding
powershell smtp
  • 2 个回答
  • 246 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve