I'm building an application in C++ that should use FFmpeg to send a live stream to Flash Media Server. For starters I would like to be able to send a .mp4 file. Using the FFmpeg .exe I can do it like this:
ffmpeg -re -i TEST.mp4 -vcodec libx264 -f flv rtmp://[host]/[application]/[stream]
How would you go about implementing something like that in code? I can only figure out how to read data, not write it. I have found functions to open input but nothing about how to connect to FMS. All write functions I can find seems to be how to write to file. Please advice.
Related
When I used python audio segment to open a .wav file and divide it into many .wav files i am getting this error
"C:\Python27\lib\site-packages\pydub\utils.py:165: RuntimeWarning: Couldn't find
ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work"
, RuntimeWarning)"
It seems like you don't have ffmpeg, which is listed in the dependencies section of the Pydub GitHub. However, it is only required if you wish to load or save non-WAV files.
This message is just a warning, if you're using Pydub solely for WAV files, it is safe to simply ignore it.
I need a simple ffmpeg conversion task to be done inside an application:
ffmpeg -i input_file.m4v -vcodec copy -acodec copy -vbsf h264_mp4toannexb output_file.ts
This works well using the terminal. I've successfully compiled ffmpeg's static lib. Some examples work perfectly, that means the lib is working. How do I implement the behaviour of the above command line with this library?
I looked into ffmpeg.c. But there is so much code inside that it took me hours to get an idea on how it works. Finally I still don't really understand the whole structure.
I would be very happy if someone could help me understanding how to use the library to do the very same what the example command line does. (At the end I just want to transmux mp4 files to ts files without reencoding)
Thanks in advance
Jack
Am trying to convert .264 files to mp4 or avi or wav format.
I have tried ffmpeg but no luck.
I am using python 2.7 on windows 7.
Please help!!
If you have a .264 file I would suggest to wrap it in a mp4 container (no re-encode required that way).
Try the following:
ffmpeg -i INPUT.h264 -c:v copy OUTPUT.mp4
Moreover, .264 contains video only so there's no way you're gonna convert it to WAV which contains audio only.
I use this code to create an mkv file with a webm video:
Code
The video that is generated can be opened in vlc and mplayer, however, firefox sais: video can't be played because the file is corrupt
How do I have to change the header so I can open it in firefox, too?
Found the solution... this code actually outputs a so called ivf format, while the real mkv output code can be found here:
(Much more complicated, though)
I'm currently working on converting h.264 elementary stream (file with postfiix .264) to transport stream (file with postfix .ts). I have finished the conversion successfully using ffmpeg command line "ffmpeg -i in.264 -an -vcodec copy -f mpegts out.ts".
Now I want to implement this conversion using my own C++ code, by calling ffmpeg's libraries. I have downloaded precompiled ffmpeg libraries (libavcodec, libavformat etc). My input h.264 is prerecorded file, not live stream, and so as my output .ts file. So my question is which functions in the library should I call to implement the conversion?
You will see an example file named ffmpeg.c after you install ffmpeg in Linux. There are many options to set the decoding parameters in this file e.g. opt_audio_codec, opt_video_codec, opt_audio_rate, opt_video_rate, opt_default etc. Just set the necessary parameters from your command(-i in.264 -an -vcodec copy -f mpegts out.ts) using appropriate functions before calling "transcode" or "av_encode" function from "main" function of ffmpeg.c file.
It's not as simple as list the library calls. Here is an old tutorial that will help you get started reading the input file. There is also an example called decoding_encoding.c that is included with the ffmpeg source. These should help you get started.
You don't need to do it in your own code. You can just spawn the ffmpeg process programatically instead. Use CreateProcess on Windows, or spawn on Linux.