2011-09-29 1 views
1

Gosi Api를 사용하여 ios 응용 프로그램에서 YouTube에 비디오를 업로드하고 있습니다. 동영상을 성공적으로 업로드했지만 오디오가 재생되지 않습니다.GData youtube video upload missing audio

저는 .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; 
} 

이이 나는 오디오를 캡처하는 데 사용하고 설치 작가이다 뭔가 결선 ????

답변

2

:

.MOV/.MP4/.3GPP는

MOV/MP4/3GPP 파일 인덱스 기반 파일. 간단히 말해서, 이것은 파일에 비디오 및 오디오 프레임이있는 의 특정 위치를 알려주는 색인이 파일에 있음을 의미합니다. 색인이 없으면 특정 비디오 또는 오디오 프레임에 대한 데이터의 위치를 ​​아는 것이 거의 불가능합니다. 이 색인은 파일에서 'moov'아톰에 포함되어 있습니다.

이제 인덱스가 파일의 시작 부분에있는 경우 파일의 연속 바이트가 으로 업로드 될 때 비디오의 처리가 으로 설정됩니다. 반면 색인이 끝에있는 경우 색인이 파일을 해석하는 데 필요하므로 전체 업로드가 완료 될 때까지 동영상을 처리 할 수 ​​없습니다. 동영상을 처리 할 수 ​​없습니다.

따라서 MOV/MP4/3gpp 파일의 경우 "fast start"MP4/MOV 파일이라고도하는 파일의 시작 부분에서 "moov"아톰을 선호합니다. MOV 파일을 플랫 화하기 위해 웹에서 사용할 수있는 도구가 있습니다. 보통 동영상 편집/내보내기 소프트웨어에는 파일의 끝 부분이 아닌 처음에 moov 아톰을 사용하여 개의 파일을 만드는 옵션이 있습니다. 당신이 애플 편집 도구를 사용하는 경우, 다음 "빠른 시작"MP4/MOV의 file./p 여기>

을 생산하는 방법을 에이 문서를 참조하십시오 YouTube가 지원하는 대표적인 형식의 목록입니다 :

의 WebM 파일 - VP8 비디오 코덱과 보비스 오디오 코덱

.MPEG4, 3GPP 및 MOV 파일 - 일반적 H264지지, MPEG4 비디오 코덱 및 AAC 오디오 코덱

.AVI - 많은 카메라 출력 형식 - 일반적 비디오 코덱은 MJPEG이고 오디오는 PCM입니다.

.MPEGPS - 일반적으로 MPEG2 비디오 코덱과 오디오 MP2

지지.WMV

.FLV - 어도비-FLV1 동영상 코덱, MP3 오디오 나 같은 .MP4 형식을 사용하고 @ankit

+1

감사하지만 그것은 단지 그것에 대해 그 .... 뉴욕의 단서와 함께 오디오 비디오를하지 업로드? – objectivecdeveloper

1

저는 지난 며칠 동안 GData API를 사용해 왔으며 비슷한 문제가 없었습니다. Youtube에서 지원하는 파일 형식을 체크 아웃하시는 것이 좋습니다 : http://www.google.com/support/youtube/bin/answer.py?answer=55744. 업로드중인 파일에 실제로 오디오가 있는지 확인할 수 있습니까? Quicktime은 오디오 트랙의 형식에 대해 무엇을 말합니까? Youtube는 AAC 사용을 권장합니다 (제가 말할 수있는 한). CamStudio Support Forum에서