Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libav 11beta #476

Closed
wants to merge 73 commits into from
Closed

Libav 11beta #476

wants to merge 73 commits into from

Conversation

1stsetup
Copy link
Contributor

@1stsetup 1stsetup commented Sep 9, 2014

During my tests of streaming to a ChromeCast dongle the audio most of the times did not come through or was distorted.

Therefore I tried to fix it in the code and this is the result.
It still contains extra debug lines and I can remove them.
It can now also down or upsample channels on request but I have not yet changed this in the code so you can specify this on the GET URL.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
…ng functions.

Added conversion/resampling functionality.
Added using of libav audio fifo buffer.

Works with latest git master of libav.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
…only once.

Second we now try to determine the best fitting sample_fmt and channel_layout for the encoder. Based on was is has available.

Tested with encoder MPEG2, AAC and Vorbis.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
@1stsetup
Copy link
Contributor Author

Finalized the update to the latest version of libav and using the new decoding and encoding functions.
This code needs the latest libav git master

@csutcliff
Copy link

Trying this out with a recent (today) git build of libx264 and libav, seems to go ok to begin with but no video (sound is transcoded and plays) then this line appears in the log:

"transcode: No output from avcodec_encode_video2()"

Relevent parts of the log: http://pastebin.com/kb0uvjuk

Any ideas?

…uffer.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
@1stsetup
Copy link
Contributor Author

I have just made a small change. It did a reset of an index when it did not receive a fully encoded packet. But not getting an encoded packet and not receiving an error means the encoder needs more data which probably will come in on the next packet to decode and encode.
Please retry my latest commit.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
@1stsetup
Copy link
Contributor Author

I just ran a test in converting MPEG2VIDEO 720x576 ==> H264 600x480 and tvheadend crashed. Currently investigating.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
…m. Now they are.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
The flushing should only be done completely at the end when no more new packet will receive. In our case never as the listening end most of the time already closed the connection.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
@1stsetup
Copy link
Contributor Author

Video conversion to H264 is now working. Only audio is out of sync. Probably has to do with the fact that the pts is not set alright. Next thing on the todo list.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
Signed-off-by: Michel Verbraak <info@1st-setup.nl>
@1stsetup
Copy link
Contributor Author

Please try this latest version.
transcoding to MPEG2VIDEO is working now as expected creating the right pkt_headers.
Audio is still out of sync for MPEG2VIDEO en H264.

@csutcliff
Copy link

VP8 and MPEG2 are working well for me (sidenote: the tvhclient android app calls for mpeg2 using "MPEG4VIDEO" instead of "MPEG2VIDEO" and so doesn't work)

H264 shows a single frame forever whilst audio plays as normal.

P.S is VP8 meant to be really heavy on the cpu or do I have another problem?

@1stsetup
Copy link
Contributor Author

On my machine VP8 also uses more cpu than h264.

Are you using my Cast branch of TVHClient where the mpeg2/mpeg2video problem is in?

@csutcliff
Copy link

I was using the Google play store version as I did not know you had modified it, I'll try your version!

@l3rady
Copy link

l3rady commented Sep 28, 2014

Compiled and Installed latest git master of libav and running this branch but when trying:

/stream/channel/0d0f074e16d0a199820f702044bf657a?mux=mpegts&acodec=aac&vcodec=H264&transcode=1&resolution=576

I'm still getting errors:

2014-09-28 19:04:25.116 [  ERROR] transcode: Unable to find H264 encoder
2014-09-28 19:04:25.116 [   INFO] transcode: 1:MPEG2VIDEO ==> Passthrough
2014-09-28 19:04:25.118 [   INFO] transcode: 2:MPEG2AUDIO ==> AAC
2014-09-28 19:04:25.118 [   INFO] transcode: 3:TELETEXT ==> Filtered
2014-09-28 19:04:25.118 [   INFO] transcode: 4:TEXTSUB ==> Passthrough
2014-09-28 19:04:25.949 [  ERROR] transcode: Unable to open aac encoder

@1stsetup
Copy link
Contributor Author

Did you compile libav with an aac library into it. Like fdk-aac (https://github.com/mstorsjo/fdk-aac.git).
First compile and install fdk_aac and then configure libav with '--enable-libfdk_aac'.

My configure line for libav is: ./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu/ --shlibdir=/usr/lib/x86_64-linux-gnu/ --enable-libfdk_aac --enable-nonfree --enable-shared --enable-vaapi --enable-libvpx --enable-libvorbis --enable-libx264 --enable-gpl

@1stsetup
Copy link
Contributor Author

And if you want to know more about libav aan aac see https://wiki.libav.org/Encoding/aac

@l3rady
Copy link

l3rady commented Sep 29, 2014

Thanks for the extra help. I hadn't done all that but I have now. But I'm still getting the same errors.

@perexg
Copy link
Contributor

perexg commented Oct 10, 2014

Merged (in one patch) - 4e098bd .

Some updates:

39961d4
0632c29

.. but it does not work with my ffmpeg libs (previous code didn't work either):

 DEBUG]:transcode: Using decoder mpeg2video
  DEBUG]:transcode: Using encoder libx264
   INFO]:transcode: 5:MPEG2VIDEO 720x576 ==> H264 480x384
  DEBUG]:transcode: Using decoder mp2
  DEBUG]:transcode: Using encoder libvorbis
   INFO]:transcode: 2:MPEG2AUDIO ==> VORBIS
  ERROR]:transcode: Unable to decode video (-22)
WARNING]:transcode: Detected framedrop in audio
  TRACE]:transcode: Decoded packet. length-consumed=-22 from in-length=768, got_frame=0
  TRACE]:transcode: Did not have a full frame in the packet
  ERROR]:transcode: Unable to decode audio (-22)

Also. I would recommend to use valgrind to check for leaks (and there are many)...

@perexg perexg closed this Oct 10, 2014
@1stsetup
Copy link
Contributor Author

perexg what is the source of your stream? Satellite or something else. When Satellite which one. I am in Europe and have a satellite. Maybe I can reproduce.

Which OS are you running on and which version of libav?

@perexg
Copy link
Contributor

perexg commented Oct 10, 2014

I'm using ffmpeg which might be the culprit.. Also other on IRC reports that ffmpeg support is broken with this change...

ffmpeg-libs-2.1.5-1.fc20.x86_64

@1stsetup
Copy link
Contributor Author

My patch only works with libav and then also latest git (tag v11 will work)

@perexg
Copy link
Contributor

perexg commented Oct 10, 2014

OK, Made some fixes in da9b9b5 . Could you check with libav ?

@InuSasha
Copy link
Contributor

i got an compile error

src/plumbing/transcoding.c:875:10: error: ‘AVFrame’ has no member named ‘channels’
frame->channels = octx->channels;
^

@perexg
Copy link
Contributor

perexg commented Oct 10, 2014

Fixed in 930bd97 .

@InuSasha
Copy link
Contributor

builds now fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants