Convert mp3 to ogg via Paperclip (S3) on Heroku - ruby

I have a media attribute (from paperclip) that can be audio or image. I use an HTML5 audio player (jplayer) for an audio player on the front-end which works well in Chrome and Safari but Firefox has trouble with mp3 and needs a ogg format file. I see usage of ffmpeg but am unsure how to implement to also work on Heroku. I have tried using paperclip-ffmpeg like below but it hasn't been re-formatting the file (have tried format as 'ogv' and 'ogg'):
has_attached_file :media, styles: { ogg: { format: 'ogv' } }, processors: [:ffmpeg]
Any ideas?

Related

Rails Active Storage : video_tag not showing video

I m trying to implement some upload then play video in my app using Rails 5.2.3 and Active Storage. After fighting with active storage for a while i m finally sure that my attachment is containing the file i want to attach => after inspecting the src is correct
The problem here is that i keep getting those warnings from firefox console :
HTTP "Content-Type" of "text/html" is not supported. Load of media resource http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHM…JibG9iX2lkIn19--a44730f58a07282f626737b6a541d57fa9dc11c4/vid failed. 23
Cannot play media. No decoders for requested formats: text/html
and a video area with the following message "
No video with supported format and MIME type found"
Now, the console warnings are only showing up in Firefox but the video isn't playable in all the browsers that i tested so i think that my problem got something to do with the warning. I m new to rails so i ve tried all what i have found in google without solving my problem.
I m showing the video with the video_tag this way :
<%= video_tag(url_for(#play.clip), style: "width:100%;height:auto", :controls => true) if #play.clip.attached? %>
And added a meme_types.rb in initializers with the following code
Rack::Mime::MIME_TYPES.merge!({
".mp4" => "video/mp4",
})
I have tried to display the video using plain html5 ( which is the same) and i m naturally getting the same warnings...
fixed. The issue wasn't coming from the active storage itself. The get request to play the video was stopped by a line i wrote in routes.rb to make all "unknown routes" redirect to root_path :
get '*path' => redirect('/')
Now t hat the video playing video has been fixed i have to deal with "redirecting unknown paths to root without causing a problem with the GET "

How do I extract and record audio in webRTC on Firefox?

I implemented one to one webRTC video chat (Both audio and video)
navigator.getUserMedia({
audio: true,
video:true
}, function (stream) {
}, function(err){
})
But i want to record only audio of the chat session. In chrome i am able to record by using RecordRTC, But in Firefox i am getting video+audio file (webM).
How do I extract audio in Firefox from audio+video stream?
you have one of two ways to do it, when you make new recording, you do new RecordRTC(stream, config):
currently the stream you are passing must be videostream, you can change it to audiostream as stream.getAudioTracks()[0], I have not tried this, but guessing that it should work.
or as part of config, add an attribute recorderType: window.StereoRecorder, now it would use StereoRecorder and not firefox's own MediaStreamRecorder.
p.s: have you tried recording remote stream in chrome, because chrome supports recording only stereo mode and webrtc provides audio in mono mode.

Resolving rtmp stream url from Adobe Flash container

How can a rtmp stream url be retrieved completely with its playpath and be played with ffplay/avconv from a flash plugin. In embedded flash code below rtmp address exits (rtmp://live.atv.com.tr/atv) , however it does not work with avplay since it needs playpath.
<param value="config={"key":"##c67bf4e753034f78950","play":{"display":"none"},"clip":{"eventCategory":"Canli Yayin","url":"atv3","live":true,"provider":"influxis"},"plugins":{"controls":{"url":"http://i.tmgrup.com.tr/p/flowplayer.controls.swf"},"influxis":{"url":"http://i.tmgrup.com.tr/p/flowplayer.rtmp.swf","netConnectionUrl":"rtmp://live.atv.com.tr/atv"},"ova":{"url":"http://i.tmgrup.com.tr/p/ova.swf","autoPlay":true,"overlays":{"regions":[{"id":"Reklam","verticalAlign":"bottom","horizontalAlign":"right","backgroundC...0,"style":".smalltext { font-style: italic; font-size:10; }"}]},"ads":{"notice":{"show":true,"region":"my-ad-notice","message":"<p class=\"smalltext\" align=\"right\"> Kalan süre : _countdown_ saniye.</p>"},"schedule":[{"zone":"5","position":"pre-roll","server":{"type":"direct","apiAddress":"http%3a%2f%2fad.reklamport.com%2frpgetad.ashx%3ftt%3dt_atv_canli_yayin_preroll_800x700%26vast%3d2"}}]}}},"playerId":"live","playlist":[{"eventCategory":"Canli Yayin","url":"atv3","live":true,"provider":"influxis"}]}" name="flashvars">
Problem Solved: Using wireshark (network analyzer) is much more effective to retrieve paramaters like rtmp url, playpath...
Edit2: Some urls are also embedded in scripts files rather than directly in flash object, this variables are used in flash object above, later.

Streaming MP3 audio to HTML5 audio tag from servlet

I'm having some cross-browser compatibility joys. I have a Ruby WEBrick server with a couple of servlets, one of which is used to stream media (Ogg and MP3). The servlet gets a couple of query parameters (a base64 urlsafe string key, a small string user, and a small number, sid). When I put the URL verbatim into Chrome, I get the QuickTime extension, and it works. When I post the same into FireFox, I get the expected unsupported codec. When I put it in Safari, it works. However, the URL is not being accessed directly. I have a jQuery Mobile app that uses the Javascript Buzz library, and uses these servlet streaming URLs as sources. The code works in Safari, allowing me to play the sounds. On FireFox, instead of falling back onto Ogg, it gives unsupported errors, and on Chrome, it does nothing. Here's the code that serves the MP3:
res.status = 200
str = File.new("Music/#{req.query['sid']}.mp3", 'r:BINARY:BINARY').read
res.body = str
res['content-type'] = 'audio/mpeg'
Can anyone tell me how to get audio streaming to all browsers through a Ruby servlet?
Note: This is not a duplicate. I've been thorough a lot of SO answers, but none work because they are designed for static files, not servlets.

Is a .mp4 video file recorded in the WP Emulator ready for outside storage?

MS have released some code examples where a video is recorded in the WP Emulator and then saved in isolated storage. Is this .mp4 file ready to export away from the WP Emulator and play in other applications? Or is it needed to format it in some way or the other? If so, how to do it?
http://channel9.msdn.com/Shows/Inside+Windows+Phone/Inside-Windows-Phone-16-Mango-Camera-APIs
Source code for video recording is located in the WP project is called CameraUpload:
https://skydrive.live.com/?cid=bc58fec5c97e307a&sc=documents&id=BC58FEC5C97E307A%21295
http://msdn.microsoft.com/en-us/library/hh394041(v=vs.92).aspx
Edit:
I am trying to upload a video recorded in the WP Emulator to Azure blob.
A file does get uploaded, but I am not able to play that file in Zune.
I would like to be able to play the video file recorded in the WP Emulator on Zune, what to do to enable this?
The method in the Azure WCF service role, which saves the video looks like this:
(Please forgive if the method parameters have slightly misdirecting and confusing names.)
bool SaveImage(int salesItemId, string contentType, byte[] photo);
The video is saved to a blob container named "firstmay".
The code in the phone client saving the video looks like this:
client.SaveImageAsync(77, "mp4", GetPhotoBytes(m_capturedFileName));
public byte[] GetPhotoBytes(string fileName)
{
using (var appStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
IsolatedStorageFileStream isoStream = appStorage.OpenFile(m_capturedFileName, FileMode.Open);
byte[] buffer = new byte[isoStream.Length];
isoStream.Read(buffer, 0, (int)isoStream.Length); isoStream.Close();
return buffer;
}
}
When uploading a video from the WP client application, one first records a video and then uploads it by clicing "Save", it all goes on in the MainPage.
The client and server application can be downloaded from skydrive:
https://skydrive.live.com/redir?resid=159250F5CE7FE134!118
That'll all depend on what you want to be able to play back the content on. PCs with Zune would be fine, and I'd expect other video capable mobiles to be fine, but older mobiles, or standard Vista installs would require additional software, or transcoding of the video to be playable.

Resources