Upload and play video. RoR 5

Hi!
I'am trying to upload videos, from the client, to my web application, to
play it later.
All the tutorials and post that i found about this are of several years
ago, so someone can help me?
Thanks in advance!

Hi!
I'am trying to upload videos, from the client, to my web application, to
play it later.
All the tutorials and post that i found about this are of several years
ago, so someone can help me?
Thanks in advance!

This is a very well solved problem, so there hasn't been a lot of change in this area. What have you tried, and where has it gone wrong for you?

Walter

Walter Davis wrote in post #1184561:

This is a very well solved problem, so there hasn't been a lot of change
in this area. What have you tried, and where has it gone wrong for you?

Walter

Thanks for your response Walter.
I tried to follow the steps of:

https://www.pubnub.com/blog/2015-12-08-building-video-sharing-app-server-messaging-ruby/

with rails 4.2.6, ruby 2.2.1 and it doesn`t work for me. I used the gem
'paperclip' to upload images before, but not to upload videos, and I
never used the majority of gems of that proyect. I'm learning RoR since
three month ago and i don't know many of concept yet, nor the reason of
the generated errors.
What knowledge I should have to do a project like this?
Do you know some material (web pages, video tutorials, books...) to
learn this concepts?
Regards

Following the steps of the page, and running sedekiq and redis-server,
I have this on sedekiq:

Unknown encoder 'libtheora'
2016-07-11T16:48:42.300Z 39114 TID-owgatp770 OgvVideoEncoder
JID-5473fd4117a3b5aebaf19cf4 INFO: fail: 0.041 sec
2016-07-11T16:48:42.300Z 39114 TID-owgatp770 WARN:
{"class":"OgvVideoEncoder","args":[13],"retry":true,"queue":"default","jid":"5473fd4117a3b5aebaf19cf4","created_at":1468255407.2016299,"enqueued_at":1468255722.258083,"error_message":"exception
class/object
expected","error_class":"TypeError","failed_at":1468255407.339723,"retry_count":4,"retried_at":1468255722.298764}
2016-07-11T16:48:42.300Z 39114 TID-owgatp770 WARN: TypeError: exception
class/object expected
2016-07-11T16:48:42.300Z 39114 TID-owgatp770 WARN:
/Users/JiNo/VideoShrimp/app/workers/ogv_video_encoder.rb:14:in `raise'
/Users/JiNo/VideoShrimp/app/workers/ogv_video_encoder.rb:14:in `perform'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:152:in
`execute_job'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:134:in
`block (2 levels) in process'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:128:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/bundler/gems/sidetiq-7bec4084165f/lib/sidetiq/middleware/history.rb:8:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/active_record.rb:6:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/retry_jobs.rb:74:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/logging.rb:11:in
`block in call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/logging.rb:32:in
`with_context'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/logging.rb:7:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:133:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:133:in
`invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:129:in
`block in process'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:168:in
`stats'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:128:in
`process'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:80:in
`process_one'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:68:in
`run'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/util.rb:17:in
`watchdog'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/util.rb:25:in
`block in safe_thread'

and repeats the same...

Walter Davis wrote in post #1184561:

This is a very well solved problem, so there hasn't been a lot of change
in this area. What have you tried, and where has it gone wrong for you?

Walter

Thanks for your response Walter.
I tried to follow the steps of:

https://www.pubnub.com/blog/2015-12-08-building-video-sharing-app-server-messaging-ruby/

with rails 4.2.6, ruby 2.2.1 and it doesn`t work for me.

Did you get errors, and if so, can you paste some of them here or at Gist or Pastie (if they're really long)? 'Doesn't work' covers a lot of ground. Did you try building a throw-away site with Paperclip, just to see if you could upload regular JPEG images according to the recipe on the README page?

I have built a video sharing site with Paperclip and Rails 4.2, and that side of things (uploading files and linking to them) worked without drama or special effort.

What took me some time to sort out was creating the placeholder images (sample one frame 5 seconds into the clip and save it as a JPEG), or transcode some wonky flavor of Windows Media into standard MP4 with ffmpeg. Those parts are non-trivial, and for a start, you may find it useful to read some non-rails sites about ffmpeg and how to get it working on your server. But you still haven't explained what got you stuck, how far you got, and where it stopped working for you.

I used the gem
'paperclip' to upload images before, but not to upload videos, and I
never used the majority of gems of that proyect. I'm learning RoR since
three month ago and i don't know many of concept yet, nor the reason of
the generated errors.

Before you run like this, I recommend you walk over to http://railstutorial.org and complete the free online course. Do the whole thing. Type everything by hand, don't copy and paste the examples. This really matters. Depending on your non-Rails programming experience, this can take you two days or two weeks to finish. But once you have, you will have a foundational knowledge of Rails, upon which you can layer more experience and add new tricks. I can't overstate how important this step is.

What knowledge I should have to do a project like this?

For the ffmpeg stuff, at a minimum, learn how to compile a C executable at the command line. Read up on video transcoding and "snapshotting" (I just made that word up -- I mean how to extract a poster frame).

Do you know some material (web pages, video tutorials, books...) to
learn this concepts?

Yes, see above.

Walter

Sorry, I didn't see that you had pasted some of your errors, please ignore that part of my earlier reply.

Following the steps of the page, and running sedekiq and redis-server,
I have this on sedekiq:

Unknown encoder 'libtheora'

You don't have ffmpeg set up correctly. Go back and re-compile it with the theora stuff turned on.

2016-07-11T16:48:42.300Z 39114 TID-owgatp770 OgvVideoEncoder
JID-5473fd4117a3b5aebaf19cf4 INFO: fail: 0.041 sec
2016-07-11T16:48:42.300Z 39114 TID-owgatp770 WARN:
{"class":"OgvVideoEncoder","args":[13],"retry":true,"queue":"default","jid":"5473fd4117a3b5aebaf19cf4","created_at":1468255407.2016299,"enqueued_at":1468255722.258083,"error_message":"exception
class/object
expected","error_class":"TypeError","failed_at":1468255407.339723,"retry_count":4,"retried_at":1468255722.298764}
2016-07-11T16:48:42.300Z 39114 TID-owgatp770 WARN: TypeError: exception
class/object expected
2016-07-11T16:48:42.300Z 39114 TID-owgatp770 WARN:
/Users/JiNo/VideoShrimp/app/workers/ogv_video_encoder.rb:14:in `raise'
/Users/JiNo/VideoShrimp/app/workers/ogv_video_encoder.rb:14:in `perform'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:152:in
`execute_job'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:134:in
`block (2 levels) in process'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:128:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/bundler/gems/sidetiq-7bec4084165f/lib/sidetiq/middleware/history.rb:8:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/active_record.rb:6:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/retry_jobs.rb:74:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/logging.rb:11:in
`block in call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/logging.rb:32:in
`with_context'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/logging.rb:7:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in
`block in invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:133:in
`call'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:133:in
`invoke'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:129:in
`block in process'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:168:in
`stats'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:128:in
`process'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:80:in
`process_one'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:68:in
`run'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/util.rb:17:in
`watchdog'
/Users/JiNo/.rvm/gems/ruby-2.2.1/gems/sidekiq-4.1.4/lib/sidekiq/util.rb:25:in
`block in safe_thread'

and repeats the same...

I would really recommend that you try -- just at the start -- to do this without background processing. It is trivial to add that later (and you should) but for now it's going to confuse you more than it helps.

Walter

Walter Davis wrote in post #1184577:

You don't have ffmpeg set up correctly. Go back and re-compile it with
the theora stuff turned on.

I don't know what happened, I follow the steps of the second answer in:

http://stackoverflow.com/questions/14236617/how-to-install-libtheora-for-macosx-ffmpeg

and still doesn't work, it seems that there are no errors on sedekiq,
but I think that OgvVideoEncoder and WebmVideoEncoder don't run, because
in the table course their entries of "attachments" are always nil. I
force the show view to can watch my upload video, and I can do it with a
very small video, but I can't with a heavy video.

After understanding the tutorial:
https://www.pubnub.com/blog/2015-12-08-building-video-sharing-app-server-messaging-ruby/
I have a problem.

I need to open ogv and webm files and i get this:

Command :: file -b --mime '...'

looking for a solution to this problem, I read that is necessary to add
the audio format in mime_types.rb.

Mime::Type.register "video/ogg", :ogv
Mime::Type.register "video/webm", :webm

but I still have the same problem. Any solution?
Regards