热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

转换MKV到MP4与所有流(字幕)和水印-FFMPEG-ConvertMKVtoMP4withallstreams(subtitles)andwatermark

IspentfewhoursresearchingandstillhaveproblemIwanttoconvert.mkvfileto.mp4withwat

I spent few hours researching and still have problem... I want to convert .mkv file to .mp4 with watermark and subtitles (from mkv).

我花了几个小时研究,仍然有问题……我想将.mkv文件转换为.mp4,带有水印和字幕(来自mkv)。

I tried few commands but always error or success with watermark without subtitles. Here are some commands I tried (not all):

我尝试过一些命令,但在没有字幕的情况下,水印总是出错或成功。以下是我试过的一些命令(不是全部):

Partial Success - some files are converted with subtitles, but I have 153 files that are converted without subtitles... (both from .mkv to .mp4):

部分成功——有些文件是用字幕转换的,但是我有153个没有字幕的文件。(由.mkv至.mp4):

ffmpeg -i 025.mkv -vf "movie=logovideo2.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10,subtitles=025.mkv [out]" 25.mp4

ffmpeg -i 001.mkv -i logovideo2.png -filter_complex "[0:v][1:v]overlay=0:0,subtitles=001.mkv[out]" -map "[out]" -map 0:a -c:s ass 001.mp4

Fail - command with error:

失败-错误命令:

ffmpeg -i 001.mkv -i logovideo2.png -filter_complex "[0:v][1:v]overlay=0:0[out]" -map "[out]" -map 0:a -map 0:s -c:s ass 001.mp4

CODE (with error):

代码(错误):

ffmpeg version N-81036-g2b14204 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
  configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libass
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 50.100 / 57. 50.100
  libavformat    57. 42.100 / 57. 42.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from '001.mkv':
  Metadata:
    title           : DB
    encoder         : libebml v1.2.1 + libmatroska v1.1.1
    creation_time   : 2011-09-15 16:44:37
  Duration: 00:24:39.37, start: 0.000000, bitrate: 1429 kb/s
    Stream #0:0(jpn): Audio: vorbis, 48000 Hz, stereo, fltp (default)
    Stream #0:1: Video: h264 (High), yuv420p, 720x540 [SAR 1:1 DAR 4:3], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:2(pol): Subtitle: ass (default)
    Metadata:
      title           : Grupa
Input #1, png_pipe, from 'logovideo2.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 235x50 [SAR 2835:2835 DAR 47:10], 25 tbr, 25 tbn, 25 tbc
File '001.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x43c7a80] using SAR=1/1
[libx264 @ 0x43c7a80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x43c7a80] profile High, level 3.0
[libx264 @ 0x43c7a80] 264 - core 148 r2 3f5ed56 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzOne=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
**[mp4 @ 0x442c9e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 2 times
[mp4 @ 0x442c9e0] Could not find tag for codec ass in stream #2, codec not currently supported in container**
Output #0, mp4, to '001.mp4':
  Metadata:
    title           : DB
    encoder         : Lavf57.42.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x540 [SAR 1:1 DAR 4:3], q=-1--1, 23.98 fps, 24k tbn, 23.98 tbc (default)
    Metadata:
      encoder         : Lavc57.50.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(jpn): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc57.50.100 aac
    Stream #0:2(pol): Subtitle: ass (default)
    Metadata:
      title           : Grupa
      encoder         : Lavc57.50.100 ass
Stream mapping:
  Stream #0:1 (h264) -> overlay:main (graph 0)
  Stream #1:0 (png) -> overlay:overlay (graph 0)
  overlay (graph 0) -> Stream #0:0 (libx264)
  Stream #0:0 -> #0:1 (vorbis (native) -> aac (native))
  Stream #0:2 -> #0:2 (ass (ssa) -> ass (native))
**Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument**
[aac @ 0x43bf600] Qavg: -nan

1 个解决方案

#1


0  

Command ffmpeg -i 001.mkv -i logovideo2.png -filter_complex "[0:v][1:v]overlay=0:0,subtitles=001.mkv[out]" -map "[out]" -map 0:a 001.mp4

001年ffmpeg命令我。mkv -我logovideo2。png -filter_complex”(0 v):[1:v]覆盖= 0时,字幕= 001。mkv[out]" -map "[out] -map 0: 001.mp4

Doesn't has subtitles... here's output:

没有字幕…输出:

ffmpeg version N-81036-g2b14204 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
  configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libass
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 50.100 / 57. 50.100
  libavformat    57. 42.100 / 57. 42.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from '001.mkv':
  Metadata:
    title           : Dragon Ball #1
    encoder         : libebml v1.2.1 + libmatroska v1.1.1
    creation_time   : 2011-09-15 16:44:37
  Duration: 00:24:39.37, start: 0.000000, bitrate: 1429 kb/s
    Stream #0:0(jpn): Audio: vorbis, 48000 Hz, stereo, fltp (default)
    Stream #0:1: Video: h264 (High), yuv420p, 720x540 [SAR 1:1 DAR 4:3], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:2(pol): Subtitle: ass (default)
    Metadata:
      title           : Grupa
Input #1, png_pipe, from 'logovideo2.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 235x50 [SAR 2835:2835 DAR 47:10], 25 tbr, 25 tbn, 25 tbc
[Parsed_subtitles_1 @ 0x459aaa0] Shaper: FriBidi 0.19.4 (SIMPLE) HarfBuzz-ng 0.9.36 (COMPLEX)
[Parsed_subtitles_1 @ 0x459aaa0] Using font provider fontconfig
File '001_Dragon_Ball_NapisyPL.mp4' already exists. Overwrite ? [y/N] y
[Parsed_subtitles_1 @ 0x4542f80] Shaper: FriBidi 0.19.4 (SIMPLE) HarfBuzz-ng 0.9.36 (COMPLEX)
[Parsed_subtitles_1 @ 0x4542f80] Using font provider fontconfig
[libx264 @ 0x44fe7a0] using SAR=1/1
[libx264 @ 0x44fe7a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x44fe7a0] profile High, level 3.0
[libx264 @ 0x44fe7a0] 264 - core 148 r2 3f5ed56 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzOne=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x453ad80] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, mp4, to '001.mp4':
  Metadata:
    title           : Dragon Ball #1
    encoder         : Lavf57.42.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x540 [SAR 1:1 DAR 4:3], q=-1--1, 23.98 fps, 24k tbn, 23.98 tbc (default)
    Metadata:
      encoder         : Lavc57.50.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(jpn): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc57.50.100 aac
Stream mapping:
  Stream #0:1 (h264) -> overlay:main (graph 0)
  Stream #1:0 (png) -> overlay:overlay (graph 0)
  subtitles (graph 0) -> Stream #0:0 (libx264)
  Stream #0:0 -> #0:1 (vorbis (native) -> aac (native))
Press [q] to stop, [?] for help
frame=34743 fps=108 q=-1.0 Lsize=  150041kB time=00:24:39.38 bitrate= 830.8kbits/s speed=4.59x    
video:125218kB audio:23557kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.851010%
[libx264 @ 0x44fe7a0] frame I:340   Avg QP:19.82  size: 38155
[libx264 @ 0x44fe7a0] frame P:13109 Avg QP:22.20  size:  6213
[libx264 @ 0x44fe7a0] frame B:21294 Avg QP:25.43  size:  1588
[libx264 @ 0x44fe7a0] consecutive B-frames: 14.3%  9.7%  7.2% 68.9%
[libx264 @ 0x44fe7a0] mb I  I16..4:  4.2% 61.7% 34.0%
[libx264 @ 0x44fe7a0] mb P  I16..4:  1.9%  7.1%  2.0%  P16..4: 38.2% 12.2%  7.9%  0.0%  0.0%    skip:30.5%
[libx264 @ 0x44fe7a0] mb B  I16..4:  0.2%  0.8%  0.3%  B16..8: 34.2%  2.9%  0.5%  direct: 1.4%  skip:59.6%  L0:45.0% L1:52.1% BI: 2.9%
[libx264 @ 0x44fe7a0] 8x8 transform intra:63.3% inter:77.4%
[libx264 @ 0x44fe7a0] coded y,uvDC,uvAC intra: 55.9% 74.8% 36.6% inter: 10.9% 18.1% 1.0%
[libx264 @ 0x44fe7a0] i16 v,h,dc,p: 39% 24% 13% 24%
[libx264 @ 0x44fe7a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 17% 27%  5%  5%  6%  5%  5%  6%
[libx264 @ 0x44fe7a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 20% 14%  6%  7%  8%  6%  6%  5%
[libx264 @ 0x44fe7a0] i8c dc,h,v,p: 48% 24% 22%  6%
[libx264 @ 0x44fe7a0] Weighted P-Frames: Y:5.3% UV:1.0%
[libx264 @ 0x44fe7a0] ref P L0: 65.0% 13.3% 15.4%  6.1%  0.3%
[libx264 @ 0x44fe7a0] ref B L0: 89.1%  8.4%  2.5%
[libx264 @ 0x44fe7a0] ref B L1: 97.2%  2.8%
[libx264 @ 0x44fe7a0] kb/s:707.89
[aac @ 0x45939e0] Qavg: 654.550

推荐阅读
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • 使用C++编写程序实现增加或删除桌面的右键列表项
    本文介绍了使用C++编写程序实现增加或删除桌面的右键列表项的方法。首先通过操作注册表来实现增加或删除右键列表项的目的,然后使用管理注册表的函数来编写程序。文章详细介绍了使用的五种函数:RegCreateKey、RegSetValueEx、RegOpenKeyEx、RegDeleteKey和RegCloseKey,并给出了增加一项的函数写法。通过本文的方法,可以方便地自定义桌面的右键列表项。 ... [详细]
  • tcpdump 4.5.1 crash 深入分析
    tcpdump 4.5.1 crash 深入分析 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 本文讨论了使用差分约束系统求解House Man跳跃问题的思路与方法。给定一组不同高度,要求从最低点跳跃到最高点,每次跳跃的距离不超过D,并且不能改变给定的顺序。通过建立差分约束系统,将问题转化为图的建立和查询距离的问题。文章详细介绍了建立约束条件的方法,并使用SPFA算法判环并输出结果。同时还讨论了建边方向和跳跃顺序的关系。 ... [详细]
  • 解决VS写C#项目导入MySQL数据源报错“You have a usable connection already”问题的正确方法
    本文介绍了在VS写C#项目导入MySQL数据源时出现报错“You have a usable connection already”的问题,并给出了正确的解决方法。详细描述了问题的出现情况和报错信息,并提供了解决该问题的步骤和注意事项。 ... [详细]
  • Imtryingtofigureoutawaytogeneratetorrentfilesfromabucket,usingtheAWSSDKforGo.我正 ... [详细]
  • 本文讨论了如何在codeigniter中识别来自angularjs的请求,并提供了两种方法的代码示例。作者尝试了$this->input->is_ajax_request()和自定义函数is_ajax(),但都没有成功。最后,作者展示了一个ajax请求的示例代码。 ... [详细]
  • REVERT权限切换的操作步骤和注意事项
    本文介绍了在SQL Server中进行REVERT权限切换的操作步骤和注意事项。首先登录到SQL Server,其中包括一个具有很小权限的普通用户和一个系统管理员角色中的成员。然后通过添加Windows登录到SQL Server,并将其添加到AdventureWorks数据库中的用户列表中。最后通过REVERT命令切换权限。在操作过程中需要注意的是,确保登录名和数据库名的正确性,并遵循安全措施,以防止权限泄露和数据损坏。 ... [详细]
  • Iamtryingtocreateanarrayofstructinstanceslikethis:我试图创建一个这样的struct实例数组:letinstallers: ... [详细]
  • 本文介绍了在RHEL 7中的系统日志管理和网络管理。系统日志管理包括rsyslog和systemd-journal两种日志服务,分别介绍了它们的特点、配置文件和日志查询方式。网络管理主要介绍了使用nmcli命令查看和配置网络接口的方法,包括查看网卡信息、添加、修改和删除配置文件等操作。 ... [详细]
  • 本文介绍了Java调用Windows下某些程序的方法,包括调用可执行程序和批处理命令。针对Java不支持直接调用批处理文件的问题,提供了一种将批处理文件转换为可执行文件的解决方案。介绍了使用Quick Batch File Compiler将批处理脚本编译为EXE文件,并通过Java调用可执行文件的方法。详细介绍了编译和反编译的步骤,以及调用方法的示例代码。 ... [详细]
author-avatar
阿克苏的风格
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有