

One of the key observations here is that MP4 is not naturally suited to streaming media. Return Response ( generate (), mimetype =' video/mp4 ') PIPE route (' /video.mp4 ')įor data in iter (p.stdout.readline, b ''): Popen (' cat video.h264 | ' + cmd, shell = True, stdin =subprocess. ' -c:v h264 ' \ # input is h264 ' -i - ' \ # input from stdin ' -movflags frag_keyframe+empty_moov ' \ # allows mp4 to be streamable ' -vf scale=640:-1 ' \ # scales output to 640px in height, and a width to keep the current ratio. from flask import Flask, Response, render_templateĬmd = ' docker run -i -rm jrottenberg/ffmpeg:3.4-alpine ' \ Each ffmpeg argument is commented to describe why it is required. Once requested, a python generator is used to stream the results of a very crude subprocess which cats a video file into the ffmpeg docker container for muxing and returns the results in a pipe.

It serves HTML, which contains a video tag requesting video.mp4.

Luckily, you can grab a docker container with it in.īelow is a small python webapp. The only downside is that it requires a C toolchain, which in my experience, are troublesome to build cross-platform. If you want to display H264 video on a web browser, it needs muxing into MP4 or another file container format.įFmpeg is the leading tool available when muxing is required. MP4 is a file container, which can contain H264. To resolve this issue, try VLC media player.H264 is a codec. MP4 is a container that contains various kinds of data, so when there is a problem opening the file, it usually means that data in the container (an audio or video codec) is not compatible with the device’s OS. On some devices, particularly mobile, opening this file type can be problematic. On Windows, it opens in Windows Media Player. There is no need for third-party software. Simply double-clicking the file opens it. MP4 files open in the operating system's default video player. Many consider MP4 to be one of the best video formats available today. It is also a popular video format for streaming over the Internet, such as on YouTube. It is compatible with a wide range of devices and operating systems, using a codec to compress file size, resulting in a file that is easy to manage and store. MPEG-4 (MP4) is a container video format that can store multimedia data, usually audio and video.
