Problem beim Konvertieren von TS in MP4-Container mit ffmpeg

Ich habe einen Videostream, mit dem ich aufgenommen VLCund als TS-Datei gespeichert habe. Die Codecs in der Datei sind h.264/AAC, daher dachte ich, es wäre trivial ffmpeg, die Datei von einem TS-Container in einen MP4-Container zu konvertieren, damit ich die Datei in QuickTime abspielen kann. Ich habe den folgenden Befehl verwendet:

ffmpeg -i vlc-output.ts -acodec copy -vcodec copy car-free\ tourism.mp4

Alles schien in Ordnung zu sein, aber während die resultierende Datei in QuickTime geöffnet werden kann, springt sie nach dem Abspielen von 1s der Datei zum Anfang zurück und spielt dann nur den Ton ab, wobei das Video schwarz bleibt. Das Video spielt gut in VLC und MPlayerX. Ich kann nicht verstehen, warum QuickTime die Datei nicht abspielt. Die Codecs sehen kompatibel aus und die Dateilänge sieht gut aus. Mache ich etwas falsch? Gibt es zusätzliche Metadaten, die QuickTime benötigt?

Ich vermute irgendwie, dass das Problem an einem Mangel an vollständigen Bitraten-Metadaten liegt, bin aber überfordert.

Danke für jede Hilfe.

Die Ausgabe von ffprobe für beide Dateien lautet wie folgt:

vlc-output.ts

[~/Desktop] 113: ffprobe vlc-output.ts                                                   10:51:13 
ffprobe version 3.3.3 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vlc-output.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    creation_time   : 2015-06-23T20:48:30.000000Z
    playback_requirements: QuickTime 6.0 or greater
    playback_requirements-eng: QuickTime 6.0 or greater
    encoder         : vlc 2.2.1 stream output
    encoder-eng     : vlc 2.2.1 stream output
  Duration: 00:01:50.09, start: 0.000000, bitrate: 1149 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : SoundHandler

Autofreier Tourismus.mp4

[~/Desktop] 114: ffprobe car-free\ tourism.mp4                                           10:51:36 
ffprobe version 3.3.3 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'car-free tourism.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:01:50.09, start: 0.000000, bitrate: 1150 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

Wenn ich die -reportOption beim Ausführen des Rewrap-Befehls verwende, erhalte ich die folgende Protokolldatei:

ffmpeg-20170824-164217.log

ffmpeg started on 2017-08-24 at 16:42:17
Report written to "ffmpeg-20170824-164217.log"
Command line:
ffmpeg -i vlc-output.ts -acodec copy -vcodec copy -report "car-free tourism.mp4"
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Splitting the commandline.
Reading option '-i' ... matched as input url with argument 'vlc-output.ts'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option 'car-free tourism.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url vlc-output.ts.
Successfully parsed a group of options.
Opening an input file: vlc-output.ts.
[NULL @ 0x7f8f8e004200] Opening 'vlc-output.ts' for reading
[file @ 0x7f8f8ce00300] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Processing st: 0, edit list 0 - media time: 0, duration: 109960000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Processing st: 1, edit list 0 - media time: 0, duration: 4854784
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Before avformat_find_stream_info() pos: 76497 bytes read:98304 seeks:0 nb_streams:2
[h264 @ 0x7f8f8e008400] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x7f8f8e008400] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x7f8f8e008400] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x7f8f8e008400] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x7f8f8e008400] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x7f8f8e008400] user data:"x264 - core 118 r2085 8a62835 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=5 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=36 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=50 keyint_min=25 scenecut=0 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=1200 ratetol=1.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 vbv_maxrate=1200 vbv_bufsize=600 nal_hrd=none ip_ratio=1.40 aq=1:1.00"
[h264 @ 0x7f8f8e008400] Reinit context to 640x368, pix_fmt: yuv420p
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] After avformat_find_stream_info() pos: 99278 bytes read:131072 seeks:0 frames:2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vlc-output.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    creation_time   : 2015-06-23T20:48:30.000000Z
    playback_requirements: QuickTime 6.0 or greater
    playback_requirements-eng: QuickTime 6.0 or greater
    encoder         : vlc 2.2.1 stream output
    encoder-eng     : vlc 2.2.1 stream output
  Duration: 00:01:50.09, start: 0.000000, bitrate: 1149 kb/s
    Stream #0:0(eng), 1, 1/1000000: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: output url car-free tourism.mp4.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument copy.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument copy.
Successfully parsed a group of options.
Opening an output file: car-free tourism.mp4.
[file @ 0x7f8f8ce04fe0] Setting default whitelist 'file,crypto'
Successfully opened the file.
Output #0, mp4, to 'car-free tourism.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    encoder         : Lavf57.71.100
    playback_requirements: QuickTime 6.0 or greater
    playback_requirements-eng: QuickTime 6.0 or greater
    Stream #0:0(eng), 0, 1/1000000: Video: h264 (Main) ([33][0][0][0] / 0x0021), yuv420p, 640x360, q=2-31, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng), 0, 1/44100: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
No more output streams to write to, finishing.
frame= 2749 fps=0.0 q=-1.0 Lsize=   15455kB time=00:01:50.04 bitrate=1150.5kbits/s speed= 588x    
video:14120kB audio:1258kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.503515%
Input file #0 (vlc-output.ts):
  Input stream #0:0 (video): 2749 packets read (14459053 bytes); 
  Input stream #0:1 (audio): 4741 packets read (1287842 bytes); 
  Total: 7490 packets (15746895 bytes) demuxed
Output file #0 (car-free tourism.mp4):
  Output stream #0:0 (video): 2749 packets muxed (14459053 bytes); 
  Output stream #0:1 (audio): 4741 packets muxed (1287842 bytes); 
  Total: 7490 packets (15746895 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7f8f8ce050a0] Statistics: 60 seeks, 7583 writeouts
[AVIOContext @ 0x7f8f8ce00480] Statistics: 16617055 bytes read, 17 seeks

Die Videodatei, die ich umzupacken versuche, ist ein STV-Nachrichtenstrom, der in einer m3u8-Datei angegeben ist, die ich mit VLC aufgenommen habe. Eine Kopie davon habe ich hier hinterlegt .

Antworten (1)

Update : Der VLC TS ist fehlerhaft.

Erster Lauf

ffmpeg -i vlc-output.ts -c copy ffmpeg-output.ts

und dann

ffmpeg -i ffmpeg-output.ts -c copy working.mp4

Die Hauptsache, die abfällt, ist die Zeitbasis 1000k tbn.

Versuchen

ffmpeg -i vlc-output.ts -c copy -video_track_timescale 90k car-free\ tourism.mp4
Danke für den Vorschlag, leider hat es das gleiche Ergebnis (außer dass der Videostream sagt 90k tbn:Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Versuchen Sie es dann mit einer niedrigen Zahl, z. B. 600.
Am Ergebnis änderte das nichts. Ich habe jedoch auch festgestellt, dass die -reportOption eine Protokolldatei erzeugt (hatte das noch nie gesehen), also habe ich die Frage mit dem Inhalt dieser Datei aktualisiert, seit Sie mich zum ersten Mal gebeten haben, die Umverpackung mit einem Bericht auszuführen. Vielleicht könnte der Inhalt dieser Datei helfen, herauszufinden, was los ist? Ich schätze Ihre Hilfe sehr, danke.
Oder ein anderer Ansatz: Gibt es eine Möglichkeit für mich, die .ts-Datei zu analysieren und zu bestimmen, wie die Zeitskala sein sollte?
Die Auflösung ändert sich mittendrin. Versuchen ffmpeg -ss 30 -i vlc-output.ts -c copy -video_track_timescale 600 -report car-free\ tourism.mp4Wenn es funktioniert, versuchen Sie es mit niedrigeren ss-Werten, bis es immer noch funktioniert.
Danke nochmal für deine Hilfe. Ich habe das versucht, und kein Glück. Dasselbe Ergebnis, sowohl mit den anfänglichen 0-1s als auch mit dem Zurückspringen zum Anfang, und es wird kein Video angezeigt. Ich habe es auch mit -ss 60und versucht und habe -ss 90genau das gleiche Ergebnis (außer dass das Audio offensichtlich in den 60ern und 90ern beginnt und die Gesamtlänge kürzer ist). Kann ich noch etwas versuchen?
Geben Sie die Quelldatei frei, wenn Sie können.
Danke Mulvya. Ich habe Informationen und einen Link zur Quelldatei am Ende des ursprünglichen Beitrags hinzugefügt ⬆️.
Entschuldigung, ich habe gerade erst bemerkt, dass Sie diese Antwort aktualisiert haben. Vielen Dank, das erste Kopieren in eine neue TS-Datei hat funktioniert! Ich muss mich nicht mit der Zeitbasis herumschlagen, wenn ich Ihrer Anweisung gefolgt bin, in eine neue TS-Datei zu kopieren und dann von dieser auf eine MP4 zu kopieren, funktioniert alles gut. So gut, dass dies endlich richtig archiviert ist, Ihre Hilfe wird sehr geschätzt.