
Note that the applications in Bento4 are very functional and can do a lot more, including adding captions and DRM into your HLS/DASH outputs as with FFmpeg, you can add as many switches as you need to implement the required features.

You can read more about mp4-dash at /mp4dash. Then you simply list the files created in lines 11–14 in the order you want them placed in the manifest file. Line 15. This line calls the m p4-dash application, includes the -hlsswitch to create HLS output, and uses the -output-dir switch to store the final files in the proper subfolder. You can read more about the mp4fragment utility at /bentomp4. The syntax is simple, just mp4fragment inputname outputname the hard part is pointing to the files in the subfolder for both input and output. Lines 11–14. This series of commands uses the Bento4 mp4fragment utility to convert the MP4 files created by FFmpeg into fragmented MP4 files required for the mp4-dash utility used in line 15. Again, note that I’m sending all files into the folder created in line 5. Getting the names right is critical because the files created in lines 6–10 feed into the fragmented MP4 files created in lines 11–14, which feed into the packaging created in line 15. mp4at the end designates the output file name for each file.

Line 5. I’m creating a separate output folder for each input file, which is necessary for the proper operation of the watch folder function implemented next.Ĭreate the folder using the mkdir command, and name it " $_*". In terms of major sections, here’s what’s happening: Here’s our second script, which is a bit more ambitious.Īs an overview, the most complicated part of the script relates to naming the output files and then recalling them for later use. mp4 files located in the folder within which it is run.įigure 5. As you can see on line 3, the script implements another "for" loop, so it processes all. The script I’ll use is shown in Figure 5. Now that you’ve got the basics, let’s take it up a notch and encode and package output for HLS and DASH distribution using FFmpeg and Bento4. The fruits of our Bash script: 13 files created with up to an 83% file size reduction with no impact on visual quality Working With Bento4 Not bad for essentially two lines of code.įigure 4.


Figure 4 shows two of the CRF files compared to the original with a data rate reduction as high as 83% with no impact on quality. The script ran through all 13 files in less than an hour. You’ll have to make each Bash script executable using this command sequence.įigure 3. Then, run the script again (./crf.sh), and it will start FFmpeg and iterate through all the files in the folder. As you see in the figure, however, if you try to run the script without first authorizing it, you’ll get the Permission denied error.Īs shown on the next input line, you make the file executable using this command: You run the Bash script from Terminal using the syntax shown on the top line of Figure 3 (.
