Topics

ffmpeg options

John Hanley
 

I want to convert a TS container to a MKV container. My understanding is that the MKV container will encode in MP4 but with subtitles/closed captioning pass through. I want my videos compressed in MP4 as the files are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files significantly while still maintaining a nice smooth high def experience (720p would be fine)?

Thanks!

John

Keehan Dowd
 

I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

Regards,
Keehan.


On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:
I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John





William Henderson aka Slackrat
 

"John Hanley" <linux@...> writes:

I want to convert a TS container to a MKV container. My understanding
is that the MKV container will encode in MP4 but with subtitle
Worked for me:

https://www.internalpointers.com/post/convert-vob-files-mkv-ffmpeg

--
William Henderson
aka Slackrat
http://billh.sdf.org/slackware.jpg
9HS5203 on HamSphere Ham Radio

John Hanley
 

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John


On 2019-12-27 3:47 p.m., Keehan Dowd wrote:
I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

Regards,
Keehan.


On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:
I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John





Keehan Dowd
 

Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

Keehan. 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John


On 2019-12-27 3:47 p.m., Keehan Dowd wrote:
I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

Regards,
Keehan.


On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:
I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John





John Hanley
 

They are definitely in the raw .TS file. And when I translate it to MKS they remain there. But when I specify mpeg4 in the mks container, they get lost. Must be an option there...

On 2019-12-27 6:29 p.m., Keehan Dowd wrote:
Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

Keehan. 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John


On 2019-12-27 3:47 p.m., Keehan Dowd wrote:
I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

Regards,
Keehan.


On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:
I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John





Keehan Dowd
 


On Fri, Dec 27, 2019, 6:58 PM John Hanley, <linux@...> wrote:

They are definitely in the raw .TS file. And when I translate it to MKS they remain there. But when I specify mpeg4 in the mks container, they get lost. Must be an option there...

On 2019-12-27 6:29 p.m., Keehan Dowd wrote:
Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

Keehan. 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John


On 2019-12-27 3:47 p.m., Keehan Dowd wrote:
I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

Regards,
Keehan.


On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:
I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John





Keehan Dowd
 

There are also some other ffmpeg options mentioned in the reply from William.   Analyze duration, etc.   If had to do that on some streams too to find other streams that are normally reported by ffmpeg...


On Fri, Dec 27, 2019, 7:13 PM Keehan Dowd via Groups.Io, <keehan.dowd=gmail.com@groups.io> wrote:

On Fri, Dec 27, 2019, 6:58 PM John Hanley, <linux@...> wrote:

They are definitely in the raw .TS file. And when I translate it to MKS they remain there. But when I specify mpeg4 in the mks container, they get lost. Must be an option there...

On 2019-12-27 6:29 p.m., Keehan Dowd wrote:
Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

Keehan. 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John


On 2019-12-27 3:47 p.m., Keehan Dowd wrote:
I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

Regards,
Keehan.


On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:
I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John





John Hanley
 

Well I can definitely isolate the closed captions stream using this tool and can copy it to an srt file. It seems the issue for me is when I encode to mpeg4 the closed captions get lost, even when I include the mapping of the closed captions stream. This seems to be an issue with MP4.

The solution I am looking for is this:

I want to compress my .TS file to something smaller. I can play my .TS and .MKV containers (with the MPEG2 file) over Plex with just a few hiccups. And the closed captions are there just fine. However, when I use Chromecast, the .ts file often times crashes the Chromecast for whatever reason.

I have previously tried using HandBrake to convert the TS container to MP4. It burns in the closed caption as subtitles that are *HUGE* even at Plex's smallest settings.

I thought using an MKS container would handle closed captions better but it appears to be the same problem when it contains an MP4.

I found an extremely convoluted  solution that uses CCExtractor to extract the closed captions, save it to a separate file, and then somehow re-add in the closed captions after the mp4 has been created. I was working on that months ago and never got it to work as it required scripts, etc... Convoluted.

I suppose I could go out and buy a hard wired device that has Plex player and could play the TS container.

Or is there any other way to get the closed captions in a compressed format that Chromecast can play without crashing?

Thanks!

John


On 2019-12-27 7:13 p.m., Keehan Dowd wrote:

On Fri, Dec 27, 2019, 6:58 PM John Hanley, <linux@...> wrote:

They are definitely in the raw .TS file. And when I translate it to MKS they remain there. But when I specify mpeg4 in the mks container, they get lost. Must be an option there...

On 2019-12-27 6:29 p.m., Keehan Dowd wrote:
Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

Keehan. 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John


On 2019-12-27 3:47 p.m., Keehan Dowd wrote:
I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

Regards,
Keehan.


On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:
I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John





Manuel Eller
 

Hi,

 

I strongly recommend Handbrake to do that compression. I do not know if Handbrake uses ffmpeg to compress but the tool gives you the option to incorporate the closed caption. The program is much easier to use than the commend line (at least for me). Have a look and try it. I compress all kinds of TS recordings to a more reasonable file size maintaining the audio by passing it through but I have not tired the closed caption. I know it is possible as the option to import SRT files is there.

 

Manuel

 

Von: elug@groups.io <elug@groups.io> Im Auftrag von John Hanley
Gesendet: Freitag, 27. Dezember 2019 20:59
An: elug@groups.io
Betreff: Re: [elug] ffmpeg options

 

Well I can definitely isolate the closed captions stream using this tool and can copy it to an srt file. It seems the issue for me is when I encode to mpeg4 the closed captions get lost, even when I include the mapping of the closed captions stream. This seems to be an issue with MP4.

The solution I am looking for is this:

I want to compress my .TS file to something smaller. I can play my .TS and .MKV containers (with the MPEG2 file) over Plex with just a few hiccups. And the closed captions are there just fine. However, when I use Chromecast, the .ts file often times crashes the Chromecast for whatever reason.

I have previously tried using HandBrake to convert the TS container to MP4. It burns in the closed caption as subtitles that are *HUGE* even at Plex's smallest settings.

I thought using an MKS container would handle closed captions better but it appears to be the same problem when it contains an MP4.

I found an extremely convoluted  solution that uses CCExtractor to extract the closed captions, save it to a separate file, and then somehow re-add in the closed captions after the mp4 has been created. I was working on that months ago and never got it to work as it required scripts, etc... Convoluted.

I suppose I could go out and buy a hard wired device that has Plex player and could play the TS container.

Or is there any other way to get the closed captions in a compressed format that Chromecast can play without crashing?

Thanks!

John

 

On 2019-12-27 7:13 p.m., Keehan Dowd wrote:

 

On Fri, Dec 27, 2019, 6:58 PM John Hanley, <linux@...> wrote:

They are definitely in the raw .TS file. And when I translate it to MKS they remain there. But when I specify mpeg4 in the mks container, they get lost. Must be an option there...

On 2019-12-27 6:29 p.m., Keehan Dowd wrote:

Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

 

Keehan. 

 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John

 

On 2019-12-27 3:47 p.m., Keehan Dowd wrote:

I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

 

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

 

Regards,

Keehan.

 

On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:

I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John




John Hanley
 

I did try HandbrakeCLI in the past but had troubles converting to mkv. I think that may have been a permissions problem. But I could try again.

However, I just recently looked at tvheadend and it will allow recording directly to mkv so I'll give that a go (rather than record to TS and then run a post-processor command to encode to mkv).

Closed Captions seemed to be dicey when using MP4 in the container.

Thanks!

John



On 2019-12-29 12:55 p.m., Manuel Eller wrote:

Hi,

 

I strongly recommend Handbrake to do that compression. I do not know if Handbrake uses ffmpeg to compress but the tool gives you the option to incorporate the closed caption. The program is much easier to use than the commend line (at least for me). Have a look and try it. I compress all kinds of TS recordings to a more reasonable file size maintaining the audio by passing it through but I have not tired the closed caption. I know it is possible as the option to import SRT files is there.

 

Manuel

 

Von: elug@groups.io <elug@groups.io> Im Auftrag von John Hanley
Gesendet: Freitag, 27. Dezember 2019 20:59
An: elug@groups.io
Betreff: Re: [elug] ffmpeg options

 

Well I can definitely isolate the closed captions stream using this tool and can copy it to an srt file. It seems the issue for me is when I encode to mpeg4 the closed captions get lost, even when I include the mapping of the closed captions stream. This seems to be an issue with MP4.

The solution I am looking for is this:

I want to compress my .TS file to something smaller. I can play my .TS and .MKV containers (with the MPEG2 file) over Plex with just a few hiccups. And the closed captions are there just fine. However, when I use Chromecast, the .ts file often times crashes the Chromecast for whatever reason.

I have previously tried using HandBrake to convert the TS container to MP4. It burns in the closed caption as subtitles that are *HUGE* even at Plex's smallest settings.

I thought using an MKS container would handle closed captions better but it appears to be the same problem when it contains an MP4.

I found an extremely convoluted  solution that uses CCExtractor to extract the closed captions, save it to a separate file, and then somehow re-add in the closed captions after the mp4 has been created. I was working on that months ago and never got it to work as it required scripts, etc... Convoluted.

I suppose I could go out and buy a hard wired device that has Plex player and could play the TS container.

Or is there any other way to get the closed captions in a compressed format that Chromecast can play without crashing?

Thanks!

John

 

On 2019-12-27 7:13 p.m., Keehan Dowd wrote:

I was googling around a bit....does this help?  https://stackoverflow.com/questions/3169910/can-ffmpeg-extract-closed-caption-data

 

 

On Fri, Dec 27, 2019, 6:58 PM John Hanley, <linux@...> wrote:

They are definitely in the raw .TS file. And when I translate it to MKS they remain there. But when I specify mpeg4 in the mks container, they get lost. Must be an option there...

On 2019-12-27 6:29 p.m., Keehan Dowd wrote:

Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

 

Keehan. 

 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John

 

On 2019-12-27 3:47 p.m., Keehan Dowd wrote:

I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

 

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

 

Regards,

Keehan.

 

On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:

I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John




Keehan Dowd
 

Another thing that just came to mind is the player.   I had a problem a while ago where my default player wouldn't play mp4 with subtitles but VLC did (or maybe it was the other way 'round...I can't remember!)



On Sun, Dec 29, 2019, 4:55 PM John Hanley, <linux@...> wrote:

I did try HandbrakeCLI in the past but had troubles converting to mkv. I think that may have been a permissions problem. But I could try again.

However, I just recently looked at tvheadend and it will allow recording directly to mkv so I'll give that a go (rather than record to TS and then run a post-processor command to encode to mkv).

Closed Captions seemed to be dicey when using MP4 in the container.

Thanks!

John



On 2019-12-29 12:55 p.m., Manuel Eller wrote:

Hi,

 

I strongly recommend Handbrake to do that compression. I do not know if Handbrake uses ffmpeg to compress but the tool gives you the option to incorporate the closed caption. The program is much easier to use than the commend line (at least for me). Have a look and try it. I compress all kinds of TS recordings to a more reasonable file size maintaining the audio by passing it through but I have not tired the closed caption. I know it is possible as the option to import SRT files is there.

 

Manuel

 

Von: elug@groups.io <elug@groups.io> Im Auftrag von John Hanley
Gesendet: Freitag, 27. Dezember 2019 20:59
An: elug@groups.io
Betreff: Re: [elug] ffmpeg options

 

Well I can definitely isolate the closed captions stream using this tool and can copy it to an srt file. It seems the issue for me is when I encode to mpeg4 the closed captions get lost, even when I include the mapping of the closed captions stream. This seems to be an issue with MP4.

The solution I am looking for is this:

I want to compress my .TS file to something smaller. I can play my .TS and .MKV containers (with the MPEG2 file) over Plex with just a few hiccups. And the closed captions are there just fine. However, when I use Chromecast, the .ts file often times crashes the Chromecast for whatever reason.

I have previously tried using HandBrake to convert the TS container to MP4. It burns in the closed caption as subtitles that are *HUGE* even at Plex's smallest settings.

I thought using an MKS container would handle closed captions better but it appears to be the same problem when it contains an MP4.

I found an extremely convoluted  solution that uses CCExtractor to extract the closed captions, save it to a separate file, and then somehow re-add in the closed captions after the mp4 has been created. I was working on that months ago and never got it to work as it required scripts, etc... Convoluted.

I suppose I could go out and buy a hard wired device that has Plex player and could play the TS container.

Or is there any other way to get the closed captions in a compressed format that Chromecast can play without crashing?

Thanks!

John

 

On 2019-12-27 7:13 p.m., Keehan Dowd wrote:

I was googling around a bit....does this help?  https://stackoverflow.com/questions/3169910/can-ffmpeg-extract-closed-caption-data

 

 

On Fri, Dec 27, 2019, 6:58 PM John Hanley, <linux@...> wrote:

They are definitely in the raw .TS file. And when I translate it to MKS they remain there. But when I specify mpeg4 in the mks container, they get lost. Must be an option there...

On 2019-12-27 6:29 p.m., Keehan Dowd wrote:

Sorry - I don't know how closed captions are captured (are they actually captured?) assuming you've recorded this off air.   Years ago when I was recording off-air, I'm pretty sure there was a recording option to capture closed captioning.

 

Keehan. 

 

On Fri, Dec 27, 2019, 4:46 PM John Hanley, <linux@...> wrote:

So when I use ffmpeg -i to discover my streams, I see:

[mpeg2video @ 0x55ac721c8e80] Invalid frame dimensions 0x0.
    Last message repeated 1 times
[mpegts @ 0x55ac721c4820] PES packet size mismatch
Input #0, mpegts, from 'Grand-Designs2019-12-27-S10E01.ts':
  Duration: 00:01:06.77, start: 74573.013233, bitrate: 15789 kb/s
  Program 3
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bottom first), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 15000 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](enm): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)

Based on this, I try:

sudo ffmpeg -i Grand-Designs2019-12-27-S10E01.ts -map 0:0 -map 0:2 -f matroska -vcodec mpeg4 -codec:s copy -metadata:s:s:0 language=eng -acodec aac Grand-Designs7.mkv

and I get no subtitles. Keeping in mind these are closed captions. When I didn't specify mpeg4, the closed captions were there. When I specified mpeg4, the subtitles aren't there.

Any thoughts on how to get the closed captioning through?

Thanks!

John

 

On 2019-12-27 3:47 p.m., Keehan Dowd wrote:

I think if you don't specify, it will only pass through the first audio and first subtitle stream if multiple streams exist.  You'll need to use the -map option to pick which stream(s) if there are multiple streams.

 

As for quality, I normally use the -crf option of 24 or 26 for high quality.  I think crf 18 is considered visually lossless and by crf 32 it can look pretty bad in high motion scenes.  Each step of 6 results in about 1/2 the bitrate if I recall correctly.  I also often rescale to 480p to further save file size if I don't care about the picture definition.  If you can reencode to h.265 that'll save file size too, but h265 requires significantly more decoding power and it's too much for my little set-top boxes with arm processors.

 

Regards,

Keehan.

 

On Fri, Dec 27, 2019, 3:27 PM John Hanley, <linux@...> wrote:

I want to convert a TS container to a MKV container. My understanding is
that the MKV container will encode in MP4 but with subtitles/closed
captioning pass through. I want my videos compressed in MP4 as the files
are huge.

There are sooooooo many options in ffmpeg.

Can anyone suggest some good options to compress these files
significantly while still maintaining a nice smooth high def experience
(720p would be fine)?

Thanks!

John