Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on scaling video #6

Closed
freiguy1 opened this issue Feb 2, 2020 · 2 comments
Closed

Question on scaling video #6

freiguy1 opened this issue Feb 2, 2020 · 2 comments

Comments

@freiguy1
Copy link

freiguy1 commented Feb 2, 2020

Hi there. This isn't an actual issue, but more of a question. I hope that's ok.

I'm working on a project to reduce the disk space required by mp4 videos. I was planning on doing this by scaling down the resolution and lowering frames per second. I'm doing this with Rust, and my searching directed me to ffmpeg. This is my first exposure to ffmpeg.

Am I on the right track by using this library in the first place? If not, you can stop reading here and say so.

I found an ffmpeg example about scaling, but I'll be honest, it seems more complicated than I was expecting especially when just using the command line ffmpeg tool can scale with this command:

ffmpeg -i input.avi -vf scale=320:240 output.avi

Can you point me in the right direction for doing these operations (scaling and lowering fps)? Perhaps some pseudo code would be helpful. Thanks!

@colbyn
Copy link
Member

colbyn commented Feb 18, 2020

Yes, use the CLI interface. Especially if you are new to rust, this library isn't idiomatic or safe rust code.

Some time ago when I was a JR dev working on a video processing project, I tried to use FFmpeg VIA the C APIs over some CLI interface, the result was terrible. Furthermore using the CLI interface would have been substantially easier and more robust.

So regarding your question on implementation and my aforementioned mistake. :)

I'd just use std::process::Command (api docs) from the standard library, this will allow you to invoke FFmpeg as a child process using its CLI interface. You can even batch multiple encoding instances in a single invocation or whatever it's called.

Regarding your question on compression, this is a bit more complicated, and I'm not sure about the requirements of your project (also I'm not an expert on video compression, and especially anything related to audio)...

First, I think, you can't really talk about compression in this context without regard for any specific video codec. For instance, whereas JPEG generally refers to a container format and codec, MP4 files may contain an H264/AVC encoded video stream, or something different, such as the newer H265/HEVC video codec, which may make for a substantial difference with regards to quality/file-size tradeoffs. Anyway If you writing such a tool, I'd first consider what video codecs you need to support, not just the container format. Thereafter I'd dive into the more technical aspects on how the given encoder works and it's exposed settings and whatnot, since otherwise you'll probably be using subpar defaults, unknowingly.

Hope this helps.

@freiguy1
Copy link
Author

Thanks much. The CLI it is for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants