UbuntuサーバーにBigBlueButton(ビデオ会議)プラットフォームをインストールしてミーティングを記録しています。このプロセスは、録画が終了した後に、以下である: Rubyのファイルメソッドがうまくいかず、スクリプトが失敗する
A Rubyスクリプトが処理して公開するために使用される記録
- プロセス記録を、溶液のコアです。私は、ウェブカメラビデオからサムネイルを生成し、それを公開スクリプトに追加する機能を追加しています。プロセススクリプトが完了すると、公開スクリプトが実行され、Webカメラビデオが存在するかどうかが確認されます。存在する場合は、ビデオをパブリッシングディレクトリにコピーし、新しい機能を使用してサムネイルを生成します。問題は、機能を追加した後、publishスクリプトがpublish.failエラーで失敗することです。ここで
は、新機能のコードです:
def GenerateThumbnails(video_dir,x) BigBlueButton.logger.info("Making Thumbnails dir") thumb_dir = "#{video_dir}/thumbnails" FileUtils.mkdir_p thumb_dir if x == true BigBlueButton.logger.info("Made Thumbnails dir - Generating Thumbnails") command="ffmpeg -ss 5 -i #{video_dir}/webcams.webm -vf "select=gt(scene\,0.4)" -frames:v 5 -vsync vfr -vf fps=fps=1/10 #{thumb_dir}/thumb%d.jpg" # -ss 5 : To discard the 5 first seconds of the video. # -vf "select=gt(scene\,0.4)" : To filter only frames # that have 40% change or more,compared to previous # frames. # -frames:v 5 : To get 5 frames in total. # -vsync vfr : Makes sure that the 5 frames,are different # from each others. # -vf fps=fps=1/10 : Generates 1 thumbnail for everty # 10th span of the video. BigBlueButton.execute(command) BigBlueButton.logger.info("Generated Thumbnails - Picking the most representative thumbnail") # The following code picks the thumbnail with the biggest # size,since more size means more details. i = (1..5).map {|i| File.size("#{thumb_dir}/thumb#{i}.jpg").to_f }.each_with_index.max[1] File.rename("#{thumb_dir}/thumb#{i + 1}.jpg", "thumbnail.jpg") # We get an array of file sizes from thumb1.jpg up to # thumb5.jpg # Then,we get the index of the greatest value of the # array. # Finally , now that we know that i is the index of the # greatest value in the array, then thumb#{(i+1)}.jpg is # the file with the greatest size, so that's the one we # want to replace the name of,with 'thumbnail.jpg' ,which # will be called later in the image source. BigBlueButton.logger.info("Picked the most representative thumbnail") else BigBlueButton.logger.info("Made Thumbnails dir - Copying the standard wrap image to the folder") FileUtils.cp("/var/lib/tomcat7/webapps/ROOT/remark/remark/global/photos/views-960x640.jpg","#{thumb_dir}") File.rename("#{thumb_dir}/views-960x640.jpg", "thumbnail.jpg") end end
Hereを公開するために使用Rubyコードです。
次のように私は、開始する前に私の機能を追加し、次に開始以内にそれを呼ばれる:
GenerateThumbnails(video_dir,true)
をライン951GenerateThumbnails(video_dir,false)
でライン953
編集で:
実際にログファイルに記録される内容は次のとおりです。
許可が拒否されました - (/foo/thumbnails/thumb7.jpg、thumbnail.jpg)私はこのように、アクセス権を強制しようとした
:しかし、私はまだ取得
File.chmod(0777, "#{thumb_dir}/thumb#{i + 1}.jpg") rescue nil File.rename("#{thumb_dir}/thumb#{i + 1}.jpg", "thumbnail.jpg")
を同じエラー。
私はパブリッシュスクリプトを書きませんでした。私は、この新しい関数をパブリッシュスクリプト全体で適切に動作させようとしています。
問題を解決するにはどうすればよいですか?
'command =" ffmpeg -ss 5 -i#{video_dir} /webcams.webm -vf "select = gt(scene \、0.4)"行にタイプミスがあります。-frames:v 5 -vsync vfr - vf fps = fps = 1/10#{thumb_dir} /thumb%d.jpg "'? そうでない場合は、文字列を途中で閉じることになります:) – Ninigi
typoとはどういう意味ですか? – MrRobot
また、バックスラッシュはルビ文字列のエスケープ演算子なので、別のバックスラッシュ 'scene \\、0.4'を使ってバックスラッシュをエスケープする必要があります。 – Ninigi