Como usar corretamente o ffmpeg para converter mkv em mp4 para uso com o navegador Xbox One Edge?

Como usar corretamente o ffmpeg para converter mkv em mp4 para uso com o navegador Xbox One Edge?

Tenho um servidor com filmes/programas adicionados e convertidos automaticamente. O problema é que a MAIORIA dos arquivos que iniciam como mkv não funcionam no Xbox (reproduzidos especificamente no navegador Edge, no meu site). Eu realmente não sei muito sobre conversão de arquivos, então depois de tentar todas as combinações que encontrei no Google, não sei o que fazer.

O que posso fazer para que todos funcionem?

Para começar, como você pode imaginar, é muito difícil pesquisar qualquer coisa que contenha a palavra-chave Xboxe obter informações úteis. Mas encontrei esta postagem que parece mostrar os tipos de arquivos suportados. Não sei se o edge tem requisitos ligeiramente diferentes ou não: https://www.ign.com/wikis/xbox-one/Supported_File_Types

Um dos tipos de arquivo listados é mpeg 4 h264 aacaquele para o qual estou tentando converter meus filmes e ainda não reproduzo.

Alguns comandos que tentei:

  < /dev/null ffmpeg -n -i "$i" -c:v libx264 -c:a aac -movflags +faststart -vf format=yuv420p "${name}.mp4" -hide_banner;

  < /dev/null ffmpeg -i "$i" -f mp4 -vcodec libx264 -preset fast -profile:v main -c:a aac "${name}.mp4" -hide_banner;

  ffmpeg -i "$i" -f mp4 -vcodec libx264 -preset fast -profile:v main -c:a aac "${name}.mp4" -hide_banner;

  ffmpeg -i "$i" -f mp4 -vcodec libx264 -preset fast -profile:v main -c:v libx264 -c:a aac "${name}.mp4" -hide_banner;

  ffmpeg -i "$i" -codec copy "${name}.mp4";

E mais...

Informações do arquivo esperançosamente úteis: MKV:

ffprobe -loglevel error -show_entries stream=codec_name -of default=nw=1 /var/www/html/uploads/Videos/TV/'Silicon Valley'/'Season 1'/S01E01*.mkv; 
codec_name=h264
codec_name=dts

Não funciona MP4 convertido:

ffprobe -loglevel error -show_entries stream=codec_name -of default=nw=1 /var/www/html/uploads/Videos/TV/'Silicon Valley'/'Season 1'/S01E01*.mp4;                    codec_name=h264
codec_name=aac
codec_name=bin_data

MP4 funcionando:

ffprobe -loglevel error -show_entries stream=codec_name -of default=nw=1 /var/www/html/uploads/Videos/TV/'Rick and Morty'/'Season 4'/*S04E03*.mp4;
codec_name=h264
codec_name=aac

A única diferença que posso dizer até agora é o codec bin-data. Mas não sei por que está em um e não no outro.

Log de conversão em mkv-mp4 que não funciona:

# for i in /var/www/html/uploads/Videos/TV/'Silicon Valley'/'Season 1'/S01E01*.mkv;
>   do name=$(echo "${i//.mkv/}");
>   echo "$name";
>   < /dev/null ffmpeg -n -i "$i" -c:v libx264 -c:a aac -movflags +faststart -vf format=yuv420p "${name}.mp4" -hide_banner;
> done
/var/www/html/uploads/Videos/TV/Silicon Valley/Season 1/S01E01 - Minimum Viable Product Bluray-1080p
Input #0, matroska,webm, from '/var/www/html/uploads/Videos/TV/Silicon Valley/Season 1/S01E01 - Minimum Viable Product Bluray-1080p.mkv':
  Metadata:
    encoder         : libebml v1.3.0 + libmatroska v1.4.0
    creation_time   : 2015-03-13T05:58:12.000000Z
  Duration: 00:29:21.39, start: 0.000000, bitrate: 10636 kb/s
    Chapter #0:0: start 0.000000, end 182.432000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 182.432000, end 504.838000
    Metadata:
      title           : 00:03:02.432
    Chapter #0:2: start 504.838000, end 913.329000
    Metadata:
      title           : 00:08:24.838
    Chapter #0:3: start 913.329000, end 1236.110000
    Metadata:
      title           : 00:15:13.329
    Chapter #0:4: start 1236.110000, end 1691.523000
    Metadata:
      title           : 00:20:36.110
    Chapter #0:5: start 1691.523000, end 1761.387000
    Metadata:
      title           : 00:28:11.523
    Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (dts (dca) -> aac (native))
Press [q] to stop, [?] for help
[aac @ 0x561f95f4b5c0] Using a PCE to encode channel layout "5.1(side)"
[libx264 @ 0x561f95e9fbc0] using SAR=1/1
[libx264 @ 0x561f95e9fbc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x561f95e9fbc0] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x561f95e9fbc0] 264 - core 157 r2980 34c06d1 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=34 lookahead_threads=5 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
Output #0, mp4, to '/var/www/html/uploads/Videos/TV/Silicon Valley/Season 1/S01E01 - Minimum Viable Product Bluray-1080p.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Chapter #0:0: start 0.000000, end 182.432000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 182.432000, end 504.838000
    Metadata:
      title           : 00:03:02.432
    Chapter #0:2: start 504.838000, end 913.329000
    Metadata:
      title           : 00:08:24.838
    Chapter #0:3: start 913.329000, end 1236.110000
    Metadata:
      title           : 00:15:13.329
    Chapter #0:4: start 1236.110000, end 1691.523000
    Metadata:
      title           : 00:20:36.110
    Chapter #0:5: start 1691.523000, end 1761.387000
    Metadata:
      title           : 00:28:11.523
    Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 23.98 fps, 13978 tbn, 23.98 tbc (default)
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1(side), fltp, 394 kb/s (default)
    Metadata:
      encoder         : Lavc58.54.100 aac
frame=   41 fps=0.0 q=0.0 size=       0kB time=00:00:02.34 bitrate=   0.7kbits/s speed=4.68x frame=   58 fps= 58 q=0.0 size=       0kB time=00:00:03.05 bitrate=   0.5kbits/s speed=3.05x frame=   74 fps= 47 q=0.0 size=       0kB time=00:00:03.73
 --SNIPPED TOO LONG--
 bitrate=3985.6kbits/s speed=2.25xframe=42207 fps= 54 q=28.0 size=  856576kB time=00:29:21.10 bitrate=3984.5kbits/s speed=2.25x[matroska,webm @ 0x561f95e78580] File extends beyond end of segment.
frame=42224 fps= 54 q=28.0 size=  856832kB time=00:29:21.34 bitrate=3985.1kbits/s speed=2.25x[mp4 @ 0x561f95ea1040] Starting second pass: moving the moov atom to the beginning of the file
frame=42230 fps= 54 q=-1.0 Lsize=  863321kB time=00:29:21.38 bitrate=4015.2kbits/s speed=2.24x
video:776974kB audio:84842kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.174605%
[libx264 @ 0x561f95e9fbc0] frame I:466   Avg QP:19.32  size:207180
[libx264 @ 0x561f95e9fbc0] frame P:11673 Avg QP:21.92  size: 35007
[libx264 @ 0x561f95e9fbc0] frame B:30091 Avg QP:23.52  size:  9652
[libx264 @ 0x561f95e9fbc0] consecutive B-frames:  2.8%  4.8%  5.2% 87.2%
[libx264 @ 0x561f95e9fbc0] mb I  I16..4:  9.2% 89.1%  1.7%
[libx264 @ 0x561f95e9fbc0] mb P  I16..4:  2.7%  8.7%  0.5%  P16..4: 49.0%  9.5%  7.1%  0.0%  0.0%    skip:22.6%
[libx264 @ 0x561f95e9fbc0] mb B  I16..4:  0.2%  1.0%  0.0%  B16..8: 37.4%  1.6%  0.2%  direct: 2.4%  skip:57.2%  L0:44.7% L1:52.2% BI: 3.0%
[libx264 @ 0x561f95e9fbc0] 8x8 transform intra:77.9% inter:91.0%
[libx264 @ 0x561f95e9fbc0] coded y,uvDC,uvAC intra: 56.8% 83.6% 51.8% inter: 9.8% 25.7% 2.8%
[libx264 @ 0x561f95e9fbc0] i16 v,h,dc,p: 41% 19% 10% 31%
[libx264 @ 0x561f95e9fbc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 14% 35%  4%  5%  6%  5%  6%  5%
[libx264 @ 0x561f95e9fbc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 16% 13%  5%  9%  9%  8%  6%  5%
[libx264 @ 0x561f95e9fbc0] i8c dc,h,v,p: 59% 16% 19%  6%
[libx264 @ 0x561f95e9fbc0] Weighted P-Frames: Y:1.1% UV:0.7%
[libx264 @ 0x561f95e9fbc0] ref P L0: 58.5% 11.4% 22.6%  7.4%  0.0%
[libx264 @ 0x561f95e9fbc0] ref B L0: 86.8% 10.7%  2.5%
[libx264 @ 0x561f95e9fbc0] ref B L1: 95.2%  4.8%
[libx264 @ 0x561f95e9fbc0] kb/s:3613.70
[aac @ 0x561f95f4b5c0] Qavg: 284.855

Já pensei que tinha acontecido isso muitas vezes, em que consegui fazer com que um vídeo entre 60 funcionasse, apenas para perceber que estava errado. Se houver alguma outra maneira de obter registros melhores, me avise e eu o farei.

Responder1

Tente adicionar isso

ffmpeg.exe -i "NOME DO ARQUIVO.mkv" -target ntsc-vcd "NOME DO ARQUIVO.MP4"

sem os extras...

Responder2

Convertendo mkv para mp4 com ffmpeg

https://gist.github.com/jamesmacwhite/58aebfe4a82bb8d645a797a1ba975132

"basta copiar o fluxo de vídeo e áudio existente como está em um novo contêiner, sem graça"

Leia também o(s) comentário(s)

--Por: nickdagamer400 comentado em 19 de fevereiro de 2018

(Sobre o arquivo Batch (.bat) no Windows)

para /R %%f IN (*.mkv) DO ffmpeg -i "%%f" -c copiar "%%~nf.mp4"

Responder3

Primeiro, eu recomendaria obter mediainfo para comparar arquivos funcionais/não funcionais, para que você possa ver os detalhes da mídia.

> mediainfo S01E08.Much\ More.mp4 
General
Complete name                            : S01E08.Much More.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 634 MiB
Duration                                 : 59 min 38 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 487 kb/s
Movie name                               : S01E08.Much More
Writing application                      : Lavf58.35.100
Comment                                  : -filter_complex [0:0]fps=fps=24000/1001[vOut];[0:1]loudnorm=linear=true:measured_I=-22.63:measured_tp=-3.77:measured_LRA=19.00:measured_thresh=-34.34[aOut] -c:v libx264 -crf 21 -preset medium -tune film -maxrate 8m -bufsize 2m -c:a libfdk_aac -b:a 128k -ar 48k -c:s mov_text -metadata:s:s:0 language=eng
LongDescription                          : No info

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 59 min 38 s
Bit rate                                 : 1 353 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.061
Stream size                              : 577 MiB (91%)
Writing library                          : x264 core 158
Encoding settings                        : cabac=1 / ref=3 / deblock=1:-1:-1 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=22 / lookahead_threads=3 / 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
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 59 min 38 s
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 6 channels
Channel layout                           : C L R Ls Rs LFE
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 54.6 MiB (9%)
Default                                  : Yes
Alternate group                          : 1

Text #1
ID                                       : 3
Format                                   : Timed Text
Muxing mode                              : sbtl
Codec ID                                 : tx3g
Duration                                 : 58 min 38 s
Bit rate mode                            : Variable
Bit rate                                 : 44 b/s
Stream size                              : 19.1 KiB (0%)
Language                                 : English
Default                                  : Yes
Forced                                   : No
Alternate group                          : 3

Text #2
ID                                       : 4
Format                                   : Timed Text
Muxing mode                              : sbtl
Codec ID                                 : tx3g
Duration                                 : 58 min 38 s
Bit rate mode                            : Variable
Bit rate                                 : 56 b/s
Stream size                              : 24.0 KiB (0%)
Title                                    : SDH
Language                                 : English
Default                                  : No
Forced                                   : No
Alternate group                          : 3

Compare os codecs e perfis usados ​​para arquivos de trabalho.

Verifique os fluxos do arquivo de entrada e mapeie apenas os fluxos que realmente lhe interessam (Vídeo/Áudio (no seu idioma)/Legendas?)

> ffprobe S01E08.Much\ More.mp4 2>&1 |grep Stream
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1353 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 128 kb/s (default)
    Stream #0:2(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
    Stream #0:3(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s

Em seguida, crie seu comando ffmpeg:

> ffmpeg -y -i "S01E08.Much More.mkv" \
  -c:v libx264 -crf 21 -preset medium -tune film -maxrate 8m -bufsize 2m -map 0:0 \
  -c:a libfdk_aac -b:a 128k -ar 48k -map 0:1 \
  -c:s mov_text -metadata:s:s:0 language=eng -map 0:3 \
  "S01E08.Much More.mp4"

Não tenho certeza se você precisa de -movflags ou -faststart, eles são usados ​​para streaming de vídeos para começar a reproduzir durante a transferência.

informação relacionada