Use of pipe:// to stream a mp4 file
Added by David jrm about 8 years ago
Hi all,
Im trying to stream a .mp4 file through a TVH mux, but so far I have been able to take the audio but not the video.
This is what I have set in the mux:
pipe:///usr/bin/ffmpeg -loglevel fatal -i PATH_TO_THE_MP4 -codec copy -acodec copy -metadata service_provider=XXX -metadata service_name=XXX -tune zerolatency -f mpegts pipe:1
Is there anybody that use this and could let me know what I'm missing? I have seen several examples but not able to have it working at all.
Thanks
Replies (13)
RE: Use of pipe:// to stream a mp4 file - Added by Jonathan Thomson about 8 years ago
Without trying it, I'd say this is your issue;
pipe:///usr/bin/ffmpeg -loglevel fatal -i PATH_TO_THE_MP4 -codec copy -acodec copy -metadata service_provider=XXX -metadata service_name=XXX -tune zerolatency -f mpegts pipe:1
The -codec parameter should be -vcodec.
RE: Use of pipe:// to stream a mp4 file - Added by David jrm about 8 years ago
Hi Jonathan,
I tried this already but unfortunately the outcome is the same... Should I specify any additional string there?
Thx
RE: Use of pipe:// to stream a mp4 file - Added by Jonathan Thomson about 8 years ago
This is the command I use to get an MP4 (h264) feed from my IP cameras into TVHeadend:
pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://usrr:pass@CameraIPAddress -vcodec copy -acodec copy -metadata service_provider=STRING -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1
Have you got debug logging enabled to see what is falling over?
RE: Use of pipe:// to stream a mp4 file - Added by David jrm about 8 years ago
Yes, but nothing about the video codec there... it is taking the file as audio only. Maybe due the codec used to create that file.. not sure.
I have tested the same with a .mkv (adding -bsf:v h264_mp4toannexb,dump_extra) and works perfectly, so not sure what could be the reason behind the other behavior....
Will keep testing.
Thanks
RE: Use of pipe:// to stream a mp4 file - Added by Jonathan Thomson about 8 years ago
Sounds like it could be a codec issue, if using the -vcodec copy flag, ffpmeg just passes the codec as-is to the output, and if the client doesn't understand the stream it will render only the video.
Have you tried opening the piped stream in VLC to see what video codec (if any) is being passed to the client?
I've just used the following to successfully pipe an MP4 file (a video downloaded from YouTube) to TVHeadend and I get both audio and video;
pipe:///usr/bin/ffmpeg -loglevel fatal -i /tmp/sample.mp4 -vcodec copy -acodec copy -metadata service_provider=STRING -metadata service_name=STRING -f mpegts -tune zerolatency pipe:1
RE: Use of pipe:// to stream a mp4 file - Added by Jonathan Thomson about 8 years ago
If you change the -vcodec copy to one of the following (depending upon which are available on your system) do things work then?
h264
libx264
h265
libx265
RE: Use of pipe:// to stream a mp4 file - Added by David jrm about 8 years ago
Thanks Jonathan, changing the codec to any of those, it works! So definitely something codec related that ffmpeg doesn't like the copy option
Thx!
RE: Use of pipe:// to stream a mp4 file - Added by Robert Cameron about 8 years ago
The copy -c:v copy
(for copying the video codec) should be fine and cause no problems. The problem is because of the MP4 to MPEG-TS format translation, you also need -bsf:v h264_mp4toannexb
in there as well.
So, something like:
pipe://ffmpeg -i sample.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts pipe:1
(A note about the -tune zerolatency
that I see all over ffmpeg
command lines in the TVH forums:
-tune
is for passing parameters to libx264. If you have not specified -c:v libx264
or -vcodec libx264
, the option is pointless and does nothing. In this example, since you are not actually encoding anything, it serves no use.)
RE: Use of pipe:// to stream a mp4 file - Added by David jrm about 8 years ago
With the above string I got the same outcome, so only audio, but replacing "-c copy -bsf:v h264_mp4toannexb" by "-vcodec h264" it works properly
RE: Use of pipe:// to stream a mp4 file - Added by Robert Cameron about 8 years ago
Then, perhaps the initial video codec of your MP4 is the problem ...
What is the output of ffprobe
?
RE: Use of pipe:// to stream a mp4 file - Added by David jrm about 8 years ago
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Duration: 01:13:53.14, start: 0.000000, bitrate: 1317 kb/s
Stream #0:0(und): Video: mpeg4 (Advanced Simple Profile) (mp4v / 0x7634706D), yuv420p, 512x384 [SAR 1:1 DAR 4:3], 1188 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 29.98 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 122 kb/s (default)
Metadata:
handler_name : SoundHandler
RE: Use of pipe:// to stream a mp4 file - Added by Robert Cameron about 8 years ago
Well that explains it. MPEG-4/Advanced Simple Profile is similar DivX, and is not H.264.
That is why copying the codecs and putting it into a MPEG-TS stream did not work, because MPEG-TS does not support MPEG-4/H.263 video.
You either need to re-encode your source video, or encode it to something else when piping it to TVH.