8/25/2021

Pure and natural honey , immunity booster सीधा किसान से आप खरीदे । एकता ...

11/25/2020

Virtual Media File or Video Metadata

FAQs

  1. How can I embed chapters metadata into media file? Because sometimes I have a big media file and I want that whenever I want, I can go to specific segment of that media file.

    1. Yes! Using ffmpeg
  2. Is There any way to create a config file to play different segment of videos from multiple files? This can be useful when you have list of media files and you want to create playlist for a single topic without merging these media files together.

    1. Yes! Using EDL file.

 

What is EDL?

EDL files basically concatenate ranges of video/audio from multiple source files into a single continuous virtual file.

Each such range is called a segment, and consists of source file, source offset, and segment length.

 

Example File

# mpv EDL v0
001.mp4, 200, 20,title=First Chapter
002.mp4, 100, 30,title=Second Chapter
003.mp4, 220, 100,title=Third Chapter

Note that You should save this file with file line endings from the Windows default CRLF to *nix-like LF only,

 

Usage

  • You can play this edl file directly by mpv player

    • mpv demo.edl
  • You can also save your virtual media file to disk (by encoding)

    • mpv demo.edl -o demo.mp4

 

Useful Shortcuts

  • [ and ]

    • Decrease/increase current playback speed by 10%.
  • BACKSPACE

    • Reset playback speed to normal.
  • T (Shift + t)

    • Toggle stay-on-top (see also --ontop).
  • PGUP and PGDWN key

    • Seek to the beginning of the previous/next chapter.
  • Alt + and Alt -

    • Combining Alt with the + or - keys changes video zoom.

    • Alt+LEFT, Alt+RIGHT, Alt+UP, Alt+DOWN

      • Move the video rectangle (panning).
    • Alt+BACKSPACE

      • Reset the pan/zoom settings.
  • Ctrl + h

    • Toggle hardware video decoding on/off.

 

using ffmpeg to add Chapters

You can use ffmpeg command line tool to add chapters into media file.

Extract metadata from media file

ffmpeg -i 001.mp4 -f ffmetadata meta.txt

 

Format of FFMETADATA file

;FFMETADATA1
major_brand=isom
minor_version=512
compatible_brands=isomiso2avc1mp41
encoder=Lavf58.45.100

[CHAPTER]
TIMEBASE=1/1000
START=0
END=60000
title=chapter \#1

[CHAPTER]
TIMEBASE=1/1000
START=60000
END=120000
title=chapter \#2

[CHAPTER]
TIMEBASE=1/1000
START=120000
END=500000
title=chapter \#3

 

Inserting metadata into media file

ffmpeg -i 001.mp4 -f ffmetadata meta.txt -map_metadata 1 -codec copy 001_conv.mp4

 

 

 

Sources

https://github.com/mpv-player/mpv/blob/master/DOCS/edl-mpv.rst

https://github.com/mpv-player/mpv/issues/6479

https://mpv.io/manual/master/#interactive-control

https://sourceforge.net/projects/mpv-player-windows/files/

http://ffmpeg.org/ffmpeg-formats.html#Metadata-1