Skip to content
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

Tool to split videos? #20

Closed
marcoXbresciani opened this issue Mar 1, 2019 · 10 comments
Closed

Tool to split videos? #20

marcoXbresciani opened this issue Mar 1, 2019 · 10 comments

Comments

@marcoXbresciani
Copy link
Contributor

Is there a tool that I can use to create chunks in the proper format needed for server.js? Also, which kind of video/audio codecs and container should I use?

@samirkumardas
Copy link
Owner

Sorry, I don't have such tool.

@marcoXbresciani
Copy link
Contributor Author

marcoXbresciani commented Mar 2, 2019 via email

@samirkumardas
Copy link
Owner

samirkumardas commented Mar 2, 2019

Please check the file example/server-h264.js
where I created chunk on the fly from h264

By the way I missed a part of your questions.
Supported Audio Code: AAC
Supported Video codec: h264 (any profile)
Container is mp4 that is JMuxer creates on the fly and feed into video tag

@marcoXbresciani
Copy link
Contributor Author

Thanks again. So if I take an MP4 with H264 video and AAC audio, I can use your "extractChunks" method to create the files I need for audio/video streaming, correct?

Sorry, I'm quite newbie on JS and audio/video things... coming from good ol' backend with Java.

@samirkumardas
Copy link
Owner

Nope, It won't work. It can only read 264 file.
That means it won't work mp4 directly. It expect h264 data

@marcoXbresciani
Copy link
Contributor Author

So that extractChunks in example/server-h264.js is for H264 only. So, sorry, not clear: how can I get an MP4 (H264+AAC) video file and prepare something like your raw/*.txt files to feed your (great!) jmuxer?

@samirkumardas
Copy link
Owner

samirkumardas commented Mar 4, 2019

Yes, example/server-h264.js is for H264 only. It is an example of playing raw h264 without audio.

Honestly I don't know any tool for making chunk of both audio and video. In my case, my server would provide chunk data. Basically it was an app that would record video and audio and converted that chunks on the fly.

How did I get those chunks?

I had to do few steps in order to make such chunks from mp4. For your information here were the steps:

  1. I had converted full mp4 into chunks using ffmpeg tool
  2. Then I extracted AAC and h264 from those chunks using ffmpeg tool again
  3. Finally, I merged each audio and video chunk into a compact audio/video chunk according to the packet format that I mentioned in project description. It was done using a simple javascript code.

Since JMuxer does not depends on any predefined packet format, so I just wanted to show an demo how it could work.

Hope this helps

Regards,
Samir

@marcoXbresciani
Copy link
Contributor Author

Thank you. I'll try and do my best.

@marcoXbresciani
Copy link
Contributor Author

marcoXbresciani commented Mar 8, 2019

Sorry for bothering again... could you take a look at my steps?

I did ffmpeg -i ROT.mp4 -vcodec copy -acodec copy -ss 0-t14 ROT-1-of-9.mp4 for each chunk.

Then I have to do something like ffmpeg -i input.mp4 -vn -acodec copy output.aac, for each chunk to have the audio right? And the like for video ffmpeg -i input.mp4 -an -vcodec copy output.h264.

@samirkumardas
Copy link
Owner

samirkumardas commented Mar 8, 2019

  1. Spliting video into 2 seconds chunks

ffmpeg -i input.mp4 -c copy -map 0 -segment_time 2 -f segment %03d.mp4

  1. Extracting h264 for all chunks

for f in *.mp4; do ffmpeg -i "$f" -vcodec copy -an -bsf:v h264_mp4toannexb "${f:0:3}.h264"; done

  1. Extracting audio for all chunks

for f in *.mp4; do ffmpeg -i "$f" -acodec copy -vn "${f:0:3}.aac"; done

  1. Extracting duration for all chunks

for f in *.mp4; do ffprobe "$f" -show_format 2>&1 | sed -n 's/duration=//p'; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants