VideoHelp Forum




+ Reply to Thread
Results 1 to 10 of 10
  1. ********** jump to post #10 for the resolution *****************


    I have an MP4 that does not have chapters or subtitles (or a data stream). Past experience tells me that when viewing an MP4 with chapters in VLC, VLC adds a ghost subtitle track that when selected only shows the chapter names - and I have learned that this is because VLC seems to be misinterpreting the chapters information in the data stream. And, I know that "-map_metadata 1 -map_chapters 1" is used to add chapters to the output MP4. And, I have found that when I do that, a data stream is typically added to the outout MP4.

    When I generate the chapters file with ffmetadata and I add the chapters to that file, the ffmpeg command to add the chapters to the output MP4 adds the correct number of chapters and the correct times, but, it fails to add the chapter titles. VLC shows the titles as "Chapter 0, Chapter 1, etc" and Zoom Player shows the chapters and times, but, no titles. Both jump to the proper times when I click to tell it to go to a chapter. The console display from the ffmpeg command shows that it is seeing all of the chapter information - including the titles. When I look at the ffmpeg output for both MP4s, there is no data stream. I have not worked with ffmpeg for 4-6 months, but, in the past when I added chapters to an MP4, it added a data stream (and I have verified that by checking on an old MP4 today) that seems to have the chapter names.

    My understanding is that "-map_metadata 1 -map_chapters 1" handle two separate/different issues when it comes to chapter file and information. I have also tried having "-map 0" in the command line and leaving it out. And, I have commented out each of the lines in the chapters file after the ;FFMETADATA1 line, but, it makes no difference. Google does not seem to know about this issue, so, here I am. What do y'all think is going on?

    BTW, I know that I can use other software to add the chapters correctly. But, I want to use ffmpeg and understand what it is doing and not doing.
    Last edited by the_steve_randolph; 21st Jun 2023 at 17:43. Reason: additional info
    Quote Quote  
  2. Post your full ffmpeg commandline
    Quote Quote  
  3. No clue about VLC or Zoom Player, no clue what your ffmpeg command line looks like, and I have never used ffmetadata.
    That said, something like:
    Code:
    ffmpeg -y  -i "<Path to input file>" -i "<path to chapter file>" -map_chapters 1 -c:0 copy -map 0:0 "<path to output file>"
    with the chapter file looking like:
    Code:
    ;FFMETADATA1
    [CHAPTER]
    TIMEBASE=1/1000
    START=0
    END=4999
    title=Chapter 1
    [CHAPTER]
    TIMEBASE=1/1000
    START=5000
    END=19999
    title=Chapter 2
    [CHAPTER]
    TIMEBASE=1/1000
    START=20000
    END=49999
    title=Chapter 3
    [CHAPTER]
    TIMEBASE=1/1000
    START=50000
    END=59999
    title=Chapter 4
    [CHAPTER]
    TIMEBASE=1/1000
    START=60000
    END=63000
    title=Chapter 5
    always worked fine for me so far.

    Here's the chapter file in mkv format (which I prefer, but ffmpeg doesn't support) for better readability:
    Code:
    CHAPTER01=00:00:00.000
    CHAPTER01NAME=Chapter 1
    CHAPTER02=00:00:05.000
    CHAPTER02NAME=Chapter 2
    CHAPTER03=00:00:20.000
    CHAPTER03NAME=Chapter 3
    CHAPTER04=00:00:50.000
    CHAPTER04NAME=Chapter 4
    CHAPTER05=00:01:00.000
    CHAPTER05NAME=Chapter 5
    Maybe that helps,....

    Cu Selur

    Ps.: I only used a video stream and the chapter info in my example, no audio stream.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  4. Originally Posted by Selur View Post
    Code:
    ffmpeg -y  -i "<Path to input file>" -i "<path to chapter file>" -map_chapters 1 -c:0 copy -map 0:0 "<path to output file>"
    Works without -map_chapters 1 too.
    Quote Quote  
  5. Originally Posted by ProWo View Post
    Post your full ffmpeg commandline
    Code:
    ffmpeg -i in.mp4 -i in.txt -map_metadata 1 -map_chapters 1 -c copy out.mp4 2>log.txt
    in.txt:

    Code:
    ;FFMETADATA1
    major_brand=isom
    minor_version=512
    compatible_brands=isomiso2avc1mp41
    encoder=Lavf60.5.100
    
    [CHAPTER]
    TIMEBASE=1/1000
    START=00000
    END=34000
    title=Introduction
    
    [CHAPTER]
    TIMEBASE=1/1000
    START=34000
    END=275000
    title=My Chapter 1
    
    [CHAPTER]
    TIMEBASE=1/1000
    START=275000
    END=496000
    title=My Chapter 2
    
    [CHAPTER]
    TIMEBASE=1/1000
    START=496000
    END=764000
    title=My Chapter 3
    Console output:
    Code:
    ffmpeg version 2023-04-26-git-e3143703e9-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
      built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
      configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
      libavutil      58.  6.100 / 58.  6.100
      libavcodec     60. 10.100 / 60. 10.100
      libavformat    60.  5.100 / 60.  5.100
      libavdevice    60.  2.100 / 60.  2.100
      libavfilter     9.  5.100 /  9.  5.100
      libswscale      7.  2.100 /  7.  2.100
      libswresample   4. 11.100 /  4. 11.100
      libpostproc    57.  2.100 / 57.  2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf58.76.100
      Duration: 01:05:23.41, start: 0.000000, bitrate: 2371 kb/s
      Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 2235 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
        Metadata:
          handler_name    : ISO Media file produced by XYZ Inc.
          vendor_id       : [0][0][0][0]
      Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
        Metadata:
          handler_name    : ISO Media file produced by XYZ Inc.
          vendor_id       : [0][0][0][0]
    Input #1, ffmetadata, from 'in.txt':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf60.5.100
      Duration: 00:12:44.00, start: 0.000000, bitrate: 0 kb/s
      Chapters:
        Chapter #1:0: start 0.000000, end 34.000000
          Metadata:
            title           : Introduction
        Chapter #1:1: start 34.000000, end 275.000000
          Metadata:
            title           : My Chapter 1
        Chapter #1:2: start 275.000000, end 496.000000
          Metadata:
            title           : My Chapter 2
        Chapter #1:3: start 496.000000, end 764.000000
          Metadata:
            title           : My Chapter 3
    Output #0, mp4, to 'out.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf60.5.100
      Chapters:
        Chapter #0:0: start 0.000000, end 34.000000
        Chapter #0:1: start 34.000000, end 275.000000
        Chapter #0:2: start 275.000000, end 496.000000
        Chapter #0:3: start 496.000000, end 764.000000
      Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2235 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
      Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame=    0 fps=0.0 q=-1.0 size=       0kB time=-00:00:00.03 bitrate=  -0.0kbits/s speed=N/A    
    frame=32325 fps=0.0 q=-1.0 size=  326656kB time=00:17:58.54 bitrate=2481.1kbits/s speed=2.16e+03x    
    frame=61086 fps=61078 q=-1.0 size=  586752kB time=00:33:58.17 bitrate=2358.3kbits/s speed=2.04e+03x    
    frame=88069 fps=58686 q=-1.0 size=  825856kB time=00:48:58.50 bitrate=2302.3kbits/s speed=1.96e+03x    
    frame=112185 fps=56072 q=-1.0 size= 1079040kB time=01:02:23.21 bitrate=2361.5kbits/s speed=1.87e+03x    
    [out#0/mp4 @ 0000021794544fc0] video:1070419kB audio:61303kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.357409%
    frame=117583 fps=52731 q=-1.0 Lsize= 1135767kB time=01:05:23.38 bitrate=2371.5kbits/s speed=1.76e+03x
    Last edited by the_steve_randolph; 19th Jun 2023 at 17:10.
    Quote Quote  
  6. Try
    ffmpeg -i in.mp4 -i in.txt -c copy -map 0 out.mp4
    Quote Quote  
  7. Originally Posted by ProWo View Post
    Try
    ffmpeg -i in.mp4 -i in.txt -c copy -map 0 out.mp4
    That worked. But, now I am confused: what is the purpose of "-map_metadata" and "-map_chapters"? When are they supposed to be used? Maybe when converting a MKV to a MP4?

    BTW, this works too:
    Code:
    ffmpeg -i in.mp4 -i in.txt -c copy out.mp4
    And, this works too:
    Code:
    ffmpeg -i in.mp4 -i in.txt -map_chapters 1 -c copy out.mp4
    but I think it is because the "-map-chapters 1" is being ignored.
    Last edited by the_steve_randolph; 21st Jun 2023 at 17:51.
    Quote Quote  
  8. map_chapters should copy chapters from one input to the output
    map_metadata is used to copy metadata from a from an input.
    see: https://www.ffmpeg.org/ffmpeg-all.html
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  9. Originally Posted by Selur View Post
    map_chapters should copy chapters from one input to the output
    map_metadata is used to copy metadata from a from an input.
    see: https://www.ffmpeg.org/ffmpeg-all.html
    In my situation here, my second input file is an ffmetadata file, but, my command did not need either of these two switches. Perhaps one or both switches is used if the first two input files are video files (aka MKV, MP4, AVI, etc)?
    Quote Quote  
  10. OK, it seems that "-map_metadata" and "-map_chapters" only do something when there is more than one video file (as opposed to a single video file and a ffmetadata file). And, it also seems that having a single input video file that is a different format (i.e. MKV, MP4, MOV, AVI, etc.) from the output video file does NOT require "-map_metadata" and/or "-map_chapters". Although, I don't know why my orginal command left out the chapter names (maybe the answer is "do something crazy and get crazy results").

    Once again, thanks for the help here.
    Last edited by the_steve_randolph; 21st Jun 2023 at 17:47.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!