Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discard data stream from container using ffmpeg

I am trying to get rid of a data (subtitle) stream within a Mp4 container, using ffmpeg.

Here's the screenshot from ffprobe:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.m4v':
Metadata:
major_brand     : isom
minor_version   : 2
compatible_brands: isomiso2avc1mp41
creation_time   : 2018-01-19T15:10:48.000000Z
Duration: 00:00:42.17, start: 0.000000, bitrate: 6260 kb/s
Chapter #0:0: start 0.000000, end 42.166000
Metadata:
  title           : Chapter 1
Stream #0:0(eng): Data: bin_data (text / 0x74786574), 0 kb/s (default)
Metadata:
  creation_time   : 2018-01-19T15:10:48.000000Z
  handler_name    : Apple Alias Data Handler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, 
fltp, 317 kb/s (default)
Metadata:
  creation_time   : 2018-01-19T15:10:48.000000Z
  handler_name    : AAC audio
Stream #0:2(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 
1920x1080, 5926 kb/s, 30 fps, 30 tbr, 30k tbn, 60k tbc (default)
Metadata:
  creation_time   : 2018-01-19T15:10:48.000000Z
  handler_name    : H264 video
 **Unsupported codec with id 100359 for input stream 0**

I tried:

 ffmpeg -i test.m4v -acodec copy -vcodec copy -sn nodata.mp4

Data track still there, just moved from stream 0 to stream 2

I tried also:

 ffmpeg -i test.m4v -acodec copy -vcodec copy -map 0:1 -map 0:2 no2.mp4

Same result, track still there, just jumped to stream 0:2 no luck.

Any hint? Thanks in advance

like image 957
A.Be Avatar asked Dec 19 '22 01:12

A.Be


2 Answers

It's better to use this command instead of -map_chapters -1:

ffmpeg -i in.mp4 -c copy -dn -map_metadata:c -1 out.mp4

-dn says that we don't need a data stream to be copied from in.mp4 to out.mp4. It's required if you have a data stream in source file. But even if there's not a data stream in source file, ffmpeg appends a data stream to output file to keep chapters metadata info (chapter names). This enables the player to name each chapter.

If you don't need it, your chapters may have no name. -map_chapters -1 completely removes chapters so that in video stream you'll lose all chapters. But if you just mean not to include a data stream, by using -map_metadata:c -1 you may keep chapters and just lose their names. It may be a better and less destructive idea.

For reference:

-dn (output)
    Disable data recording. For full manual control see the "-map" option.
like image 68
hamidi Avatar answered Jan 13 '23 11:01

hamidi


Thanks, I resolved using the -map_chapters option with negative value to remove the data stream.

Full string:

ffmpeg -i in.mp4 -c:v copy -c:a copy -map_chapters -1 out.mp4 

Hope this would help someone else!

like image 26
A.Be Avatar answered Jan 13 '23 12:01

A.Be