Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Webrtc to rtmp using ffmpeg for live streaming from webcam to browsers and mobile
6 février 2017, par Omar SuleimanI am new in live streaming, and i am working on the website to allows user to broadcasting and visitors can watch and listen the video, I use webrtc from webcam and the url is blob, so I can not find the best way to transcode webrtc to rtmp or hls to show the live streaming in the browsers as a flash and on mobile as hls. I dont know from where can i start.
what is the best way for transcoding (ffmpeg or red5 or nginx or what) - like: 1 broadcaster to 1000 viewers can watch and listen and there is many broadcasters also.
what about CPU usage.
I am used asp.net MVC
your help is very appreciated. Thanks.
-
Cannot play MPEG-TS from webcam using ExoPlayer on Android or Quicktime on Mac
6 février 2017, par GalaxyI'm trying to use FFmpeg to stream my webcam to an Android device based on the HttpLiveStreaming(HLS). In order to play the MPEG-TS on Android, I use ExoPlayer.
FFmpeg streaming command:
ffmpeg -f avfoundation -video_size 1280x720 -framerate 30 -i "0" -vcodec libx264 -preset veryfast -f flv rtmp://localhost:1935/hls/test
When I used VLC to play the MPEG-TS, everything was OK. However, I failed to play it using the ExoPlayer on Android or the Quicktime(Safari) on Mac OS. Then I tried to find out the reason.
I tried to stream a mp4 video using FFmpeg in the same way. For example:
ffmpeg -re -i test.mp4 -vcodec libx264 -preset veryfast -f flv rtmp://localhost:1935/hls/test
I can play it using both ExoPlayer and Quicktime.
The only difference I found between these two cases is that the Webcam's capturing format is YUY2 while the mp4 video is YUV420 and they used different H264 encoders. I guess the H264 decoders for YUY2 and YUV420 are not the same.
I'm not sure if my inference was correct and the only solution to this problem is to convert YUY2 to YUV420 before streaming.
I hope someone using Mac could try to stream the Facetime camera using the same way as me and see if it can be played in the Safari.
-
FFMPEG python check if dictionary key exists
6 février 2017, par Georgе StoyanovI want to check if there is a dictionary key:
"data["streams"][1]["codec_name"]"
and if there is one to print the values of couple of keys and if not to print "No Audio". Actually if there is no audio the whole data["streams"][1] is missing. Right now the script is always returning No Audio even if the audio exists. What I am doing wrong?#!/usr/bin/env python import subprocess import json input_file = raw_input("Please enter the input file path: ") returned_data = subprocess.check_output(['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', input_file]) data = json.loads(returned_data.decode('utf-8')) print "==========================Audio=============================" if 'data["streams"][1]["codec_name"]' in data: print "Codec: %s" %(data["streams"][1]["codec_name"]) print "Sample Rate: %.3f KHz" %(int(data["streams"][1]["sample_rate"])/1000) print "Bitrate: %d Kbps" %(int(data["streams"][1]["bit_rate"])/1000) else: print "NO AUDIO"
-
Run a Linux shell script using a file inserted by the user in Python
6 février 2017, par Georgе StoyanovI am trying to run a ffprobe command using a pre-defined by the user input file in Python. And then I will use the generated file by this command to report some parameters in a more organized view. My code is:
import subprocess import json cmd = "ffprobe -v quiet -print_format -show_format -show_streams /path/to/input/file.mp4 > output.json" subprocess.call(cmd.split()) with open('output.json') as json_data: data = json.load(json_data) json_data.close() d = float((data["streams"][0]["duration"])) t = (data["streams"][0]["time_base"]) fps = [float(x) for x in t.split('/')] print "==========================General==========================" print "Name of the File: %s" %(data["format"]["filename"]) print "Duration: %.2f minutes" %(d/60) print "Frame Rate: %d fps" %fps[1] print "Bitrate: %.2f Mbps" %(float(data["format"]["bit_rate"])/1000000)
I was thinking to use:
input_file = ("Please enter the path to your input file: ")
and then use the input_file in the ffprobe command on the second line of my code. But I am not sure how I can do it within the quotes. Please also note that the file name should also include an extension like input.mp4. -
need script to delete after convert, ffmpeg
6 février 2017, par GsharksI'm a virgin to this whole CMD scene. I can really use some help. I just want to delete the file after it converts. Heres what I have so far: update: I figured how to delete after conversion, but its after everything is converted, I want to delete the file RIGHT AFTER EACH CONVERT...
dir/b/s *.mkv >mkvlist.txt for /F "delims=;" %%F in (mkvlist.txt) do ffmpeg.exe -i "%%F" -vcodec copy -acodec copy "%%~dF%%~pF%%~nF.mp4" del mkvlist.txt del *.mkv