omxtx - open source transcoding example


238 posts   Page 3 of 10   1, 2, 3, 4, 5, 6 ... 10
by dickon » Tue Jan 01, 2013 5:49 pm
Something odd going on there, certainly. Oh well, just proves that the clocks are thoroughly broken still.

I've pushed my buffer fixes up. Hasn't made any difference.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by dickon » Tue Jan 01, 2013 6:01 pm
Oh, actually, maybe it has. I have a test stream I often use for this sort of thing -- it's a copy of Lord of Misrule from the BBC Archives -- which I know to be fairly correct. It'll now at least play after transcoding, albeit again unseekably and only if I specify -fps to mplayer. It wasn't doing that before.

I reckon it's something silly, like using the wrong timebase for one or more of the conversions or during the stream setups. If anyone's any better idea, shout now.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by richardp » Tue Jan 01, 2013 6:06 pm
dickon wrote:Oh, actually, maybe it has. I have a test stream I often use for this sort of thing -- it's a copy of Lord of Misrule from the BBC Archives -- which I know to be fairly correct. It'll now at least play after transcoding, albeit again unseekably and only if I specify -fps to mplayer. It wasn't doing that before.

I reckon it's something silly, like using the wrong timebase for one or more of the conversions or during the stream setups. If anyone's any better idea, shout now.


I spent weeks trying to get PTS/DTS working on lifavformat/libavcodec on other projects and in the then I dumped it and went to Gstreamer pipelines as it worked :-P

I think mumudvb project uses the libavformat and maybe htsheadend Media server.... I'll take a look and see what else uses the av* family
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by dickon » Tue Jan 01, 2013 7:07 pm
Hmm. I might have a look at that. It's been a while since I last bothered; I expect it'll've come on a bit since then.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by saintdev » Tue Jan 01, 2013 9:44 pm
Raw h.264 does not have a way to encode the framerate. I thought libav defaulted to 1000fps in this case, this may have been changed recently, I haven't done much with raw h.264 lately.
SELECT `signature` FROM `users` WHERE `username`='saintdev';
Empty set (0.00 sec)
Posts: 39
Joined: Mon Jun 18, 2012 10:56 pm
by dickon » Wed Jan 02, 2013 1:55 am
Raw NALs have no timestamps but are in DTS order, so playback speed doesn't matter. I've no idea what lavf reports those as; I'd've assumed AV_NOPTS_VALUE for every frame (which would be right).
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by richardp » Wed Jan 02, 2013 3:30 pm
I cant get any of the output parameters to change.... fps, H264_PROFILE, width, height, bitrate all stay the same even if I set to dumb values.. I cnahe a ton is makeoutputcontext() but the container never changes. Never mind the pts/dts values... I cant get them to any other value other than NOPTS
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by richardp » Wed Jan 02, 2013 6:42 pm
My previous post made no sense :-P .. fixed now

richardp wrote:I cant get any of the output parameters to change.... fps, H264_PROFILE, width, height, bitrate all stay the same even if I set to dumb values.. I change a ton in makeoutputcontext() but the container never changes. Never mind the pts/dts values... I cant get them to any other value other than NOPTS
Last edited by richardp on Wed Jan 02, 2013 7:01 pm, edited 1 time in total.
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by dickon » Wed Jan 02, 2013 6:52 pm
I struggled, but I think I got the gist :-)

I should be free tomorrow to look at things.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by mrotindo » Fri Jan 04, 2013 4:21 am
Just wanted to chime in and say I was following this pretty closely. Any chance you could update the source posted. I wanted to see if I could poke around the code. No experience in the given field, but I have a pretty solid background in embedded programming.

Anywho, I look forward to any updates : ).
Posts: 1
Joined: Fri Jan 04, 2013 4:19 am
by ghans » Fri Jan 04, 2013 9:32 am
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by klobber » Fri Jan 04, 2013 9:38 am
Been swamped with work this week, but every time I get a subscription notification from this thread my heart jumps a little. This is one of the most exciting projects on here for a while, imagine the possibilities after we crack this nut!
Posts: 3
Joined: Sun Dec 30, 2012 6:33 am
by richardp » Fri Jan 04, 2013 4:34 pm
dickon wrote:I struggled, but I think I got the gist :-)

I should be free tomorrow to look at things.


I am at a loss... short of re-writing to understand the OMX parts. What ideas do you have, perhaps I could give them a bash.

Richard
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by dickon » Sat Jan 05, 2013 1:42 pm
I must admit, I'm heading that way, too.

I've taken the nontrivial step of seeing if the Pi's build of ffmpeg is broken and built my own, cross-compiling from my desktop to save some months on the Pi. No change, other than a few minor API issues (and a lot of kerfuffle with symlinks and whatnot trying to get linking working).

Really, the OMX bit is the easy bit: the frames are fed into the decoder with a PTS set from the packet, and timebase-converted to the OpenMAX standard 1/E6. On the way out, those timestamps are still present, so they're converted back from OMX to ... the wrong bloody time base. Arse.

Fixed that. Also added conversions for the other streams, which shouldn't be necessary but seem to be. I still think there's something underlying that's wrong. Anyway, I now seem to have a mostly-unseekable stream playing of one of my test streams. Try that.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by richardp » Sat Jan 05, 2013 2:49 pm
dickon wrote:I must admit, I'm heading that way, too.

I've taken the nontrivial step of seeing if the Pi's build of ffmpeg is broken and built my own, cross-compiling from my desktop to save some months on the Pi. No change, other than a few minor API issues (and a lot of kerfuffle with symlinks and whatnot trying to get linking working).

Really, the OMX bit is the easy bit: the frames are fed into the decoder with a PTS set from the packet, and timebase-converted to the OpenMAX standard 1/E6. On the way out, those timestamps are still present, so they're converted back from OMX to ... the wrong bloody time base. Arse.

Fixed that. Also added conversions for the other streams, which shouldn't be necessary but seem to be. I still think there's something underlying that's wrong. Anyway, I now seem to have a mostly-unseekable stream playing of one of my test streams. Try that.


Its a big step forward... omxtx can now eat its own output :D .. but many missing frames. VLC seems to play at the correct speed, but mplayer still is proving to be a pain. Mplayer still complaining about the PTS numbers being missing (AV_NOPTS value)
Code: Select all
No pts value from demuxer to use for frame!
Video pts after filters MISSING
V:-9223372036854775808.0   0/  0 ??% ??% ??,?% 0 0


I am curious what the meaning of 'Video pts after filters MISSING' actually means.

R
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by dickon » Sat Jan 05, 2013 4:15 pm
I can't get it to do anything useful with the 480p Big Buck Bunny, although it does with the 720p. I get no output in the file for the 480p, for some reason, although it does appear to be doing what I'd expect it to.

Again, as with my own test streams, it produces output which ffplay, mplayer and vlc are happy with -- even the subtitles work and appear on time -- but which the former two can't seek in without spitting errors ('[NULL @ 0xf62ae0]non-existing PPS referenced') once per frame or so. ffmpeg can't remux it successfully into the same container, either. I have no idea what's going on there. omxtx can retranscode it, and mplayer will play the output with the usual problems.

So it's an improvement, but we're not there yet.

As to your 'Video pts after filters MISSING' error: I'm not seeing it. Have you got a .mplayerrc or whatnot with some filters configured?
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by richardp » Sat Jan 05, 2013 4:36 pm
dickon wrote:I can't get it to do anything useful with the 480p Big Buck Bunny, although it does with the 720p. I get no output in the file for the 480p, for some reason, although it does appear to be doing what I'd expect it to.

Again, as with my own test streams, it produces output which ffplay, mplayer and vlc are happy with -- even the subtitles work and appear on time -- but which the former two can't seek in without spitting errors ('[NULL @ 0xf62ae0]non-existing PPS referenced') once per frame or so. ffmpeg can't remux it successfully into the same container, either. I have no idea what's going on there. omxtx can retranscode it, and mplayer will play the output with the usual problems.

So it's an improvement, but we're not there yet.

As to your 'Video pts after filters MISSING' error: I'm not seeing it. Have you got a .mplayerrc or whatnot with some filters configured?


The Video missing error is from mplayer. I just use it to test the streams using the command
Code: Select all
mplayer XYZ.mov

This spews out the packet formats and such things. As to progress, if I uncomment
Code: Select all
//printf("Inbound PTS: %lld (%d/%d)\n", rp->pts, ic->streams[index]->time_base.num, ic->streams[index]->time_base.den);
the application segfaults when I run it on a file that it produced. (%lld should be good) - Backtrace shows that the av_bitstream_filter_filter is killing something. rp->xxxxx pointer missing/bad perhaps.
Code: Select all
OMX_SendCommand(m2, OMX_CommandStateSet, OMX_StateExecuting, NULL) completed OK.
Inbound PTS: 0

Program received signal SIGSEGV, Segmentation fault.
0x401d3ba4 in av_bitstream_filter_filter () from /usr/lib/arm-linux-gnueabihf/libavcodec.so.53
(gdb) bt
#0  0x401d3ba4 in av_bitstream_filter_filter () from /usr/lib/arm-linux-gnueabihf/libavcodec.so.53
#1  0x0000ab78 in filter (ctx=0x1a5f0, rp=0x19be88) at omxtx.c:644
#2  0x0000e470 in main (argc=3, argv=0xbefff7d4) at omxtx.c:1297
(gdb) q
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by dickon » Sat Jan 05, 2013 5:05 pm
Oops.

Uninitialised bsfc in dofiltertest() being returned unset. Fixed.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by richardp » Sat Jan 05, 2013 5:13 pm
dickon wrote:Oops.

Uninitialised bsfc in dofiltertest() being returned unset. Fixed.


Thanks... that solved the Segfault

Just noticed... Invalid timebase when encoding the original.mov
Code: Select all
Output:
Output #0, mov, to 'out.mov':
    Stream #0.0: Video: libx264, yuv420p, 854x480, q=-1--1, 2097 kb/s, 24 fps, 24 tbr, 2400 tbn, 4800 tbc
    Stream #0.1: Data: tmcd / 0x64636D74
    Stream #0.2: Audio: aac, 48000 Hz, 5.1, s16, 437 kb/s


Ignoring attempt to set invalid timebase for st:1


Inbound PTS: 700 (1/2400)
Inbound PTS: 1000 (1/2400)
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by richardp » Sat Jan 05, 2013 5:58 pm
There are 3 streams in the file.... so I think stream 1 is throwing the encoder off course. I will generate files that are 1Video+1Audio and perhaps subtitles.

The Invalid timebase comes from stream 1 (st:1 in the error I assume)

Richard
Code: Select all
Input:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mov':
  Metadata:
    major_brand     : qt 
    minor_version   : 537199360
    compatible_brands: qt 
    creation_time   : 2008-05-27 18:32:32
  Duration: 00:09:56.48, start: 0.000000, bitrate: 70 kb/s
    Stream #0.0(eng): Video: h264 (Main), yuv420p, 854x480, 2899 kb/s, 24 fps, 24 tbr, 2400 tbn, 4800 tbc
    Metadata:
      creation_time   : 2008-05-27 18:32:32
    Stream #0.1(eng): Data: tmcd / 0x64636D74
    Metadata:
      creation_time   : 2008-05-27 18:32:32
    Stream #0.2(eng): Audio: aac, 48000 Hz, 5.1, s16, 437 kb/s
    Metadata:
      creation_time   : 2008-05-27 18:32:32
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by richardp » Sat Jan 05, 2013 7:24 pm
Nope... I download a new H264 stream (Simpsons trailer) - verified there are 2 streams.
wget http://downloads.dvdloc8.com/trailers/d ... railer.zip

No Audio but video in VLC .. mplayer plays too fast

R

Can you perhaps share the first 10Megs of your sample stream (should be a couple of hundred frames) .. I am having no joy with the streams I am finding on the net.

Edit:
Same result if I generate my own h264 file in a mp4 container
Code: Select all
gst-launch-0.10 videotestsrc num-buffers=250 ! 'video/x-raw-yuv,format=(fourcc)I420,width=720,height=576,framerate=25/1' ! timeoverlay ! x264enc ! queue ! mux. audiotestsrc num-buffers=440 ! audioconvert ! 'audio/x-raw-int,rate=44100,channels=2' ! lame ! queue ! mux. mp4mux name=mux ! filesink location=test.mp4
RaspberryPi's galore
Solid run CuBox
ODroid U2
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am
by dickon » Sat Jan 05, 2013 11:35 pm
I'll see what I can do, but it'll have to be tomorrow.

Two King Cobras with the curry tonight. Never a good thing for productivity once home.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading
by STrRedWolf » Mon Jan 07, 2013 4:03 am
A few words of warning for folk:

  • If you're on Raspbian, your Mplayer and FFMPEG are broken. Blame Debian for that; you probably want the Medibuntu sources. Whoever does Raspbian needs to make a separate repository for media-related packages that aren't overpatched to remove "problematic" codecs like H264 and MPEG4. (Politics).
  • Also, if your libav* is from libav.org and not ffmpeg.org, I'm hearing word that the former is very very broken code verses ffmpeg's version. I think Debian carries the former instead of the latter. Try against the latter. It more than likely will work better. (reason? Politics at ffmpeg/libav's level).

Do we know what fork of libav* is from, and if Mplayer/mencoder is from Debian or Mplayerhq.hu?
Posts: 15
Joined: Fri Oct 05, 2012 1:47 am
by saintdev » Mon Jan 07, 2013 4:27 am
STrRedWolf wrote:
  • Also, if your libav* is from libav.org and not ffmpeg.org, I'm hearing word that the former is very very broken code verses ffmpeg's version. I think Debian carries the former instead of the latter. Try against the latter. It more than likely will work better. (reason? Politics at ffmpeg/libav's level).


Erm, please don't spread FUD when you have absolutely no idea what you're talking about.

FFmpeg regularly pulls updates from libav, and libav backports patches from FFmpeg. Both projects have fairly extensive automated testing. There is not much difference between most of the code in the two projects, save for the addition of a few obscure game codecs by FFmpeg.
SELECT `signature` FROM `users` WHERE `username`='saintdev';
Empty set (0.00 sec)
Posts: 39
Joined: Mon Jun 18, 2012 10:56 pm
by dickon » Mon Jan 07, 2013 10:13 am
I'm using a homebrew lavf, built from ffmpeg's git repository. I get audio and video in sync on the 720p Big Buck Bunny, but I can't seek. Playback is via mplayer on my Debian desktop, from deb-multimedia.org.

H.264 is 'problematic' not because of 'politics', but because of patents and licensing issues. deb-multimedia.org and their ilk simply ignore this; Debian feel they can't.
Posts: 115
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading