How to stream a mp4 video over stdin/stdout? - linux

I need to stream a video to stdout and then read that stream from stdin again to display it. At the end there will be an application in the middle to handle the networking but for now I want to test it directly. When trying this the video timer works however the screen stays black.
vlc -I dummy video.mp4 --sout '#standard{access=file,mux=ogg,dst=-}' | vlc -
I have also tried gstreamer however I was not able to successfully stream a video yet.
gst-launch-1.0 filesrc location=video.mp4 ! fdsink | gst-launch-1.0 fdsrc fd=0 ! decodebin ! autovideosink
Does anyone have an idea how to do this?
Thanks in advance!

I had to struggle quite a bit with VLC options to make this work, not even sure there are not extra / useless / wrong settings there (like the extra verbosity ;-)
For the record, I got help from VLC's wiki.
On the receiving side :
vlc rtp://192.168.56.101
On the sending side :
vlc -vvv video.mp4 --sout '#duplicate{dst=display,dst="transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:rtp{mux=ts,dst=192.168.56.101,sdp=sap,name="TestStream"}"}'
NB :
You'll see 2 videos outputs, which is due to the "duplicate" parameter in the streaming option (values of --sout)
Don't forget to add your workstation's IP address in both commands

Related

Incorrect values for song length (duration) in Mp3tag after ffmpeg FLAC to MP3 conversion

The problem
As per this post, I use the following command to convert a flac file to mp3 while keeping all metadata:
ffmpeg -i input.flac -ab 320k -map_metadata 0 -id3v2_version 3 output.mp3
When inspecting the converted mp3 file by right-clicking it, going to properties and then details, everything looks in order. The value for "Length" is correct.
When inspecting the converted mp3 file with Mp3tag, the value for "Length" is different. From my testing, the "Length" value is consistently about 28% of what it is supposed to be.
Normally, this isn't an issue. Most music players I use, read the correct length value, same as Windows. However, I've recently discovered that Spotify Mobile for some reason ignores the length value that can be seen in the Windows panel and uses the one that can be seen in Mp3tag.
I want to figure out what command I should use so that after the flac file has been converted to mp3, Mp3tag shows the correct length, and there by, Spotify Mobile reads the correct length as well.
What I have tried
1.
After converting the file to Mp3, I've tried reencoding the mp3 file into a... mp3 file using the following command:
ffmpeg -i original.mp3 -c:v copy -c:a mp3 -vn -ar 44100 -ac 2 -b:a 320k copy.mp3
As can be seen in the image above, this fixes the issue and the length is showing correctly in Mp3tag and in Spotify Mobile.
Issues with this: Reencoding reduces quality and I don't know how to combine the previous flac conversion command and this one into one line.
2.
I tried https://cloudconvert.com/flac-to-mp3 and it worked. The length is displayed correctly in Mp3tag. (What commands did they use on the server???)
Issues with this: I don't want to rely on a cloud service for conversion, I have a lot of files to convert and I'd prefer it to be done locally.
Some demo files
Here is a folder with a flac file, a bad mp3 file (wrong length) and a good mp3 file. It looks like if you preview the music in google drive, it also plays the wrong length for the bad mp3 (39s not 2m19s), while vlc, groove player, spotify (desktop not mobile) all play the correct full length (2m19s) for the bad mp3 file.
Folder: here's the link
It seems I had an outdated version of ffmpeg... (ffmpeg version git-2020-05-23-26b4509) I updated to the latest version and the issue went away. Learned my lesson the hard way.
Would still appreciate an explanation on why this was happening. I'm curious. Why were there two values for length?

Detect and remove silence from audio file using gstreamer

Is there any way by which we can detect and remove silence from an audio file using GStreamer.
Currently, by using level I am able to find the start and end time of silence present in the audio file but how do I remove this silence and produce an output which doesn't have silence in it. I tried using gst_element_seek but no luck there.
There is a removesilence element in gstreamer-plugins-bad, perhaps it is what you want.
Edit: adding example
gst-launch-1.0 autoaudiosrc ! audioconvert ! removesilence remove=true ! fakesink silent=false -v
This launch line will print data to the screen whenever removesilence output buffers, it will be capturing audio from the microphone of your system. It will only output audio when some noise is detected.

Extract audio from video with FFMPEG but not the same duration

My problem is that i need to extract with FFMPEG the audio contained in a video with the same duration. But for some files that i tested, the audio's duration is sometimes shorter than the video's duration. I need to have the exact same duration between the audio and the video file.
The command that i have already tried is this following:
ffmpeg -i input_video.mp4 output_audio.wav
How can i fix this with options in my command ?
I found the solution. To get an audio extract with the exact same length. I use the option -async 1 like this:
ffmpeg -i input_video.mp4 -async 1 output_audio.wav

mplayer playing gif animation at full screen?

I'm not familiar with mplayer and the tons of option seem like a jungle to me, when all I want to do is show an endless looped gif animation at full screen on my RPi running raspbian.
Can anyone help me, please?
I am now working in Windows and using
mplayer -fs –mf fps=1:type=jpeg *.jpg mf://*.jpg –vo direct3d, -ao dsound-sub-fuzziness 1 -loop 100
to play jpg file in mplayer in fullscreen mode. I did't test on linux but i think
mplayer -fs –mf fps=1:type=gif *.gif mf://*.jpg -ao dsound-sub-fuzziness 1 -loop 100
should work for you too.
I video DJ using the RPi. Making mplayer full-screen is often harder than it should be. The switch to make mplayer full-screen is -fs. The problem is that many video outputs (-vo) do not support full-screen. If the -vo does not support -fs, I often get around this by using the RCA connection instead of the HDMI on a screen that does not display the entire frame. Try mplayer -fs file.gif and report back. Which -vo are you using?

Record screen and audio then generate to one video file in java.

I am writting a program as http://www.screencast-o-matic.com/. I used applet and import jmf.jar to my project. When I use it, it couldn't get anything capture devices so it couldn't capture audio and video.
I captured screen to video but it hadn't sound. I captured sound but it hadn't video. I use jmf to merger 2 stream to video file. But it error.
Everybody can help me to resol problem. Thanks your help.
You can use Xuggle-Xuggler http://www.javacodegeeks.com/2011/02/introduction-xuggler-video-manipulation.html API which is wrapper of FFmpeg command line tool. Both are open source.

Resources