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

Packager fails to parse WebM from ffmpeg over udp #172

Closed
iSchluff opened this issue Nov 18, 2016 · 9 comments
Closed

Packager fails to parse WebM from ffmpeg over udp #172

iSchluff opened this issue Nov 18, 2016 · 9 comments

Comments

@iSchluff
Copy link

@iSchluff iSchluff commented Nov 18, 2016

Hi.
With the commands

ffmpeg -y -hide_banner -analyzeduration 10000 -i rtmp://foo/rtmp/bar \
  -map v:0 -map a:0 \
    -c:v libvpx -threads 4 -aspect 16:9 -pix_fmt yuv420p -deadline realtime -crf 10 \
    -s 640x360 -bufsize 2.0M -b:v 0.8M -maxrate:v 1.0M -keyint_min 50 -g 50 -r 25 \
    -c:a libvorbis -ar 44100 -ac 2 -b:a 192k \
    -f webm udp://127.0.0.1:5001

and

shaka-packager \
"input=udp://127.0.0.1:5001,stream_selector=video,init_segment=v360.webm,segment_template=v360_\$Number\$.webm,bandwidth=800000" \
  --profile live --single_segment=0 --dump_stream_info \
  --mpd_output ${DASH_PREFIX}/manifest.mpd

The packager reports

[1118/091808:INFO:demuxer.cc(60)] Initialize Demuxer for file 'udp://127.0.0.1:5001'.
[1118/091808:ERROR:demuxer.cc(99)] Not implemented reached in shaka::media::Status shaka::media::Demuxer::Initialize()
[1118/091808:ERROR:packager_main.cc(314)] Demuxer failed to initialize: 4 (UNIMPLEMENTED): Container not supported.
@kqyang
Copy link
Collaborator

@kqyang kqyang commented Nov 18, 2016

Is shaka-packager started after ffmpeg or before ffmpeg? If it is the former, can you try starting shaka-packager first?

I think the problem is that ffmpeg only transmits the init-segment in the beginning of the stream; the init-segment contains the track information, which is necessary to setup the packaging.

@iSchluff
Copy link
Author

@iSchluff iSchluff commented Nov 18, 2016

If I start the packager first I get

[1118/200840:INFO:demuxer.cc(60)] Initialize Demuxer for file 'udp://127.0.0.1:5001'.
[1118/200847:ERROR:packager_main.cc(314)] Demuxer failed to initialize: 8 (PARSER_FAILURE): Cannot parse media file udp://127.0.0.1:5001

instead once the ffmpeg stream starts.

@kqyang
Copy link
Collaborator

@kqyang kqyang commented Nov 18, 2016

I took a look at the output generated by ffmpeg. There were two tracks generated. However, the tracks element and the second track_entry element (for audio) indicate "unknown size".

tracks (unknown size)
  track_entry
    video
  track_entry (unknown size)
    audio

Right now, shaka packager does not handle unknown sizes except for Segment element and Cluster element: https://github.com/google/shaka-packager/blob/master/packager/media/formats/webm/webm_parser.cc#L752. They are needed as the size of these elements would not be known in live streaming case. But I don't understand why ffmpeg generates unknown size for "tracks" and "track_entry" elements, which can be computed easily during encoding.

An update is needed in either ffmpeg (to properly compute the size for tracks and track_entry elements) or shaka-packager (to support unknown size tracks / track_entry elements).

If you remove the audio output from transcoding, it should work, i.e.

ffmpeg -y -hide_banner -analyzeduration 10000 -i rtmp://foo/rtmp/bar \
  -map v:0 -map a:0 \
    -c:v libvpx -threads 4 -aspect 16:9 -pix_fmt yuv420p -deadline realtime -crf 10 \
    -s 640x360 -bufsize 2.0M -b:v 0.8M -maxrate:v 1.0M -keyint_min 50 -g 50 -r 25 \
    -an \
    -f webm udp://127.0.0.1:5001
@vaage
Copy link
Member

@vaage vaage commented Mar 2, 2018

@iSchluff is this still an issue for you? @kqyang do we have an action item for this issue?

@kqyang
Copy link
Collaborator

@kqyang kqyang commented Mar 2, 2018

We should check if it is already fixed in ffmpeg. If not, we need to either fix the problem in ffmpeg or handle it in packager.

@vaage
Copy link
Member

@vaage vaage commented Mar 2, 2018

So I ran this again.

I used this copy of Sintel as input and ran these commands in parallel.

ffmpeg -y -hide_banner -analyzeduration 10000 -i sintel-1024-surround.mp4 -map v:0 -map a:0 -c:v libvpx -threads 4 -aspect 16:9 -pix_fmt yuv420p -deadline realtime -crf 10 -s 640x360 -bufsize 2.0M -b:v 0.8M -maxrate:v 1.0M -keyint_min 50 -g 50 -r 25 -c:a libvorbis -ar 44100 -ac 2 -b:a 192k -f webm udp://127.0.0.1:5001

packager "input=udp://127.0.0.1:5001,stream_selector=video,init_segment=v360.webm,segment_template=v360_\$Number\$.webm,bandwidth=800000" --profile live --single_segment=0 --dump_stream_info --mpd_output manifest.mpd

If I started the packager first, everything worked. If I started FFMPEG first I got:

[0302/151055:INFO:demuxer.cc(88)] Demuxer::Run() on file 'udp://127.0.0.1:5001'.
[0302/151055:INFO:demuxer.cc(160)] Initialize Demuxer for file 'udp://127.0.0.1:5001'.
[0302/151055:ERROR:demuxer.cc(204)] Not implemented reached in shaka::Status shaka::media::Demuxer::InitializeParser()
[0302/151055:ERROR:packager_main.cc(470)] Packaging Error: 4 (UNIMPLEMENTED): Container not supported.

I was using a debug local build of the packager based off our master branch and was using version 3.4.1-1 of FFMPEG.

@kqyang, since it works as long as you start the packager first, are we comfortable closing this issue?

@kqyang
Copy link
Collaborator

@kqyang kqyang commented Mar 3, 2018

@vaage Which version of ffmpeg are you using?

EDIT: Ooops, actually @vaage already mentioned the version of FFmpeg, which is 3.4.1-1.

@vaage
Copy link
Member

@vaage vaage commented Mar 5, 2018

Commit 033fa651055f6e8cc02844f86711bb8aa5ba8a13 ("Removed Old WebVtt Code") in master. I have one more commit after it.

@iSchluff
Copy link
Author

@iSchluff iSchluff commented Mar 5, 2018

Yeah, I can reproduce this works with ffmpeg-3.4 if the packager is started before ffmpeg.

@iSchluff iSchluff closed this Mar 5, 2018
@kqyang kqyang added external and removed needs triage labels Mar 5, 2018
@shaka-bot shaka-bot added the archived label May 4, 2018
@google google locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants