gpt4 book ai didi

iphone - GData YouTube视频上传的音频丢失

转载 作者:行者123 更新时间:2023-12-03 05:28:23 26 4
gpt4 key购买 nike

我正在使用GData Api从ios应用程序在youtube上上传视频。
它成功上传了视频,但是音频丢失了。

我正在使用.mp4格式的视频。
有人有线索吗?

谢谢

-(BOOL) setupWriter{
NSError *error = nil;
// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// NSString *documentsDirectory = [paths objectAtIndex:0];
// NSURL * url = [NSURL URLWithString:documentsDirectory];
// url = [url URLByAppendingPathComponent:@"om.mp4"];


// NSString *path = [documentsDirectory stringByAppendingPathComponent:@"om.mp4"];
// [data writeToFile:path atomically:YES];


NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/movie.mp4"]];
_videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:path] fileType:AVFileTypeQuickTimeMovie
error:&error];
NSParameterAssert(_videoWriter);


// Add video input
NSDictionary *videoCompressionProps = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithDouble:128.0*1024.0], AVVideoAverageBitRateKey,
nil ];

NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInt:192], AVVideoWidthKey,
[NSNumber numberWithInt:144], AVVideoHeightKey,
videoCompressionProps, AVVideoCompressionPropertiesKey,
nil];

_videoWriterInput = [[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo
outputSettings:videoSettings] retain];


float angle = M_PI/2; //rotate 180°, or 1 π radians
_videoWriterInput.transform = CGAffineTransformMakeRotation(angle);


NSParameterAssert(_videoWriterInput);
_videoWriterInput.expectsMediaDataInRealTime = YES;


// Add the audio input
AudioChannelLayout acl;
bzero( &acl, sizeof(acl));
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;


NSDictionary* audioOutputSettings = nil;
// Both type of audio inputs causes output video file to be corrupted.
if( NO ) {
// should work from iphone 3GS on and from ipod 3rd generation
audioOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[ NSNumber numberWithInt: kAudioFormatMPEG4AAC ], AVFormatIDKey,
[ NSNumber numberWithInt: 1 ], AVNumberOfChannelsKey,
[ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey,
[ NSNumber numberWithInt: 64000 ], AVEncoderBitRateKey,
[ NSData dataWithBytes: &acl length: sizeof( acl ) ], AVChannelLayoutKey,
nil];
} else {
// should work on any device requires more space
audioOutputSettings = [ NSDictionary dictionaryWithObjectsAndKeys:
[ NSNumber numberWithInt: kAudioFormatAppleLossless ], AVFormatIDKey,
[ NSNumber numberWithInt: 16 ], AVEncoderBitDepthHintKey,
[ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey,
[ NSNumber numberWithInt: 1 ], AVNumberOfChannelsKey,
[ NSData dataWithBytes: &acl length: sizeof( acl ) ], AVChannelLayoutKey,
nil ];
}

_audioWriterInput = [[AVAssetWriterInput
assetWriterInputWithMediaType: AVMediaTypeAudio
outputSettings: audioOutputSettings ] retain];

_audioWriterInput.expectsMediaDataInRealTime = YES;




// add input
[_videoWriter addInput:_videoWriterInput];
[_videoWriter addInput:_audioWriterInput];

return YES;
}

这是我用来捕获音频的设置编写器,在这上面有些扭曲吗?

最佳答案

CamStudio Support Forum:

.MOV / .MP4 / .3GPP files

MOV /MP4 /3GPP files are index based. Simply put, this means that there is an index in the file that tells us the specific location of where in the file the video and audio frames are present. Without the index, it is almost impossible to know where the data for a specific video or audio frame is. This index is contained in what is called a 'moov' atom in the file.

Now, if the index is at the beginning of the file, it will enable processing of the video as and when successive bytes of the file are uploaded. On the other hand, if the index is at the end, processing the video cannot begin until the entire upload is complete - since the index is needed to interpret the file.

Hence, for MOV / MP4 / 3gpp files, we prefer the "moov" atom in the beginning of the file - also known as a "fast start"MP4 / MOV file. There are tools available on the web to flatten your MOV file. Usually the video editing/export software will have options to create your files with the moov atom in the beginning rather than the end of your file. If you are using Apple editing tools, then see this article on how to produce a "fast start" MP4/MOV file./p>

Here's a list of some well-known formats that YouTube supports:

WebM files - Vp8 video codec and Vorbis Audio codecs

.MPEG4, 3GPP and MOV files - Typically supporting h264, mpeg4 video codecs, and AAC audio codec

.AVI - Many cameras output this format - typically the video codec is MJPEG and audio is PCM

.MPEGPS - Typically supporting MPEG2 video codec and MP2 audio

.WMV

.FLV - Adobe-FLV1 video codec, MP3 audio

关于iphone - GData YouTube视频上传的音频丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7597483/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com