>您使用什么类型的YUV像素格式?最常见的格式是YUV4:2:0平面8位(YUV420p)。您可以键入ffmpeg -pix_fmts以获取所有可用格式的列表。
>什么是帧率?在我的例子中,我将使用-r 25 fps。
>你想使用什么编码器? libx264(H.264)编码器是一种伟大的无损压缩。
>你的相框是什么?在我的例子中,我将使用-s 1920×1080

然后我们得到这个命令来做你的压缩。

ffmpeg -f rawvideo -vcodec rawvideo -s 1920×1080 -r 25 -pix_fmt yuv420p -i inputfile.yuv -c:v libx264 -preset ultrafast -qp 0 output.mp4

在转化netflix_4k的视频时命令:ffmpeg -f rawvideo -vcodec rawvideo -s 704*576 -pix_fmt yuv420p -i /home/nkh/Temp/nkh/data_beihang/city_4cif.yuv -c:v libx264 -preset ultrafast -qp 0 /home/nkh/Temp2018/nkh/data_0/city_4cif.mp4

不行,故采用以下:

将 y4m 格式的图像序列转换为 4:2:0 的 YUV 图像序列:

ffmpeg -f yuv4mpegpipe -i test.y4m -pix_fmt yuv420p test.yuv

对所有其他参数的一点解释:

>使用-f rawvideo将输入格式设置为原始视频容器
>使用-vcodec rawvideo将输入文件设置为未压缩
>使用-i inputfile.yuv设置输入文件
>使用-c:v libx264,您设置编码器将视频编码为libx264。
> -preset ultrafast设置只是加速压缩,所以你的文件大小会比设置为veryslow更大。
>使用-qp 0可以设置最大质量。 0是最好的,51是我们的例子中最差的质量。
>然后output.mp4是你的新容器来存储你的数据。

在Adobe Premiere中完成后,您可以通过反转所有参数将其转换回YUV文件。 FFmpeg识别mp4容器中的内容,因此您不需要为输入提供参数。

ffmpeg -i input.mp4 -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 1920×1080 -r 25 rawvideo.yuv

修改分辨率:

If you need to simply resize your video to a specific size (e.g 320x240), you can use the scale filter in its most basic form:

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

Same works for images too:

ffmpeg -i input.jpg -vf scale=320:240 output_320x240.png

The resulting image will look like this:

As you can see, the aspect ratio is not the same as in the original image, so the image appears stretched. If we'd like to keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1. For example, this command line:

ffmpeg -i input.jpg -vf scale=320:-1 output_320.png

will set the width of the output image to 320 pixels and will calculate the height of the output image according to the aspect ratio of the input image. The resulting image will have a dimension of 320x207 pixels.

7.YUV序列播放

ffplay -f rawvideo -video_size 1920x1080 input.yuv

yuv2mp4的更多相关文章

随机推荐

  1. day17

    包什么是包 包的本质是文件夹为什么使用包 函数可以使得同一个文件中代码结构更清晰 木块(py文件)是以文件形式来组织代码结构 如果文件越来越多管理起来也不方便,所以需要使用文件夹来管理.从文件夹级别来 ...

  2. Python汉诺塔

    import turtle class Stack: def __init__(self): self.items = [] def isEmpty(self): return len(self.it ...

  3. pronaunciation

    5 strong  weak s            d n            t l             th you and I  -> you an dai -> you ...

  4. webpack dllPlugin使用(基于vue-cli webpack模板)

    由于本例单入口时打包的文件体积过大,将其分成多入口. 主要涉及到的几个文件为: /index.html, /webpack.dll.config.js, /build/webpack.base.con ...

  5. Pandas 基础(14) - DatetimeIndex and Resample

    这一小节要介绍两个内容, 一个是 DatetimeIndex 日期索引, 另一个是 Resample, 这是一个函数, 可以通过参数的设置, 来调整数据的查询条件, 从而得到不同的结果. 首先看下关于 ...

  6. day22

    # day22 ## 复习 ```python# 1.内存管理# 引用计数:垃圾回收机制工作原理# -- 引用就 +1 ,释放就 -1 , 当计数为0时,就会被垃圾回收机制回收 # 标记清除:解决循环 ...

  7. Qt551.主窗体Margin

    1.直接拖控件的方式,Margin的设置 不是在 MainWindow中 而是在 MainWindow下面的centralwidget中,如下图: 2. 3. 4. 5.

  8. Java多线程之volatile关键字《一》

    关键字volatile的主要作用是使变量在多个线程间可见. 1.关键字volatile与死循环 如果不是在多继承的情况下,使用继承Thread类和实现Runnable接口在取得程序运行的结果上并没有什 ...

  9. Disable access to Windows Update

    Disable access to Windows Update If this policy setting is enabled, all Windows Update features are ...

  10. 如何运行一个Vue项目

    一开始很多刚入手vue.js的人,会扒GitHub上的开源项目,但是发现不知如何运行GitHub上的开源项目,很尴尬.通过查阅网上教程,成功搭建好项目环境,同时对前段工程化有了朦朦胧胧的认知,因此将环 ...