dickontoo / omxtx

OpenMAX transcoder for the Raspberry Pi
GNU General Public License v2.0
116 stars 36 forks source link

Major update - Fixed H264 header info, PTS timing, option to remove subtitles... #7

Closed charrea6 closed 9 years ago

charrea6 commented 11 years ago

Hi Dickon,

This is a major update so I will understand if you don't want to pull as is, but take inspiration from it.

I've rewritten the openmax setup and basically broken it down into more understandable chunks, I've also removed the sleeps and replaced them with a message passing system to wait for confirmation on commands.

Added to that I've fixed the problem of the H264 header info not being in the proper place in the file for mp4 and mkv files. I've also rebased the PTS timestamps to ensure that mkv files now show the proper duration.

Finally I've added an option to remove subtitles (I've got a lot of recordings that contain DVB subtitles that don't fit into the common container formats).

Oh and the bit that I now tends to be a hot topic I converted the tabs to spaces, sorry :-)

My raspberrypi has now churned through ~440GB of MPEG2 transport stream recordings without issue.

Cheers

Adam

dickontoo commented 11 years ago

Thankyou very much for that -- you seem to've fixed all the issues I've got with it. As I've said before, I've got no real understanding of the libav* API, which has hampered me in fixing them; you seem to know what you're doing.

I'd take the patch as-is other than for the whitespace issue. I realise this is a deeply personal thing, but I'm with Linus Torvalds on this one, and have a reasonably large body of code I want to merge with this (for a work project; I can't release it, unfortunately) which is all tab-based.

So I'll be picking at it, and I'll apply what as and when over the next few days.

Thanks a lot. Very helpful.

charrea6 commented 11 years ago

No worries, As to knowing what I'm doing with libav, nope in the same boat as you there, just had a good reason for wanting to get this working (running out of space on my NAS). I found the libav doxygen useful, but there are some things like the output file timebase not being set until you write the header that are well hidden.

dickontoo commented 11 years ago

On Thu, May 30, 2013 at 13:23:19 -0700, Adam Charrett wrote: : No worries, : As to knowing what I'm doing with libav, nope in the same boat as you : there, just had a good reason for wanting to get this working (running : out of space on my NAS). I found the libav doxygen useful, but there are : some things like the output file timebase not being set until you write : the header that are well hidden.

Hidden well enough that I'd missed it, certainly. I find its documentation woeful; it's just about good enough for demuxing, but muxing is dreadful.

Cheers; I'll get it done over the next couple of days. I've been irritated by this for months now.

Dickon Hood

Due to the release of iOS 6 Maps, my .signature is temporarily lost. Normal service will be resumed as soon as possible. We apologise for the inconvenience in the meantime.

This email was sent from a colocated server, and needs no excuses.

dickontoo commented 11 years ago

OK, that didn't work too well... Directly replying to emails => doesn't work. What I tried to say was:

Hidden well enough that I'd missed it, certainly. I find its documentation woeful; it's just about good enough for demuxing, but muxing is dreadful.

Cheers; I'll get it done over the next couple of days. I've been irritated by this for months now.

dwery commented 11 years ago

I can confirm that new branch works nicely. -x works fine, as I probably have unsupported subs.

charrea6 commented 11 years ago

Subtitles should be working, although you can use the -x option to remove them.

dwery commented 11 years ago

Noticed, I edited my previous comment accordingly ;) thanks to you both for the hard work!

dwery commented 11 years ago

Thanks for that commit. Do you think it could be made to work with streaming TS input?

I tried adding av_find_input_format("mpegts") to select the input format and reading from /dev/dvb/adapter0/dvr0 but it fails in several different ways.

charrea6 commented 11 years ago

You won't be able to take the output direct from dvr0 as this will be a multi-program transport stream (even if you only select a few PIDs related to a channel). You'll need something like dvbstreamer (disclosure I wrote this), that will convert the MPTS to a SPTS that you could then stream into a fifo which is named .ts. I've confirmed this would work by previously using avconv to remove subtitles and direct the output into the fifo and then use omxtx to transcode from the fifo.

dickontoo commented 11 years ago

In my experience of ffmpeg-based software players, they choose the first PMT they come across and play that, so you might find it'll work, but only one channel and it'll be more or less random which one. There's no explicit support for it, however.

My use-case for this thing is to possibly replace a bunch of rather power-hungry x86es we've got at work transcoding DVB streams off-air, so it should eventually support that if it doesn't at the moment. I have written (unreleasable, unfortunately; it was done under contract) code which lets me take a broadcast multiplex and stream it over multicast in any combination of services and PIDs you want on any given number of multicast groups and ports; ideally I want to drop this in as a replacement for our iOS / browser transcoders which take this and archive it.

dwery commented 11 years ago

Very interesting, will try. I wish iOS had some native support other than HTTP splitted streaming

dickontoo commented 11 years ago

I've patched my code to handle the timing problems; this has been pushed. It works for me. I've also added the drop-non-av-streams support, and fixed up the SPS and PPS locations in the header, again thanks to Adam Charrett.