Jump to content

rar-file support / solution


Recommended Posts

Paracusia
Posted (edited)

Hello,

 

I read some threads about .rar support and figured out a solution which also works with remote storages(like gdrive):

 

I currently use following command to live-stream media from rar-files:

rar p -inul <rar-file> | ffmpeg -i - -c:v copy -threads 2 -c:a libfdk_aac -b:a 384k -cutoff 18000 -g 48 -keyint_min 48 -sc_threshold 0 -hls_time 5 -hls_playlist_type event -hls_segment_filename %04d.ts play.m3u8

 

whole script I use: 

#!/bin/bash
cat=$1
name=$2
archive=/home/stream/dump/
path=/home/stream/dump-web/tmp/

if [ -d $path/$name ]; then
   exit 1;
fi

mkdir -p $path/$name
cd $path/$name

unpack="rar p -inul $archive/$cat/$name/*.rar"
ffprobe="ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 -i -"

echo "codec check.."
codecTest=`$unpack | $ffprobe | grep 264`

# if video codec != x264, we need to reencode video(expensive)!
if [ x$? == x0 ]; then
   codec="-c:v copy";
else
   codec="-c:v libx264 -crf 10";
fi

echo "codec: $codec"
ffmpeg="ffmpeg -i - $codec -threads 2 -c:a libfdk_aac -b:a 384k -cutoff 18000 -g 48 -keyint_min 48 -sc_threshold 0 -hls_time 5 -hls_playlist_type event -hls_segment_filename %04d.ts play.m3u8"
echo "transcoding.."
echo "$unpack | $ffmpeg";
transcode=`$unpack | $ffmpeg`


The browser then just grabs the play.m3u8 with hls.js and plays fine.

 

I'd like to implement this to emby, but I cannot even find any build instructions for linux.

Emby would need to look out for *.rar files, then extract any info with ffprobe (which only needs the first .rar file in multiple archives), save it like ever in an .nfo and use the above code the play the media.

 

The HLS stream is continously increasing in duration, until its finally transcoded(usually[most rels are in x264, which is supported by HLS] only the audio needs the be reencoded[from AC3 to AAC], to fit browser support). I'd love to implement this feature in Emby, but I need your help:

 

- which part of code is responsible for media scanning?

- which part of code is responsible for playing media?

 

thank you very much beforehand!

 

kind regards

Edited by Paracusia
Posted

I need to go over all of the scenarios, but if that's really all that's needed then i can make it possible for you to inject this with a plugin.

 

Granted this means the user would have to supply the native rar executable.

Posted

i can think of one drawback right off the bat, which is that every stream will have to be processed through ffmpeg.

 

Like for instance, imagine an mp4 inside a .rar, which normally should direct play.

Paracusia
Posted

I need to go over all of the scenarios, but if that's really all that's needed then i can make it possible for you to inject this with a plugin.

 

Granted this means the user would have to supply the native rar executable.

that sound great and would be lovely!

 

 

i can think of one drawback right off the bat, which is that every stream will have to be processed through ffmpeg.

 

Like for instance, imagine an mp4 inside a .rar, which normally should direct play.

currently the script checks for x264 video codec, if its not there, it just transcodes the video too - I think we can handle this dynamically based on the source found in rar file

Posted

The main problem with this approach though is that it's a forward moving non seekable stream.

 

For instance, if you wanted to resume 23 minutes into the video, how would you do that?

 

It's not so simple to just say use -ss as usual because rar will still have to process everything up to that point.

Paracusia
Posted (edited)

The main problem with this approach though is that it's a forward moving non seekable stream.

 

For instance, if you wanted to resume 23 minutes into the video, how would you do that?

 

It's not so simple to just say use -ss as usual because rar will still have to process everything up to that point.

the stream is seekable to the point where the transcode process currently is, and if someone wants to continue watching somewhere in the middle, he has to wait until the transcode reaches this point, thats the downside - but I could life with it :)

 

another approach could be:

 

movies which are not completely watched, stay in tmp folder for continue watching at every point

Edited by Paracusia
  • 1 year later...
Posted

Any News On this ? Did it ever make it to a plugin?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...