<jupyter_start><jupyter_text>Presto C++ mp4 file parserIn this notebook we will show how to use the presto mp4 file parser.*Note:* all cells starting with `%%` contains commands executed in the shell/terminal.  Building the libraryThe first thing we need to do is to build the library. The library is hosted on github https://github.com/steinwurf/petro. In case we already clone it we remove it first, this is only for the sake of this notebook.<jupyter_code>%%bash
rm -rf petro
git clone <EMAIL>:steinwurf/petro.git<jupyter_output>Cloning into 'petro'...<jupyter_text>Lets see which files we have:<jupyter_code>%%bash 
ls petro<jupyter_output>config.py
examples
NEWS.rst
README.rst
src
test
waf
wscript<jupyter_text>First step is to run the configure step (`--bundle-path` refers to where external dependencies are downloaded):<jupyter_code>%%bash 
cd petro
./waf configure --bundle-path=~/dev/bundle_dependencies<jupyter_output>Checking for program 'git'               : /usr/bin/git 
Resolve dependency waf-tools             : /home/mvp/dev/bundle_dependencies/waf-tools-ae40a5/3.1.3 
Resolve dependency gtest                 : /home/mvp/dev/bundle_dependencies/gtest-39e104/3.0.0 
Setting top to                           : /home/mvp/Dropbox/work_code/notebooks/presto_mp4_example/petro 
Setting out to                           : /home/mvp/Dropbox/work_code/notebooks/presto_mp4_example/petro/build/linux 
Using the mkspec:                        : cxx_default 
Checking for 'g++' (C++ compiler)        : /usr/bin/g++ 
Checking for library pthread             : yes 
'configure' finished successfully (0.184s)<jupyter_text>You can see all the available options by running `./waf --help`. After configuring the next step is to build the library.<jupyter_code>%%bash
cd petro
./waf build<jupyter_output>Waf: Entering directory `/home/mvp/Dropbox/work_code/notebooks/presto_mp4_example/petro/build/linux'
[ 1/64] Compiling ../../../../../dev/bundle_dependencies/gtest-39e104/3.0.0/gtest/src/gtest-all.cc
[ 2/64] Compiling src/petro/box/avcc.cpp
[ 3/64] Compiling src/petro/box/bxml.cpp
[ 4/64] Compiling src/petro/box/co64.cpp
[ 5/64] Compiling src/petro/box/cprt.cpp
[ 6/64] Compiling src/petro/box/ctts.cpp
[ 7/64] Compiling src/petro/box/elst.cpp
[ 8/64] Compiling src/petro/box/free.cpp
[ 9/64] Compiling src/petro/box/frma.cpp
[10/64] Compiling src/petro/box/ftyp.cpp
[11/64] Compiling src/petro/box/hdlr.cpp
[12/64] Compiling src/petro/box/hmhd.cpp
[13/64] Compiling src/petro/box/iinf.cpp
[14/64] Compiling src/petro/box/iloc.cpp
[15/64] Compiling src/petro/box/imif.cpp
[16/64] Compiling src/petro/box/ipmc.cpp
[17/64] Compiling src/petro/box/mdat.cpp
[18/64] Compiling src/petro/box/mdhd.cpp
[19/64] Compiling src/petro/box/mehd.cpp
[20/64] Compiling src/petro/box/mfhd.cpp
[21/64] Compiling src[...]<jupyter_text>Parsing a mp4 fileLets try to parse an mp4 file. First we need to download one:<jupyter_code>%%bash
wget http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4<jupyter_output>--2015-12-01 14:09:20--  http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4
Resolving download.blender.org (download.blender.org)... 192.168.3.11
Connecting to download.blender.org (download.blender.org)|192.168.3.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 64657027 (62M) [video/mp4]
Saving to: ‘BigBuckBunny_320x180.mp4.1’

     0K .......... .......... .......... .......... ..........  0% 1.17M 53s
    50K .......... .......... .......... .......... ..........  0% 2.31M 40s
   100K .......... .......... .......... .......... ..........  0% 77.9M 27s
   150K .......... .......... .......... .......... ..........  0% 2.35M 27s
   200K .......... .......... .......... .......... ..........  0% 71.0M 21s
   250K .......... .......... .......... .......... ..........  0% 2.40M 22s
   300K .......... .......... .......... .......... ..........  0%  101M 19s
   350K .......... .......... .......... .......... ..........  0% 63.2M [...]<jupyter_text>To see the `mp4` file content we can use the *complete_parser* example:<jupyter_code>%%bash
./petro/build/linux/examples/complete_parser BigBuckBunny_320x180.mp4<jupyter_output>ftyp
  size: 20
  major_brand: isom
  minor_version: 512
  compatible_brands: mp41
free
  size: 8
mdat
  size: 64312805
  data_offset: 36
moov
  size: 344194
    mvhd
      size: 108
      version: 0
      creation_time: Thu Jan  1 01:00:00 1970
      modification_time: Thu Jan  1 01:00:00 1970
      time_scale: 1000
      duration: 596459
      rate: 1
      volume: 1
      next_track_id: 3
    trak
      size: 119807
        tkhd
          size: 92
          version: 0
          track_enabled: 1
          track_in_movie: 1
          track_in_preview: 1
          creation_time: Thu Jan  1 01:00:00 1970
          modification_time: Thu Jan  1 01:00:00 1970
          track_id: 1
          duration: 596459
          layer: 0
          alternate_group: 0
          volume: 0
          width: 320
          height: 180
        mdia
          size: 119707
            mdhd
              size: 32
              version: 0
              creation_time: Thu Jan  1 01:00:00 1970
              modifi[...]
StarcoderdataJupyterStructuredCleanDedup