2011-10-04 1 views
5

다음 코드를 사용하여 .mov 파일을 YouTube에 업로드하고 있습니다. 업로드는 성공적이나 비디오에는 오디오가 없습니다. 내가 잘못한 것을 말해주십시오 ....GData youtube video upload 오디오 문제가 누락되었습니다.

- (void)uploadVideoFile { 

    NSString *devKey = @"AI39si4w9QSgQj1JzNxzuiHhFbTm2iLt3mRerGh0UNvlryRPGgQhgIaJA8l95j4YwdC1jBIz6_JaX8eJm2GMgE06FtvIu7E9Sg"; 

    GDataServiceGoogleYouTube *service = [self youTubeService]; 
    [service setYouTubeDeveloperKey:devKey]; 

    NSString *username = txtYName.text; 

    NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username]; 

    // load the file data 
    NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/movie.mov"]] retain]; 
    NSData *data = [NSData dataWithContentsOfFile:path]; 
    NSString *filename = [path lastPathComponent]; 

    // gather all the metadata needed for the mediaGroup 
    NSString *titleStr = txtName.text; 
    GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr]; 

    NSString *categoryStr = @"Comedy"; 
    GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr]; 
    [category setScheme:kGDataSchemeYouTubeCategory]; 

    NSString *descStr = @"this is just test"; 
    GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr]; 

    NSString *keywordsStr = @"SuperShredBros"; 
    GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithString:keywordsStr]; 

    BOOL isPrivate = NO; 

    GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup]; 
    [mediaGroup setMediaTitle:title]; 
    [mediaGroup setMediaDescription:desc]; 
    [mediaGroup addMediaCategory:category]; 
    [mediaGroup setMediaKeywords:keywords]; 
    [mediaGroup setIsPrivate:isPrivate]; 

    NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:path 
              defaultMIMEType:@"video/quicktime"]; 

    // create the upload entry with the mediaGroup and the file data 
    GDataEntryYouTubeUpload *entry; 
    entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup 
                 data:data 
                MIMEType:mimeType 
                 slug:filename]; 

    SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:); 
    [service setServiceUploadProgressSelector:progressSel]; 

    GDataServiceTicket *ticket; 
    ticket = [service fetchEntryByInsertingEntry:entry 
              forFeedURL:url 
              delegate:self 
          didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)]; 

    [self setUploadTicket:ticket]; 
// [self updateUI]; 
} 

도와주세요. 미리 감사드립니다.

+0

업로드시 AVTOsetWriter의 오디오 품질이 낮아서 업로드 할 수없는 이유가 있습니다 ... . – objectivecdeveloper

답변

0

YouTube에서 flv 및 mp4 형식의 비디오 파일을 지원한다고 생각합니다. 그래서 mimetype을 변경하십시오. 희망하는 결과를 얻을 수 있기를 바랍니다.

1

나는 당신이이 일이 나를 위해 잘 작동하고 또한 한 가지 더 내가 .mov 파일에 대한뿐만 아니라 .MP4 또는 .M4A 또는

을 .FLV을 업로드하고

NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:fetchPath 
              defaultMIMEType:@"video/mp4"]; 

다음과 같이 MIME 타입을 변경할 필요가 있다고 생각

1

당신을 도움이 될 것입니다 다음은 참조

GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup]; 
[mediaGroup setMediaTitle:title]; 
[mediaGroup setMediaDescription:desc]; 
[mediaGroup addMediaCategory:category]; 
[mediaGroup setMediaKeywords:keywords]; 
[mediaGroup setIsPrivate:NO]; 

NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:outputURL.relativePath defaultMIMEType:@"video/quicktime"]; 

GDataEntryYouTubeUpload *entry; 
entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup data:data MIMEType:mimeType slug:filename]; 

SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:); 
[service setServiceUploadProgressSelector:progressSel]; 

GDataServiceTicket *ticket; 
ticket = [service fetchEntryByInsertingEntry:entry forFeedURL:url delegate:self didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)]; 

: Youtube Upload Quality

1

출력 오디오 설정을 변경하십시오 ..... 이와 같이해야합니다 .....

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];