In this article we are going to learn some common commands for converting and manipulating specific characteristics of media files. Although we've tried to show equivalent operations for all procedures, not all operations are possible in both applications.
In many cases, the commands we're showing may be combined in a single command line operation, and would be when actually used. For example, there's nothing preventing you from setting an output file's bitrate in the same operation as a file conversion. For this article, we often show these operations as separate commands for the sake of clarity.
Conversion is done with these applications:
Display characteristics
Both Shaka Packager and FFmpeg can be used to inspect the content of a media file and then display the characteristics of a stream. However, both provide different output for the same media.
Characteristics using Shaka Packager
packager input=glocken.mp4 --dump_stream_info
The output looks like:
File "glocken.mp4":
Found 2 stream(s).
Stream [0] type: Video
codec_string: avc1.640028
time_scale: 30000
duration: 300300 (10.0 seconds)
is_encrypted: false
codec: H264
width: 1920
height: 1080
pixel_aspect_ratio: 1:1
trick_play_factor: 0
nalu_length_size: 4
Stream [1] type: Audio
codec_string: mp4a.40.2
time_scale: 48000
duration: 481280 (10.0 seconds)
is_encrypted: false
codec: AAC
sample_bits: 16
num_channels: 2
sampling_frequency: 48000
language: eng
seek_preroll_ns: 20833
Characteristics using FFmpeg
ffmpeg -i glocken.mp4
The output looks like:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'glocken.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:00:10.03, start: 0.000000, bitrate: 8063 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080, 7939 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
At least one output file must be specified
Demux (separate) the audio and video streams
Shaka Packager requires demuxing when converting files. This is also required for using media frameworks.
Shaka Packager demuxing
MP4
packager input=myvideo.mp4,stream=video,output=myvideo_video.mp4
packager