Closed Jose-Moreno closed 4 years ago
Beyond converting to an image sequence, the video importer should also extract the audio channel from the movie and import it to a sound layer.
We could also consider creating a new type of layer (video layer) that would reference the video file externally instead of copying it inside the pencil2d compressed project folder
One of the advantages of the pclx format in my opinion is its portability and lack of external references. Users don't wonder why their project stopped playing properly when they moved their file, or why the friend they sent it to can't see their work. However, I'm guessing playback would be faster from a video file, so there would be advantages for using it as a cache. Modifying frames of a video layer would be difficult though and other additional functionality would probably be need. I think it would be best left as something used only behind the scenes for caching bitmap layers. Anyway, this is something that should be put in its own issue. Even if we add a video layer, importing a video to bitmap+sound layers would still be useful and should be our first step for video importing.
@scribblemaniac sounds fair enough, and you're right having a video layer might be difficult for a starter project to implement this functionality and we would also require handling for external references to exist as well, which goes in a separate issue.
However even though most use cases are related to disposing the video reference, except the odd chance where you want to export both the animation on top of the video when the rotoscopy is partial or video is used for camera matching the animation (like for example having filmed a background and animating the character on top of it) we can't be certain people won't be exporting the video along the animation and as such I agree that for a solid solution we could use the first idea (convert to and import image sequence)
Perhaps though I'd like to consider as well, adding an interface to "slice" the video before importing, that is giving Pencil2D a range of frames to import rather than getting the whole video (unless you choose to). Normally when bringing image sequences you normally want them all because you know what you exported, but when you bring a video sometimes people can't (or won't) edit the video itself if they want a particular portion, so this should also be thought as part of this implementation.
Video frames can be extracted with Qt means, smth like this: https://stackoverflow.com/questions/38468644/getting-video-frame-in-provided-time-qt
After some research I figured out it won't work without additional codecs installed (at least on Windows, not sure about Unix). QMediaPlayer is using DirectShow as backend for video which on my clean system (Win10 x64) can play only WMV files.
So I see 2 ways here:
Which one is more suitable?
@nevdokimof Not sure you know it yet, pencil2d comes bundled with a ffmpeg executable. Please have a look at movieexporter.cpp
. And also you can find some uncompleted debris about importing video in win32.cpp
@chchwy Oh, ok, it became much easier now, thanks
Issue Summary
This is a request to implement direct video import into Pencil2D with support for formats like: AVI, MP4, MKV, OGV
Video import is a quality of life feature that can be used for reference (e.g self-shot video for acting analysis purposes) or rotoscopying actions (for further visual reference on this technique look for modern movies like "Waking Life" or "A Scanner Darkly").
Considerations This implementation could be done by converting the relevant video to an image sequence using FFMPEG and then importing it into a dedicated bitmap layer.
We could also consider creating a new type of layer (video layer) that would reference the video file externally instead of copying it inside the pencil2d compressed project folder, as the possibility of having bigger (and uncompressed) video files could lead to longer saving files and possible corruption of the PCLX data. This would also allow for a quicker cache / playback of the video inside Pencil2D, pretty much like your own video player inside but with the purpose describe above.