New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow videos to be unmuted #532

Open
QuantumBadger opened this Issue Sep 24, 2017 · 14 comments

Comments

Projects
None yet
5 participants
@QuantumBadger
Owner

QuantumBadger commented Sep 24, 2017

Some videos have an audio track, but this is currently muted. It would be good to have some way of unmuting such videos.

@ajgoda90

This comment has been minimized.

Contributor

ajgoda90 commented Jan 9, 2018

What would be the complexity of doing this and where would one start? So many more things are now v.redd.it that this seems like an important feature to have.

@QuantumBadger

This comment has been minimized.

Owner

QuantumBadger commented Jan 16, 2018

Hi @ajgoda90, sorry for the delay in responding.

The MediaVideoView control is used to render the video:

https://github.com/QuantumBadger/RedReader/blob/master/src/main/java/org/quantumbadger/redreader/views/MediaVideoView.java

Which is used in the ImageViewActivity:

https://github.com/QuantumBadger/RedReader/blob/master/src/main/java/org/quantumbadger/redreader/activities/ImageViewActivity.java

The videos themselves are obtained from reddit using the following URL:

final String imageUrl = "https://v.redd.it/" + imgId + "/DASH_600_K";

https://github.com/QuantumBadger/RedReader/blob/master/src/main/java/org/quantumbadger/redreader/common/LinkHandler.java#L688

I'm not sure whether the video file returned actually has audio in it, or whether MPEG-DASH splits it out. If you have a link to a reddit video with an audio track, it should be possible to play it back in e.g. VLC and see the details.

I suspect the issue is that the audio is separate, in which case we need to figure out how to download the audio from reddit.

Hope that helps, let me know if anything is unclear :)

@ajgoda90

This comment has been minimized.

Contributor

ajgoda90 commented Jan 21, 2018

So it seems the audio is a separate mp4 that's at the v.redd.it/imgid/audio url. Looking into how we can sync up video and audio files I found this library which can handle that:

https://github.com/protyposis/MediaPlayer-Extended

Apache 2 licensed stuff can be included in a GPL 3 project so that'll work. What are your thoughts on using it?

@QuantumBadger

This comment has been minimized.

Owner

QuantumBadger commented Jan 23, 2018

Thank you for doing the research -- that library looks promising, I don't have any objections to it.

One thing to bear in mind is that the video/audio will need to be downloaded using RedReader's cache system as currently, so it won't be as simple as instantiating that library and passing it the URL.

Currently, images and videos less than 15MB are precached (on WiFi) when viewing the post list. This logic may need changing to download the video and audio separately where necessary.

Similarly, ImageViewActivity may need to set up two parallel requests through the cache, rather than just one as currently.

@ccrama

This comment has been minimized.

ccrama commented Feb 1, 2018

@QuantumBadger Hey just tuning in, having the exact same issues with my implementation with Slide.

I ended up switching over to ExoPlayer which allows native DASH .mpd streaming (adding /DASHPlaylist.mpd returns a playlist with different bitrates, channels, and audio which I used instead of adding /DASH_600_K to the ID and downloading it as an MP4 as RedReader does) which natively supports audio, but it has no way of interfacing with my caching system and the progress of download/file size indicator have no way to interface with ExoPlayer's more closed DASH streaming system. ExoPlayer also has pretty aggressive bitrate switching, and tends to use much lower quality streams than I would like (Reddit automatically splits videos into many different streams with varying bitrates/sizes).

Using the fallback_url from the submission JSON actually lets you get the original quality video DASH link which is actually encoded as an mp4 (600_k are usually pretty low resolution), and this works with my caching/loading system, but audio is split into v.redd.it/VIDEOID/audio as another MP4, which makes combining the two streams pretty difficult (mp3/mp4 splicing pretty straightforward, but MP4 video/MP4 audio combinations are not).

Seems like we're stuck between a rock and a hard place, the only real solution I see is using a library like FFMEG to combine two streams into one, which would work with directly with my caching/display system, but adds a ton of unnecessary complication to the code and makes a library do something it wasn't really meant to do. Honestly it's pretty ridiculous Reddit has decided to only allow for DASH streaming instead of a more ubiquitous standard like an actual MP4 with audio...

@QuantumBadger

This comment has been minimized.

Owner

QuantumBadger commented Feb 2, 2018

Thanks for the info @ccrama.

audio is split into v.redd.it/VIDEOID/audio as another MP4

Android provides the MediaExtractor class for demuxing containers like mp4, and MediaMuxer for combining them. If those are suitable, they'd avoid the need to bring in ffmpeg.

@ccrama

This comment has been minimized.

ccrama commented Feb 3, 2018

Unfortunately the MediaMuxer requires API 18, while I am trying to retain support for API 15. Might be time to raise the min SDK, but will continue looking for solutions that are more backwards compatible. Thank you for the info though! Will update you if I find another a solution

@QuantumBadger

This comment has been minimized.

Owner

QuantumBadger commented Feb 3, 2018

Unfortunately the MediaMuxer requires API 18, while I am trying to retain support for API 15.

As far as RedReader goes, I'd be happy to have two code paths -- one for API 18+, and one for 17 and below. That way users on up-to-date versions of Android will have audio, and users on older versions at least won't experience a regression.

@ccrama

This comment has been minimized.

ccrama commented Feb 3, 2018

@QuantumBadger ended up using this library which worked beautifully, seems to be supporting older API versions as well. Will link to my commit later if you'd like to see how I implemented it

@ajgoda90

This comment has been minimized.

Contributor

ajgoda90 commented Feb 3, 2018

The MediaPlayer-Extended library only needs API 16 if we can make that work for our needs. I haven't had a ton of time to work on it, but I do know the library drops right into place as it promises.

@fleming222

This comment has been minimized.

fleming222 commented Aug 31, 2018

Is there any update on this?
None of the video options (including vlc) play audio for v.reddit links.

@TippyLion28

This comment has been minimized.

TippyLion28 commented Nov 19, 2018

Any progress on this?

@ajgoda90

This comment has been minimized.

Contributor

ajgoda90 commented Nov 19, 2018

I haven't had time to make any progress, but I still think the MediaPlayer-Extended library would be a good choice. As QuantumBadger mentioned, the cache part was complicated and that's where I was stuck last time I looked at it. I can try to get back to it during the holidays, unless someone else wants to give it a go.

QuantumBadger added a commit that referenced this issue Nov 24, 2018

@QuantumBadger

This comment has been minimized.

Owner

QuantumBadger commented Nov 24, 2018

I've spent the last few hours implementing this, and it seems to work :)

77a2201

I've switched to ExoPlayer to merge the streams, but rather than giving it the .mpd file URL, the app now manually parses the .mpd file to find the video and audio, downloads them in parallel using the usual cache manager, and then hands the two local files to ExoPlayer.

It's in Alpha 168, so please try it out and let me know if it works:

https://redreader.org/alpha

Stuff that still needs to be added:

  • Ability to mute videos (in general). A preference for this would be nice.
  • When sharing reddit videos, the comment page link should be shared rather than the video-only link
  • Same with viewing in external browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment