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

9/25/2020

[2020-09] Create Exam Sitting Plan using OCR


# Convert Image to editable list of roll numbers

  1. Scan or Capture a photo from your camera (List of students roll numbers should be in vertical column, so that OCR can easily read them) 
  2. If you want more accurate OCR result then you should crop the image and try to keep just the roll numbers, You can also erase other unwanted things from that photo. 
  3. Open Online OCR website https://ocr.space

# Convert list of roll numbers to HTML tables

1. You should have list of all roll numbers like this 
2021001
2021002
2021004
.
.

2. Open Chrome DevTools and Run this script to create HTML Tables, (You might want to tweak this JS code as per your requirements but this is basic code that I generally use)

This JS code depends upon lodash, so you will need lodash for this code to work

var a = `456539
456543
456548
...
462057
462073
462080
462090
462100
462120
462130`;

var b = a.split("\n");

b = b.map((v,k)=>{
    if ((k + 1) % 4 == 1)
        return 'A   ' + v;
    if ((k + 1) % 4 == 2)
        return 'B   ' + v;
    if ((k + 1) % 4 == 3)
        return 'C   ' + v;
    if ((k + 1) % 4 == 0)
        return 'D   ' + v;
}
);

var c = _(b).chunk(24).map((m)=>_.zip.apply(_, _.chunk(m, 6))).value();

function createTable(i, data) {
    var a = `<p>${i}</p><table border="1"><tbody>`;
    for (var t = 0; t < data.length; t++) {
        a += '<tr>';
        for (var r = 0; r < data[t].length; r++) {
            a += `<td>${data[t][r]}</td>`;
        }
        a += '</tr>';
    }
    a += '</tbody></table>';
    return a;
}

function createTables(tbls) {
    var b = '';
    for (var i = 0; i < tbls.length; i++) {
        b += createTable(i, tbls[i]);
    }
    return b;
}

createTables(c);

3. Copy generated HTML code to Excel


There you have it and now you can paste it into any exam sitting management excel template.


May! You have a nice day.