GData youtube视频上传缺少音频问题
我正在使用以下代码将 .mov 文件上传到 youtube。上传成功,但视频没有任何音频。如果我做错了什么,请告诉我......
- (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];
}
请帮助我。提前致谢。
I am using following code to upload .mov file to youtube. It upload successfully but the video don't have any audio. Please tell me if I am doing something wrong....
- (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];
}
please help me. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
更改你的输出音频设置......它应该是这样的......
change your output audio setting.... it should be like this.....
我认为 Youtube 支持 flv 和 mp4 格式的视频文件。所以请更改 mimetype。
希望您能得到预期的结果。
i think Youtube supports flv and mp4 format video files. so please change mimetype.
Hope you get expected results.
我认为你需要更改 mime 类型,如下所示,
这对我来说效果很好,而且我还将 .Mov 文件上传到不仅是 .mp4 或 .m4a 或 .flv
I think you need to change mime type as below
This thing works fine for me and also one more thing i am uploading .Mov file to not only .mp4 or .m4a or .flv
以下内容应该对您有帮助:
供参考:Youtube 上传质量
Following should help you:
for reference: Youtube Upload Quality