stribny / fastapi-video Goto Github PK
View Code? Open in Web Editor NEWVideo streaming with FastAPI
Home Page: https://stribny.name/blog/fastapi-video
Video streaming with FastAPI
Home Page: https://stribny.name/blog/fastapi-video
The network tab shows that the chunks are being split equally but I cant seem to hit play on the video to see it
Most browsers work well with h264 codec but not others. What happens if the video I want to stream is in another coded and I want to re-encode it with FFMPEG and stream it on demand? (Like Plex media center)?
Environment:
It doesn't work when video is cut from an origin mp4 by ffmpeg, the origin mp4 is OK, e.g.:
ffmpeg -i origin.mp4 -ss 0 -t 30 out.mp4
or
ffmpeg -i origin.mp4 -ss 0 -t 30 -c copy out.mp4
The Partial Content responce is odd(the start,end
lines)๏ผ they are not continuous:
INFO: Application startup complete.
INFO: 127.0.0.1:45878 - "GET / HTTP/1.1" 200 OK
start,end: 0,1048576
INFO: 127.0.0.1:45878 - "GET /video HTTP/1.1" 206 Partial Content
start,end: 1966080,3014656
INFO: 127.0.0.1:45882 - "GET /video HTTP/1.1" 206 Partial Content
The origin mp4 information, which downloaded from https://www.youtube.com/watch?v=QW7r9i-nfpw
$ ffprobe "Automatic Speech Recognition _ by Darragh Hanley _ Kaggle Days Dubai _ Kaggle.mp4"
ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Automatic Speech Recognition _ by Darragh Hanley _ Kaggle Days Dubai _ Kaggle.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2019-08-02T00:11:56.000000Z
Duration: 00:39:46.43, start: 0.000000, bitrate: 580 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 449 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2019-08-02T00:11:56.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 08/01/2019.
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
creation_time : 2019-08-02T00:11:56.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 08/01/2019.
I'm very new to the video streaming, and I'm not able to find out the specific problem of the code.
The video just plays one second and then suspend. And I cannot drag my video process bar successfully, and it always plays from the begin rather than any middle position of the video.
I find an another code and it works well, so maybe it can help someone else.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.