videostreamer icon indicating copy to clipboard operation
videostreamer copied to clipboard

no audio?

Open jakecoffman opened this issue 5 years ago • 13 comments

Great project!

I'm not getting any audio with my stream. Is that to be expected?

jakecoffman avatar Jul 31 '18 18:07 jakecoffman

videostreamer -input='rtsp://user:[email protected]' -format=rtsp -fcgi=false

jakecoffman avatar Jul 31 '18 18:07 jakecoffman

Yeah, audio streams are not implemented unfortunately, just video. Supporting audio streams would not be particularly difficult to add I think. It just hasn't been a priority. Some code from https://github.com/horgh/audiostreamer could potentially be used at least as inspiration. I'd probably accept a PR!

horgh avatar Jul 31 '18 19:07 horgh

When this project was running under Windows, FFmpeg output Pipe protocol failed all the time, the prompt: Bad file descriptor. Is it related to the operating system? I use Windows 10. Can you help me?

qiu770 avatar Aug 27 '18 08:08 qiu770

Can you paste the output? And what flags are you running it with?

I've never tried it on Windows and don't have it available to try. It might be doable, I'm not sure.

horgh avatar Aug 28 '18 01:08 horgh

Thank you for your reply. Below is my input log.

I checked Windows and Linux, and there are differences in pipe usage. The failed return message is failed when the call to avformat_write_header is failed: Bad file descriptor returns a value of -9.

I'm trying to use this project in Linux

PS C:\Gopath\src\github.com\horgh\videostreamer> .\videostreamer.exe -host 127.0.0.1 -port 8080 -format mp4 -input 6.6.mp4 -verbose true -fcgi false 2018/08/28 10:32:14 Starting to serve requests on 127.0.0.1:8080 (HTTP) 2018/08/28 10:32:14 encoder: Waiting for clients... 2018/08/28 10:32:26 Serving [GET] request from [127.0.0.1:24982] to path [/stream] (0 bytes) 2018/08/28 10:32:26 encoder: New client 2018/08/28 10:32:26 mp4 [h264 @ 0000000000ce7520] A non-intra slice in an IDR NAL unit. [h264 @ 0000000000ce7520] decode_slice_header error Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '6.6.mp4': Metadata: major_brand : isom minor_version : 0 compatible_brands: mp41avc1 creation_time : 2018-06-06T11:35:16.000000Z encoder : vlc 2.2.8 stream output encoder-eng : vlc 2.2.8 stream output Duration: 00:02:09.68, start: 0.000000, bitrate: 284 kb/s Stream #0:0(eng): Audio: mp2 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 127 kb/s (default) Metadata: creation_time : 2018-06-06T11:35:16.000000Z handler_name : SoundHandler Stream #0:1(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x576 [SAR 1:1 DAR 11:9], 148 kb/s, 24.98 fps, 25 tbr, 1000k tbn, 50 tbc (default) Metadata: creation_time : 2018-06-06T11:35:16.000000Z handler_name : VideoHandler skip non-video stream 0 2018/08/28 10:32:27 encoder: Opened input skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 skipping packet from input stream 0, our video is from stream 1 in: pts:0 pts_time:0 dts:-80000 dts_time:-0.08 duration:40000 duration_time:0.04 stream_index:1 2018/08/28 10:32:27 writePacketToClients 2018/08/28 10:32:27 FD:= 652 outputURL:= pipe:652 output_format ifavformat_alloc_output_context2avformat_new_stream input->format_ctx->streams Output #0, mp4, to 'pipe:652': Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x576 [SAR 1:1 DAR 11:9], q=2-31, 148 kb/s avio_open opfilers 0 avformat_write_header [mp4 @ 0000000000d21c40] Empty MOOV enabled; disabling automatic bitstream filtering unable to write header avformat_write_header failed: Bad file descriptor

qiu770 avatar Aug 28 '18 02:08 qiu770

Does the same input file work on Linux?

It looks like you modified it to print out the error reported by avformat_write_header() already. Did you do that with av_err2str()?

You could try testing your input using the program in the cmd/remux_example directory. You'll probably have to modify it to read from a file (e.g., input_format will need to change). If it works, it would help us narrow down the problem. It would mean the file can be written fine using something other than pipes.

I don't know what's going on. It does look like there's something questionable with the pipe. I wonder if using named pipes would be better for Windows. Using the examples from http://trac.ffmpeg.org/ticket/986 with https://github.com/natefinch/npipe.

horgh avatar Aug 28 '18 03:08 horgh

Thanks for the replay.

I'm still trying to use the same input file for Linux.

Next I'll try to use a named pipe, and I need to make sure I can enter a pipe name that FFmpeg can use.

I looked at the FFmpeg source code and found no way to export video content into memory.

I tried to modify the pipe protocol into a file protocol, and as a result, I could output mp4 files normally.

Then try to write a service that puts the mp4 file directly into the browser. Chrome decoded incorrectly because of audio.

I'll write it down here if I get a result.

Thank you for your advice

qiu770 avatar Aug 28 '18 08:08 qiu770

I will keep you on watch until "AUDIO" is implemented. Thanks!

aapaeste avatar Nov 17 '19 01:11 aapaeste

Hi @horgh,

Nice work. Any chance for you to revisit the code and improve it with audio any time soon?

BR

avafinger avatar Apr 03 '21 00:04 avafinger

I recommend anyone looking for a complete solution with audio to check out https://github.com/pion/webrtc and https://github.com/deepch/RTSPtoWebRTC

jakecoffman avatar Apr 03 '21 00:04 jakecoffman

@jakecoffman

Thanks for the links but i really like his clean solution, it works very smoothly. I hope he gets motivated and can have a look at it again, I have a generic camera with sound and I can help debug and test the code if necessary.

Cheers

avafinger avatar Apr 03 '21 01:04 avafinger

I tried to add support for audio but hit a wall, my rtsp looks like this:

  Metadata:
    title           : h264.mp4
    comment         : TAS-Tech Live Cast
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1920x1080, 12.50 fps, 12.50 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
Output #0, mp4, to 'file:test_video_audio.mp4':
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1920x1080, q=2-31
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
[mp4 @ 0x55966f5131a0] Could not find tag for codec pcm_alaw in stream #1, codec not currently supported in container

The funny thing is the title: h264.mp4 :) So, I have to switch to MKV container or transcode to aac, need some sample code to be based on... Any thoughts?

avafinger avatar Apr 03 '21 21:04 avafinger

Muxed to mkv and now i have video and audio, unfortunately mkv is about 10% bigger in size than mp4. (without the audio and same condition). If anyone interested I can push the changes to my github, but I changed the C code only, I am not a go programmer.

avafinger avatar Apr 04 '21 22:04 avafinger