lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.39k stars 160 forks source link

transcode-video not respecting --target argument #212

Closed kford closed 6 years ago

kford commented 6 years ago

Hi Don,

I'm trying to transcode several video files to a form factor appropriate for low-storage Android devices. I'm executing...

ford@arrakis ~/Videos % transcode-video --chapters 13 --target 300 /mnt/plex/Movies/Some_Video.mkv

Regardless of the options I pass, it makes videos with an overall bitrate of over 2500Mb/s

Any help would be appreciated.

samhutchins commented 6 years ago

I believe that the default ratecontrol system will exceed the target bitrate to match a minumum quality, you probably want to also pass --abr. abr will still exceed it in places, but the overall bitrate will average out to your target bitrate.

I'd also say that using a target of 300kbps is insanely low, and will result in unwatchable video in most cases.

For smaller encodes I'd recommend using --target small and either --720p or --max-width and --max-height to constrain the output resolution. I'd also suggest using --audio-width all=stereo to avoid encoding a surround sound track

Overall, I think you'd get a command like this:

transcode-video --target small --max-width 854 --max-height 480 --audio-width all=stereo, which would reduce the resolution to fit inside a 16:9 SD frame, and use about 1000kbps to encode the video, and 160kbps to encode the audio.

I hope this helps

lisamelton commented 6 years ago

@kford I'm sorry that you had this problem. But the always-helpful @samhutchins is completely correct about the diagnosis and the cure. (Thanks, Sam!)

One of the reasons I developed the --abr option and its new average bitrate (ABR) ratecontrol implementation is to deliver output at a predictable size. This is something the default ratecontrol system can't do, by design, because it's always trying to deliver a predictable quality, which can cause it to exceed the target bitrate.

So, the target bitrate will be honored when using the --abr option if you also use --target 300. But Sam is correct that a such a target will likely be unwatchable. And that adding --target small to your command line instead is a much safer idea. If your videos have a resolution of 1080p, then also adding --720p to your command line will reduce them further in size.

I hope that helps.

kford commented 6 years ago

Thanks @donmelton and @samhutchins

I was artificially setting it to 300 to see if it would effect a change in output size and bitrate (in the direction I was looking for).. I might be looking for something higher, but only slightly higher. The target output device here is a cell phone with limited storage. I'll play around with sizes and see what I get. Thank you both so much for the help and clarifications.

lisamelton commented 6 years ago

@kford You are very welcome, sir! I'll close this now but feel free to comment again here or open another issue.

kford commented 6 years ago

Thanks, I should have gotten this from your excellent documentation but I was myopically focused on the setting of the target bitrate and not thinking about how other args affect it or the overall design of the tool.

In the end, I found that forcing the bitrate to 300, leveraging the average bitrate (arb) option was good enough for video on a 5" screen and gave me files of about 1/2 the size of --target small with constrained output dimensions.

Thanks again!