This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GIFProcessor(Processor): | |
def sync(self, file): | |
mp4(file) | |
webm(file) | |
ogv(file) | |
time = 300 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MP4Processor(Processor): | |
sync = [validate_mp4, webm, ogv] | |
async = [png_frame] | |
time = 300 | |
def resolution(self, file): | |
# Some computation | |
file.resolution = 1234 | |
def audiostreams(self, file): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In your snippet, sync and async are functions. In mine, they are arrays of functions which can raise exceptions. The idea behind this is to remove code duplication. If sync() was a function, it would look something like this (https://gist.github.com/jdiez17/7760198). | |
Even though the idea of the functions in `sync` is to operate on files (in the disk), it doesn't mean that they're designed "around the idea that input file is converted to output files". A function that would validate GIFs/MP4s/whatever would a call to a command whose output is based on a file in the disk. | |
A major disadvantage of passing the Redis file object to all the functions is that each function would have to figure out the path in the file system, which leads to more clutter and code duplication than in the gist I linked. | |
For operations that require storing information on the database, passing the file path to the function is not enough: that's the use for the `extra` function (probably not the best name). Hell, for all I care, I could |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mediacrush.processing.invocation import Invocation | |
def detect(): | |
a = Invocation("ls -la") | |
a.run() | |
print a.stdout # blah | |
print a.returncode # 0 | |
print a.exited # False (True if it times out) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
P1: A => B ^ C | |
P2: B => ¬D | |
P3: C => D | |
P4: (added by Proof by Contradiction) A | |
Conclusion: false (proof by contradiction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"blob_type": "video", | |
"compression": 9.22, | |
"extras": [ | |
{ | |
"file": "/TayC7vkb31F5.png", | |
"type": "image/png" | |
} | |
], | |
"files": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mediacrush.objects import File | |
from mediacrush.database import r, _k | |
from mediacrush.processing.detect import detect | |
from mediacrush.mimetypes import get_mimetype, extension | |
from mediacrush.files import file_storage | |
if __name__ == '__main__': | |
for h in r.smembers(_k("file")): | |
f = File.from_hash(h) | |
mimetype = get_mimetype(f.original) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mediacrush.objects import File | |
from mediacrush.database import r, _k | |
from mediacrush.processing.detect import detect | |
from mediacrush.mimetypes import get_mimetype, extension | |
from mediacrush.files import file_storage | |
if __name__ == '__main__': | |
for h in r.smembers(_k("file")): | |
f = File.from_hash(h) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We're currently working on getting support for VTT, SRT, and ASS subtitles on MediaCrush, but we're not | |
done. If we finish it up, we'll revisit this post and describe how it's done. | |
You'll need to discover and extract subtitles and fonts, as well as provide a client-side subtitle | |
rendering solution like [libjass](https://github.com/Arnavion/libjass) or [WebVTT](https://wiki.mozilla.org/WebVTT). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flags = { | |
'video': BitVector('a', 'b', 'c') | |
'image': BitVector('d', 'e') | |
} | |
---- | |
def process_file: | |
processor, flags = detect() | |