Contents[hide] |
Believe it or not, it is quite difficult to display a video which you host yourself (that is, not inheriting its display from somewhere else). That is, it is difficult if you want to do it well and clean (using only open source throughout and HTML5 protocol).
If you use. In our case, we currently use MediawikiPlayer which relies on longtail video, which is at least partly open source.
To extract a segment from an mp4 between frames with timestamps 180.04 and 225 (timestamp is frame number / fps):
ffmpeg -ss 180.04 -to 225 -i lecture12-integrals.mp4 -c:v libx264 -c:a aac extracted-segment.mp4
Using -t instead of -to specifies a duration, not start-stop frames. See Stitching mp4 for a guided example.
To convert avi to mp4:
ffmpeg -i input.avi -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 output.mp4
https://superuser.com/questions/848584/convert-avi-file-to-mp4-in-linux
To convert mkv to mp4:
ffmpeg -i input.mkv -codec copy output.mp4
Extracting all frames: (better change the name of the frames to something more informative)
ffmpeg -i videoplayback.mp4 frame_%04d.png
Transfer time of video to frame number:
echo "Enter timestamp (e.g., 00:01:30 or 90):"; read time; echo "Enter frame rate (e.g., 30):"; read fps; if [[ $time =~ ^[0-9]+$ ]]; then secs=$time; else IFS=: read -r h m s <<< "$time"; secs=$((h*3600 + m*60 + s)); fi; echo "Frame number: $((secs * fps))";
Alternative version:
bash -c 'read -p "Enter time (hh:mm:ss): " t; read -p "Enter frame rate (fps, e.g., 30): " f; echo "$t" | awk -F: "{print int(((\$1*3600+(\$2)*60+\$3)*$f)+0.5)}"'
Then access them with a fast image viewer:
feh --sort filename --version-sort --start-at frame_81600.png