Video: Difference between revisions
Fabrice P. Laussy's Web
Fabrice (talk | contribs)
mNo edit summary
Line 31: Line 31:
<pre>
<pre>
  ffmpeg -i input.mkv -codec copy output.mp4
  ffmpeg -i input.mkv -codec copy output.mp4
</pre>
== Frame to Frame ==
=== Extraction ===
Extracting all frames: (better change the name of the frames to something more informative)
<pre>
ffmpeg -i videoplayback.mp4 frame_%04d.png
</pre>
=== Localization ===
Transfer time of video to frame number:
<pre>
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)}"'
</pre>
Then access them with a fast image viewer:
<pre>
feh --sort filename --version-sort --start-at frame_81600.png
</pre>
</pre>

Revision as of 12:08, 2 March 2025

Video

On our website

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.

Extraction

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.

Conversion

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

Frame to Frame

Extraction

Extracting all frames: (better change the name of the frames to something more informative)

ffmpeg -i videoplayback.mp4 frame_%04d.png

Localization

Transfer time of video to frame number:

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