Giter Club home page Giter Club logo

Comments (11)

oxydron avatar oxydron commented on May 16, 2024 7

Until today we don't have a simple documentation for outputdict from FFmpegWriter. Is one of the most important things on this lib. How can I define how to write an video? Nowhere with explanations? A single example?

from scikit-video.

beyondmetis avatar beyondmetis commented on May 16, 2024

Ah good catch. I will have to update the documentation about FFmpegWriter. I'm in the process of writing more example-based documentation. You can see the current progress (with dict examples for I/O) here:

http://www.scikit-video.org/dev/examples.html

from scikit-video.

PetreanuAndi avatar PetreanuAndi commented on May 16, 2024

Hey guys. Check this code :

from skvideo.io import VideoWriter
import numpy
writer = VideoWriter(filename, frameSize=(w, h))
writer.open()
while True:
.......
writer.write("some random video frame- from iteration process")
.......
writer.release()

It does output a video file, however the quality of it is very poor beyond the first keyframe. Your skvideo documentation states that FFmpegWriter should be used for more customisation of parameters, however that does not exist.

http://www.scikit-video.org/dev/examples.html this link does not provide an example of video file written to disk frame by frame.

What's wrong with this thread? Why is there such bad quality of output? Why is there such bad quality of documentation?

Why is there no proper way to write video in Python, in 2016? :)

from scikit-video.

beyondmetis avatar beyondmetis commented on May 16, 2024

Ah! I did forget to add an example on the webpage regarding high-quality h264 encodes.

If you want to output a good quality video (frame by frame), you can start from the below example which uses the libx264 codec with bitrate set to 30MBps which encodes random noise:

import skvideo.io
import skvideo.measure
import numpy as np


outputfile = "test.mp4"
outputdata = np.random.random(size=(30, 480, 640, 3)) * 255
outputdata = outputdata.astype(np.uint8)

# start the FFmpeg writing subprocess with following parameters
writer = skvideo.io.FFmpegWriter(outputfile, outputdict={
    '-vcodec': 'libx264', '-b': '30000000'
})

for i in range(30):
    writer.writeFrame(outputdata[i])
writer.close()

inputdata = skvideo.io.vread(outputfile)

# test each frame's SSIM score
mSSIM = 0
for i in range(30):
    mSSIM += skvideo.measure.ssim(np.mean(inputdata[i], axis=2), np.mean(outputdata[i], axis=2))
mSSIM /= 30.0

print mSSIM

You can play with the coding parameters and see how it is reflected in the measured mean SSIM value. BTW, the flags in the outputdict are passed directly to FFmpeg through the CLI.

Perhaps there is a better, more generic way to write high quality video as h264, rather than explicitly using a dictionary of parameters. I think the current approach is flexible although currently poorly documented.

from scikit-video.

beyondmetis avatar beyondmetis commented on May 16, 2024

I have now added this to the dev branch of the website

from scikit-video.

TobiasWeis avatar TobiasWeis commented on May 16, 2024

It would be awesome if you could state somewhere whether it's possible to grab frames from a webcam? Have not been able to find any documentation on that in the latest release, and had no luck with ffmpegreader so far..

from scikit-video.

beyondmetis avatar beyondmetis commented on May 16, 2024

from scikit-video.

dukleryoni avatar dukleryoni commented on May 16, 2024

Hi,
Thanks for the nice package!
I am working with skvideo and trying to output a video but while the code above (high quality video) runs and produces a video file, the created video is not being able to be read by Window media player/ seems to not have any frames. Do you know what is causing the problem and how could I fix this?

from scikit-video.

beyondmetis avatar beyondmetis commented on May 16, 2024

Is the file size larger than 0? You can try playing it with VLC

from scikit-video.

dukleryoni avatar dukleryoni commented on May 16, 2024

Hi, I downloaded VLC and it works perfectly! Thank you.

from scikit-video.

beyondmetis avatar beyondmetis commented on May 16, 2024

Examples: http://www.scikit-video.org/stable/examples.html

If you want to go beyond this, you can check out the documentation for ffmpeg's output flags.

from scikit-video.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.