How to pass videofile name to representation?
talasokratas opened this issue · comments
Hi, how do I pass file url to each Representation?
I generate different quality videos on file upload: video_240.mp4, video_360.mp4 and so on.
I can't set neither representation ID or Media url, so I don't get it how player supposed to find these convertions for adaptive bitrate streaming? Options are generated in mpd file but they seem to point to the same video file
$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open("$fullPath$fileName" );
$fileName = pathinfo($fileName, PATHINFO_FILENAME); // removes extension
mkdir($fullPath . $fileName);
$path = $fullPath . $fileName . '/';
$codec = new Video\X264();
//hd 1080
$codec
-> setKiloBitrate(6000)
-> setAudioKiloBitrate(192);
$video
->filters()
->resize(new Coordinate\Dimension(1920, 1080))
->synchronize();
$video
->save($codec, $path . $fileName .'_1080.mp4');
//hd 720
$codec
-> setKiloBitrate(3000)
-> setAudioKiloBitrate(128);
$video
->filters()
->resize(new Coordinate\Dimension(1280, 720))
->synchronize();
$video
->save($codec, $path . $fileName .'_720.mp4');
//high
$codec
-> setKiloBitrate(1400)
-> setAudioKiloBitrate(96);
$video
->filters()
->resize(new Coordinate\Dimension(854, 480))
->synchronize();
$video
->save($codec, $path . $fileName .'_480.mp4');
//med
$codec
-> setKiloBitrate(1000)
-> setAudioKiloBitrate(96);
$video
->filters()
->resize(new Coordinate\Dimension(640, 360))
->synchronize();
$video
->save($codec, $path . $fileName .'_360.mp4');
//low res
$codec
-> setKiloBitrate(400)
-> setAudioKiloBitrate(64);
$video
->filters()
->resize(new Coordinate\Dimension(426, 240))
->synchronize();
$video
->save($codec, $path . $fileName .'_240.mp4');
$r_240p = (new Representation)->setKiloBitrate(150)->setResize(426, 240);
$r_360p = (new Representation)->setKiloBitrate(276)->setResize(640, 360);
$r_480p = (new Representation)->setKiloBitrate(750)->setResize(854, 480);
$r_720p = (new Representation)->setKiloBitrate(2048)->setResize(1280, 720);
$r_1080p = (new Representation)->setKiloBitrate(4096)->setResize(1920, 1080);
$video->dash()
->setSegDuration(10)
->setAdaption('id=streaming,streams=v id=1,streams=a')
->x264()
->addRepresentations([$r_240p, $r_360p, $r_480p, $r_720p, $r_1080p])
->save($path . '/' . $fileName . '.mpd');
I didn't get your question meaning. If you mean how DASH works, you can see its documentation and RFC.
Thanks. Will read that RFC and am still studying dash documentation. I asked how to choose multiple files I have created when I use dash() to generate mpd file. Segment template seems to use representation id to locate correct files, but I am still new to this so I might be wrong. What I have used for now is this solution you suggested: #21 , it works as desired. If anyone wants to setup their streaming like that on their website and have problems installing shaka packager on server I suggest using npm to install shaka-packager-static, it's a prebuilt packager binary