shaka-project / shaka-streamer

A simple config-file based approach to preparing streaming media, based on FFmpeg and Shaka Packager.
https://shaka-project.github.io/shaka-streamer/
Apache License 2.0
198 stars 62 forks source link

How to convert video chunks created by shaka streamer to a tiny video that can be played using ffmpeg? #101

Closed upanitag closed 3 years ago

upanitag commented 3 years ago

Hi, How can I convert each webm chunk generated via shaka streamer into a proper video? I don't want to combine the chunks to one video but rather convert each tiny chunk to its own video. Is that feasible using ffmpeg and how?

For example, shaka streamer generates the following

video_1080p_2M_vp9_init.webm video_1080p_2M_vp9_1.webm video_1080p_2M_vp9_2.webm video_1080p_2M_vp9_3.webm video_1080p_2M_vp9_4.webm video_1080p_2M_vp9_5.webm

The chunks 1 to 5 are not playable on its own using VLC player etc. How do I convert each of them to 5 tiny playable videos?

Thanks, Upanita

joeyparrish commented 3 years ago

Fragmented files can be concatenated together to form full files. The init segment goes first, then the media segments in order.

This definitely works with fragmented MP4, but I haven't had to do that with WebM in a long time. Please try with the fragmented WebM and let us know if it works. Here's the command to this on Linux/Mac:

cat video_1080p_2M_vp9_{init,1,2,3,4,5}.webm > video_1080p_2M_vp9_full.webm
upanitag commented 3 years ago

Thanks! My question is more about creating a tiny video file from just one chunk say only video_1080p_2M_vp9_1.webm. Basically how can I make video_1080p_2M_vp9_1.webm playable in any player just by itself?

mariocynicys commented 3 years ago

I don't think you can do that, if you want to split a video into chunks each of them playable everywhere, you can just use ffmpeg for that with start time argument -ss and duration -to.

ffmpeg -ss 00:01:00 -i input.mp4 -to 00:02:00 -c copy output.mp4

This command cuts from minute one to minute three.

image

mariocynicys commented 3 years ago

I just tried what Joey said, found that you can concatenate the init segment with any other segment to create the chunk you wanted playable by it self.

cat video_1080p_2M_vp9_{init,1}.webm > video_first_chunk.webm

and for the sixth chunk for example:

cat video_1080p_2M_vp9_{init,6}.webm > video_sixth_chunk.webm
upanitag commented 3 years ago

Awesome. Thanks both of you. I will try it at my end.