I'm trying to stream a .ts file containing H.264 and AAC as an RTP stream to an Android device.
I tried:
.\ffmpeg -fflags +genpts -re -i 1.ts -vcodec copy -an -f rtp rtp://127.0.0.1:10
000 -vn -acodec copy -f rtp rtp://127.0.0.1:20000 -newaudio
FFMPEG displays what should be in your SDP file and I copied this into an SDP file and tried playing from VLC and FFPLAY. VLC plays audio but just gives errors re: bad NAL unit types for video. FFPLAY doesn't play anything.
My best guess if that the FFMPEG H.264 RTP implementation is broken or at least it doesn't work in video passthru mode (i.e. using the -vcodec copy).
I need a fix for FFMPEG or an alternate simple open-source solution. I don't want to install FFMPEG in my Android client.
thanks.
Have you tried vlc?I once used vlc for streaming. You can have a look at here.
Related
I am attempting to generate an MP4 video by combining images and audio with FFmpeg-Kit-React-Native but it is not being displayed in web browsers.
For your reference I'm attaching the package link below:
ffmpeg-kit-react-native
The commands I utilized to produce the video are as follows:
-i ${imageFile} -i ${audioFile?.uri} -vf scale=480:360 -f mp4 ${outputFile}
-loop 1 -i ${imageFile} -i ${audioFile.uri} -shortest -acodec copy ${outputFile}
-i ${imageFile} -i ${audioFile?.uri} -b:v 2M -vf scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1 -pix_fmt yuv420p ${outputFile}
-i ${imageFile} -i ${audioFile?.uri} -vf scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1 -f mp4 ${outputFile}
I have attached a link to the video I generated using a single image and one audio file
Additionally, I am unable to install external encoding packages such as full-gpl, full, https-gpl, and min-gpl on the Android side.
You do not specify a video codec for your format (-f mp4). In that case ffmpeg uses 'a' default video codec. If i run ffprobe on your file, the output for the video stream is:
Video: mpeg4 (Simple Profile)
According to https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#mpeg-4_mp4, firefox does not support this codec (as to the other browsers, please do your own research).
The solution is to use one of the supported video codecs, e.g. AVC (H.264) or VP9.
To specify the H.264 codec in ffmpeg use the argument -codec:v libx264.
To list all available encoders, run: ffmpeg -encoders
If the required codecs are not listed in the output, you have to configure ffmpeg and specify, e.g. --enable libx264.
See also: FFmpeg - H.264 Video Encoding Guide
I need to capture an audio/video rtsp stream uncompressed in a file from ipcamera. Audio (pcm_alaw) and video (h264) must be synchronized. It is necessary that the file does not get corrupted if the camera loses the connection for a few moments (mp4).
At the moment I use the command below, but the ts codec does not support pcm_alaw and therefore the audio is not heard:
ffmpeg -stimeout 2000000 -rtsp_transport tcp -i rtsp://admin:1234#192.168.5.22/h264 -c:v copy -c:a copy -f mpegts -y main.ts
I use the mpegts codec because I need to check the duration of the capture in real time with the command:
ffprobe -i /home/pi/NAS/main.mov -show_entries format=duration -v quiet -of csv="p=0"
If i use mkv or avi its output would be:
N/A
The verification of the duration is important because I capture files of about 3 hours and at my choice I perform some data while the capture is in progress. I prefer not to compress the audio because I have often noticed some asynchrony with respect to the video when cutting.
Thank you.
Instead of -c:a copy you can use -c:a aac or -c:a mp3 to convert the audio stream before you save it.
MPEG-TS h264 is only compatible with mp3 or aac (source).
I'm trying to stream .wav audio files via RTP multicast. I'm using the following command:
ffmpeg -re -i Melody_file.wav -f rtp rtp://224.0.1.211:5001
It successfully initiates the stream. However, the audio comes out very choppy. Any ideas how I can make the audio stream clean? I do not need any video at all. Below is a screenshot of my output:
Here's some examples expanding upon the useful comments between #Ralf and #Ahmed about setting asetnsamples and aresample, and also those mentioned in the Snom wiki. Basically one can get smoother multicast transmission/playback using these approaches for G711/mulaw audio:
ffmpeg -re -i Melody_file.wav -filter_complex 'aresample=8000,asetnsamples=n=160' -acodec pcm_mulaw -ac 1 -f rtp rtp://224.0.1.211:5001
Or using higher quality G722 audio codec:
ffmpeg -re -i Melody_file.wav -filter_complex 'aresample=16000,asetnsamples=n=160' -acodec g722 -ac 1 -f rtp rtp://224.0.1.211:5001
My goal is transcode this file with ffmpeg.
https://drive.google.com/open?id=1ATuPtSbZeQLexB1HBP509hInDOTyfEV8
ffplay fails to analize or play this file and returns:
Invalid pixel format.
This is the simply command:
ffplay -i testproxy.mxf
ffprobe -i testproxy.mxf -show_stream
It has been encoded by avid Interplay whit this targhet quality:
H.264 800Kbps Proxy 1080i 25
Maybe it's a raw file? and need same specification ahead input file?
Any suggestion is appreciated
Either Interplay doesn't write* a standard MXF or there's a limitation in ffmpeg's mxf demuxer.
But you can play the file with
ffplay -vcodec h264 testproxy.mxf
and similarly, you can transcode using
ffmpeg -vcodec h264 -i testproxy.mxf ...
*more likely, as mediainfo also fails to detect the video codec.
I've got a problem with streaming audio on my website. I thought I could put the MP3 file inside an MP4 container with h264 codec, so I can use pseudo-streaming ability of mp4 codec.
The code I'm using to convert my files is:
ffmpeg -i 1.mp3 -y -b:a 32K -vn 1.mp4
Pseudo-streaming (seeking in not-loaded parts of media) now works in HTML5 player but not in any Flash media players such as JWPlayer or FlowPlayer.
I've tested my files on both Apache server with h264 module enabled and Nginx with mod_mp4 enabled, but without any lucks.
I tried MP4Box, QTIndexSwapper and even creating a real video file by mixing of an image loop and my audio file.
ffmpeg -y -i joojoo.png -i 2.mp3 -vcodec mjpeg havij.mp4
MP4Box -add havij.mp4 -isma havij_new.mp4
What am I doing wrong? What can I do to make it work?
You have to hint the file. Check out mp4box -hint