2011-10-04 14 views
5

Korzystam z poniższego kodu, aby przesłać plik .mov do youtube. Przesyła się pomyślnie, ale wideo nie ma dźwięku. Proszę mi powiedzieć, czy robię coś nie tak ...GData youtube video upload brakujący problem z dźwiękiem

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

proszę mi pomóc. Z góry dziękuję.

+0

Było inny problem z przesłania jakość dźwięku z AVAssetWriter był niski to dlaczego nie był w stanie przesłać ... . – objectivecdeveloper

Odpowiedz

0

Uważam, że Youtube obsługuje pliki wideo w formatach flv i mp4. więc zmień typ MIME. Mam nadzieję, że uzyskasz oczekiwane wyniki.

1

Myślę, że trzeba zmienić typ MIME jak poniżej

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

To coś działa dobrze dla mnie i jeszcze jedna rzecz, jestem przesyłając plik .mov nie tylko .mp4 lub .m4a lub .flv

1

po powinny pomóc:

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

dla odniesienia: Youtube Upload Quality

1

zmienić ustawienia wyjścia dźwięku .... powinno być tak .....

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]; 
Powiązane problemy