我有一个Java批处理过程,它扫描目录并使用v3 API自动将视频上传到YouTube。这些工作每天处理几百个视频。其中上传的20-50%导致灰色椭圆图标,最终出现错误"失败(无法转换视频文件)"。
视频均为mp4格式。这些视频都使用相同的API流程,我将在下面概述。视频介于约70MB和以下之间。 150MB。
过程: 授权上传" https://www(dot)googleapis(dot)com/auth/youtube.upload",将隐私设置为公开,设置片段(设置频道,设置标题,设置描述,设置标签)
15/11/24 14:22:09 ERROR ReceiverTracker: Deregistered receiver for stream 1: Error starting receiver 1 - java.lang.NoClassDefFoundError: org/joda/time/format/DateTimeFormat
at com.amazonaws.auth.AWS4Signer.<clinit>(AWS4Signer.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:119)
at com.amazonaws.auth.SignerFactory.lookupAndCreateSigner(SignerFactory.java:105)
at com.amazonaws.auth.SignerFactory.getSigner(SignerFactory.java:78)
at com.amazonaws.AmazonWebServiceClient.computeSignerByServiceRegion(AmazonWebServiceClient.java:307)
at com.amazonaws.AmazonWebServiceClient.computeSignerByURI(AmazonWebServiceClient.java:280)
at com.amazonaws.AmazonWebServiceClient.setEndpoint(AmazonWebServiceClient.java:160)
at com.amazonaws.services.kinesis.AmazonKinesisClient.setEndpoint(AmazonKinesisClient.java:2102)
at com.amazonaws.services.kinesis.AmazonKinesisClient.init(AmazonKinesisClient.java:216)
at com.amazonaws.services.kinesis.AmazonKinesisClient.<init>(AmazonKinesisClient.java:202)
at com.amazonaws.services.kinesis.AmazonKinesisClient.<init>(AmazonKinesisClient.java:175)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker.<init>(Worker.java:106)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker.<init>(Worker.java:92)
at org.apache.spark.streaming.kinesis.KinesisReceiver.onStart(KinesisReceiver.scala:133)
at org.apache.spark.streaming.receiver.ReceiverSupervisor.startReceiver(ReceiverSupervisor.scala:125)
at org.apache.spark.streaming.receiver.ReceiverSupervisor.start(ReceiverSupervisor.scala:109)
at org.apache.spark.streaming.scheduler.ReceiverTracker$ReceiverLauncher$$anonfun$8.apply(ReceiverTracker.scala:308)
at org.apache.spark.streaming.scheduler.ReceiverTracker$ReceiverLauncher$$anonfun$8.apply(ReceiverTracker.scala:300)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1767)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1767)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:63)
at org.apache.spark.scheduler.Task.run(Task.scala:70)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.joda.time.format.DateTimeFormat
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 31 more
成功完成后,更新视频数据:
授权更新&#34; https://www(dot)googleapis(dot)com/auth/youtube&#34;,获取以前上传的视频ID,获取所述视频ID的摘要,将说明替换为更新的说明(该作业会创建一个标记的网址,用于合并说明视频ID,因此更新的原因。)
InputStream buffInStream = new BufferedInputStream(new FileInputStream(fileName));
AbstractInputStreamContent mediaContent = new InputStreamContent(MarketingConstants.YT_VIDEO_FORMAT, buffInStream);
YouTube.Videos.Insert videoInsert = youtube.videos().insert("snippet,statistics,status", videoMetadata, mediaContent);
videoInsert.setNotifySubscribers(false);
MediaHttpUploader uploader = videoInsert.getMediaHttpUploader();
// Set direct upload to TRUE and the job is remarkably efficient 2500kb/second (FAST)
// Set to False, and the job is horribly inefficient 70kb/second (SLOW)
uploader.setDirectUploadEnabled(true);
Video returnedVideo = videoInsert.execute();
最后,该过程根据内容细节将视频添加到原始频道中的特定播放列表。为此,它将授权播放列表更新&#34; https://www(dot)googleapis(dot)com/auth/youtube&#34;,根据类别(这些是流程中的属性)查找关联的播放列表ID,并进行更新。
snippet.setDescription(newDescription);
// Update the video resource by calling the videos.update() method
YouTube.Videos.Update updateVideosRequest = youtube.videos().update("snippet,status", video);
Video videoResponse = updateVideosRequest.execute();
我可以看到上传的视频失败而不是成功的唯一区别在于记录。
要成功上传: 2015-11-22 09:18:35:694 | YouTubeMediaService.uploadFileToYouTube()|正在上传 2015-11-22 09:19:27:158 | YouTubeMediaService.uploadFileToYouTube()|上传完成! 那是~52秒。
对于失败上传: 2015-11-22 07:31:12:182 | YouTubeMediaService.uploadFileToYouTube()|正在上传 2015-11-22 07:31:43:847 | YouTubeMediaService.uploadFileToYouTube()|上传完成! 那是~32秒。
它上传的速度越快(接近30秒),失败的可能性就越大。我确实看到一些需要更长时间但仍然失败的东西,但这是我发现的唯一异常现象。 最初,该过程会将隐私设置为私有,然后仅在成功更新信息后设置为公开,但Google建议我们删除该隐私,因为切换隐私设置时可能会发生已知的故障。
所以这是我的问题: 您建议我采取哪些措施来缓解此问题并最终实现接近95%或更高的成功上传率? 我应该一起删除隐私部分吗?我应该重试上传过快的视频,例如删除最近上传的视频,等待10秒,然后重试?
有没有其他人遇到此问题,特别是批量/自动上传?感谢您的帮助。This shows the uploaded and failed videos (titles removed)