[FFmpeg-user] Copying a EIA-608 subtitle stream in an m4v

Dan Smith dansmithx at icloud.com
Fri Mar 27 20:25:00 EET 2020


> On Mar 27, 2020, at 11:38 AM, Ted Park <kumowoon1025 at gmail.com> wrote:
> 
>> 2) It strips a number of metadata tags (I counted about 13). I want to remove the mjpeg stream without perturbing the rest of the file.
> 
> This can be done, add -map_metadata 0 for the global file-level metadata and -map_metadata:s: 0:s: for stream-level metadata. As I’ll explain, you can’t remove the mjpeg stream, but you can copy everything else but the mjpeg stream. Add -map 0 to copy everything and then add -map -0:# (where # is the stream index of the cover image) to not copy it.

-map_metadata 0 doesn't help—the metadata is still stripped (some well-known tags are preserved, but only a few). It appears ffmpeg is not willing to put unrecognized tags in the output when copying from m4v to mov.

Here's the command line I used, FWIW:

ffmpeg -strict experimental -i video.m4v -map_metadata 0 -map 0 -map -0:4 -codec copy test.mov

>> 3) Testing on another file (also Apple-encoded and supported), the 'mov' output chokes on another stream:
>> 
>>  Stream #0:4(eng): Data: bin_data (tx3g / 0x67337874), 0 kb/s
>>  Metadata:
>>    creation_time   : 2016-07-15T19:12:05.000000Z
>>    handler_name    : Core Media Text
> 
> This I am curious about, tx3g literally indicates mp4:17 text streams, with decoder name “mov_text”. Do you have a sample you can provide?

It's a copyrighted movie, but here's the relevant command line interaction (the problematic stream is #0:4; if I exclude it, the command succeeds):

$ -> ffmpeg -i video.m4v -map 0 -codec copy test.mov
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.16)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8625000800] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.m4v':
  Metadata:
    major_brand     : M4V 
    minor_version   : 0
    compatible_brands: M4V mp42isom

...

    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 126 kb/s (default)
    Metadata:
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Audio
    Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 640x480 [SAR 4:3 DAR 16:9], 1432 kb/s, 23.98 fps, 23.98 tbr, 2997 tbn, 5994 tbc (default)
    Metadata:
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Video
    Stream #0:2(eng): Subtitle: mov_text (tx3g / 0x67337874), 853x72, 0 kb/s (default)
    Metadata:
      rotate          : 0
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Subtitle
    Stream #0:3(eng): Subtitle: eia_608 (c608 / 0x38303663), 853x480, 0 kb/s (default)
    Metadata:
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Closed Caption
    Stream #0:4(eng): Data: bin_data (tx3g / 0x67337874), 0 kb/s
    Metadata:
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Text
    Stream #0:5(und): Video: mjpeg (Baseline) (jpeg / 0x6765706A), yuvj444p(pc, bt470bg/unknown/unknown, progressive), 640x360 [SAR 72:72 DAR 16:9], 8 kb/s, SAR 65536:62805 DAR 1048576:565245, 0.0042 fps, 1 tbr, 1k tbn, 1k tbc (attached pic) (timed thumbnails)
    Metadata:
      rotate          : 0
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Video
    Side data:
      displaymatrix: rotation of -0.00 degrees
    Stream #0:6(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Metadata:
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Audio
    Side data:
      audio service type: main
    Stream #0:7(spa): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s
    Metadata:
      creation_time   : 2016-07-15T19:12:05.000000Z
      handler_name    : Core Media Audio
    Stream #0:8: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 720x1080 [SAR 1:1 DAR 2:3], 90k tbr, 90k tbn, 90k tbc (attached pic)
[mov @ 0x7f862480ba00] Tag tx3g incompatible with output codec id '100359' ([0][0][0][0])
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
  Stream #0:4 -> #0:4 (copy)
  Stream #0:5 -> #0:5 (copy)
  Stream #0:6 -> #0:6 (copy)
  Stream #0:7 -> #0:7 (copy)
  Stream #0:8 -> #0:8 (copy)
    Last message repeated 1 times

> If by other suggestions you meant alternative tools, gpac, l-smash, mp4box are some tools that can work on ISO-family format files, if not in-place, piece by piece. If you have a Mac and are okay with a GUI solution, Subler is a very popular tool for apple-device-compatible-file editing.

I'll investigate some of these, thanks.

ffmpeg does seem pretty ubiquitous as a Swiss army knife kind of tool, so I'm glad to have gotten more familiar with it, but something else may be better for this particular problem.



More information about the ffmpeg-user mailing list