从在线流记录的损坏的AAC文件 [英] Corrupted AAC files recorded from online stream

查看:118
本文介绍了从在线流记录的损坏的AAC文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以最简单的方式记录AAC广播流中的音频:

  r = requests.get(' http://someradio.net:someport/stream.aac',stream = True)
self.new_filename()

以open(self.filename,'wb')为f:
尝试:
用于r.iter_content(self.chunk_size)中的块:f.write(block)
,键盘中断除外:
传递

生成的音频文件未正确编码(据我估计),导致Premiere Pro之类的Adobe应用程序以一种有趣的方式对待它们。例如,当它们应该是立体声时,它们将它们导入为单声道,最糟糕的部分是音频的前半部分在整个持续时间内以2倍的低速拉伸,而后半部分则丢失了。



因此,我使用FFmpeg和AudioSegment(显然,它知道如何处理这些文件)将AAC转换为MP3,在Premiere上也能很好地工作:

  stream = AudioSegment.from_file('output.aac','aac')
stream.export('output.mp3',format ='mp3')

bur录音很长,转换需要时间和资源。



我很确定可以对原始AAC进行一些非常简单的操作,以便Premiere可以按原样正确读取它们,我只是不知道它是什么。






添加1:我认为这可能与以下事实有关:我正在记录来自中间的持续流,因此是AAC文件的标头或其他内容没有正确地写也就是说,单声道/立体声属性似乎有些混乱。



添加2:在Adobe Premiere Pro,After Effects和Media Encoder中遇到的问题都是最新的版本(CC 2018,四月)。播放器(MPC,VLC,WMP)和Vegas Pro等所有其他应用程序都认为这些AAC很好。



添加3:一个类似的问题(未回答),涉及从在线流录制,AAC和2倍的音频损坏速度变慢:



声波的样子。


I'm recording audio from an AAC radio stream the simplest way I know:

r = requests.get('http://someradio.net:someport/stream.aac', stream=True)
self.new_filename()

with open(self.filename, 'wb') as f:
  try:
    for block in r.iter_content(self.chunk_size): f.write(block)
  except KeyboardInterrupt:
    pass 

The resulting audio files are not properly encoded (as I guess) causing Adobe applications like Premiere Pro to treat them a funny way. For instance, they import them as mono while they should be stereo and the worst part is that the first half of the audio is stretched over the whole duration in 2x lower pace and the second half is missing.

So I convert the AAC's to MP3's with FFmpeg and AudioSegment (apparently, it knows how to treat these files) which work just fine with Premiere:

stream = AudioSegment.from_file('output.aac', 'aac')
stream.export('output.mp3', format='mp3')

bur the recordings are long and conversion takes time and resources.

I'm pretty sure something very simple can be done to the original AAC's so they can be read properly by Premiere as they are, I just don't know what it is.


Add 1: I think maybe it has something to do with the fact that I'm recording an ongoing stream from the middle, thus a header or something for the AAC file in not being written properly. Namely something appears to be messed up with mono/stereo property.

Add 2: Problem encountered in Adobe Premiere Pro, After Effects and Media Encoder all of which are of the latest version (CC 2018, April). All other applications like players (MPC, VLC, WMP) and Vegas Pro perceive these AAC's just fine.

Add 3: A similar question (unanswered) involving recording from online stream, AAC and 2x-times slower audio corruption: AAC stream resampled incorrectly

解决方案

The core of the problem seems to be Adobe (AE, PP, ME) failing to properly handle HE-AACv2 format in ADTS container, one apparently being a standard for online radio streams. Wiki notes Adobe Flash Player has issues with it and it seems that all other Adobe products do.

Adobe treats such files as 48000Hz mono's while they are really 24000Hz mono's with additional parametric channel for Parametric Channel decoding (which is HE-AACv2 major feature). Looks like Adobe does something unnatural to this mono channel stretching to make a 48000Hz file with the same duration. But that's just my guess, no idea what exactly does Adobe do.

The natural walkaround is a conversion to another format. For instance, AAC-LC even if in ADTS works just fine with Adobe.


Just for the record:

What sound waves look like.

这篇关于从在线流记录的损坏的AAC文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆