You are not logged in.

#1 2014-07-13 18:58:40

thedude0
Member
Registered: 2006-12-28
Posts: 8

[Solved] Trying to re-encode video with mpv

Trying to re-encode a video so I can play it on my TV without having to use plex or some other transcoding streaming thing. So I run the following:

mkfifo pipe.y4m
x264 pipe.y4m --profile high --preset slow --tune animation --level 4.1 --vbv-bufsize 62500 --vbv-maxrate 62500 --me umh --threads auto --output output.264 & mpv input.mkv --vd-lavc-o=strict=-1 -no-audio -untimed --vid=1 --sid=2 -sub-ass -ofps 23.976 -o pipe.y4m

mpv throws an error though:

[ffmpeg] yuv4mpegpipe: 'yuv420p10le' is not a official yuv4mpegpipe pixel format. Use '-strict -1' to encode to this pixel format.

However, that's exactly what I've  specified in the command: --vd-lavc-o=strict=-1.  I've tried both the stable and git versions of mpv but it keeps giving me this message. How do I fix this? I assume I'm doing the right thing here.

Last edited by thedude0 (2014-07-19 23:29:00)

Offline

#2 2014-07-14 18:03:22

teckk
Member
Registered: 2013-02-21
Posts: 575

Re: [Solved] Trying to re-encode video with mpv

If If I understand what you are doing, you're trying to send input.mkv to a named pipe, use the named pipe for an input for x264, output to output.264

1. mkfifo pipe.y4m
2. mpv input.mkv --vd-lavc-o=strict=-1 ..... -o pipe.y4m
3. x264 pipe.y4m --profile high --preset slow....--output output.264

Why are you doing all that? If you want to re encode a video then

ffmpeg -i input.mkv (options) output.mp4

Then play output.mp4

Why does it have to stream to a pipe then be read with another program from the pipe?
Are you trying to stream-reencode-play on the fly?

I don't know what you are doing. You have a HTPC connected to a TV? Or does this TV have the ability to play a video of certain format?

Give a lot more info on what you are doing.

without having to use plex or some other transcoding streaming thing.

Stream from where to where? How is the video getting to your TV?

Offline

#3 2014-07-14 19:01:29

thedude0
Member
Registered: 2006-12-28
Posts: 8

Re: [Solved] Trying to re-encode video with mpv

The problem is my smart TV not taking 10-bit encoded video material. I want to play that back directly, without resorting to some streaming transcoder like Plex or anything that uses DLNA. I need level 4.1, high profile material on a USB stick since that's what my TV's built-in media player takes. The TV also needs to display ASS subtitles. It can't, so they need to be hardcoded.

The solution I found sets up a named pipe, outputs mpv's stream with the ASS subtitiles to it, then letting x264 take it and encode it on the fly. From what I've read, there is no other way for x264 to take input. If I didn't use a pipe and a regular file instead, I would have a huge lossless file in between these steps.

So that's why I'm trying to do this. If I understand correctly, ffmpeg doesn't just take this source format: it needs the -strict -1 option set. When I pass that to mpv it does nothing with it. It completely ignores it.

I'll try to use ffmpeg directly. I can see that it supports ASS hardcoding, so let me try it out.

Offline

#4 2014-07-14 20:08:39

teckk
Member
Registered: 2013-02-21
Posts: 575

Re: [Solved] Trying to re-encode video with mpv

I see, I did a little reading on that.
http://forum.doom9.org/showthread.php?t=170010
How about yuv422p

mpv....| ffmpeg -f rawvideo -pix_fmt yuv422p10le...

I just did

cat file.mp4 | ffmpeg -i pipe:0 -f rawvideo -pix_fmt yuv422p10le -s 400x300 -r 23.98 -c:v libx264 -b:v 2500k out.mp4

And that worked ok.

So you may try something like.

mkfifo pipe.y4m
mpv.......-o pipe.y4m | ffmpeg -i pipe:0 -f rawvideo -pix_fmt yuv422p10le..(options)...output.mp4

Get that working and ffmpeg can overlay subs ok.

Offline

#5 2014-07-19 23:27:36

thedude0
Member
Registered: 2006-12-28
Posts: 8

Re: [Solved] Trying to re-encode video with mpv

Thanks for the input teckk. Solved this problem by using the ffmpeg mpv ships with, through mpv exclusively - no pipes.

I'm testing my encoding options, but for now, and for the curious Googler finding this thread, here's my solution.

First off all, I've made a profile in ~/.mpv/config with some common encoding options. Here's an example:

[1080p]
ovc = libx264
ovcopts-add = profile=high,preset=slow,tune=animation,level=4.1
ovcopts-add = crf=21
oac = aac
oacopts-add = b=96k

It's named 1080p and can be referred to when running mpv. It has some rather non-specific, stock options for encoding animation, but it's a start. Moreover, the result should be compatible with most hardware available.

When encoding with ffmpeg through mpv, it seems to be recommended to specify a framerate. It can figure out the input resolution itself though. Then, to start things, run the following:

$ mpv input.mkv -o output.mkv -profile 1080p -ofps 24000/1001

Either way, I'm going to tinker with my encoding options. Thanks again, and marked solved.

Offline

Board footer

Powered by FluxBB