I'm trying to decode a .m3u8 to mp4 using ffmpeg, but keep getting this error message:
Error applying bitstream filters to an output packet for stream #0:0
https://....../audio.m3u8: Invalid data found when processing input.
This is the command I'm using:
ffmpeg -y -f hls -i https://www.video-cdn.com/video/encrypt/7b35e1550e7dac1fa9d6f34eb0b55148/R915dD-90d3ac3f-48d9-4da1-84d4-d354a7ed03de/90d3ac3f-48d9-4da1-84d4-d354a7ed03de/audio.m3u8 -bsf:v h264_mp4toannexb,dump_extra -bsf:a aac_adtstoasc -map 0 -c copy -flags +global_header -max_interleave_delta 0 -f mp4 test.mp4
cmdExample
Any ideas?
The HLS stream is encrypted. You can see this because of the following line in the m3u8 playlist file:
#EXT-X-KEY:METHOD=AES-128,URI="blob:https://www.video-cdn.com/90d3ac3f-48d9-4da1-84d4-d354a7ed03de",IV=0xa2dccda29716795b6a22bec559144723
Since the URI is with the Blob-Prefix, FFmpeg can not decrypt the stream, because this blob is only valid where you have received this URL (e.g. your browser).
To solve this, you need to manually download the m3u8 playlist file to your local drive, download also the AES-128 key manually, modify the playlist and pass this into FFmpeg. You can find a short tutorial here.
Related
I have to convert a bunch of .opus files to .wav using ffmpeg. When calling
ffmpeg -i input_file.opus -acodec pcm_s16le -ac 1 -ar 16000 output_file.wav
I get
Unsupported huge granule pos -123480
This does not depend on the specific ffmpeg options. An example .opus file can be found here. The .opus file is a part of a soundstream extracted from a youtube video in .mkv container format with .opus as audio stream with the highest available quality. The corresponding ffmpeg call was
ffmpeg -ss 00:15:00.00 -i input_file.mkv -to 00:15:00.00 -vn -acodec copy output_file.opus
The line raising the original exception is
if (os->granule > (1LL << 62))
{av_log(avf, AV_LOG_ERROR, "Unsupported huge granule pos %"PRId64 "\n", os->granule);
return AVERROR_INVALIDDATA;
}
It can be found in lines 121-124 of this file. granule is defined as an uint_64t here.
So, what I figured so far is that a uint probably shouldn't be negative after all. I'm unsure whether the error is occuring during the extraction of the audio but remains unnoticed until trying to convert said audio or if the error is in the actual conversion. I also do not understand what "granule" is supposed to mean in this context, but probably I don't need to.
Are these Ogg Opus files or are the Opus audio packets encapsulated in another container? Try using MKVToolNix to extract the audio stream.
The *.opus URL you provided requires authentication and I cannot access.
Try extracting the wav file from the mkv without the intermediate opus file:
ffmpeg -ss 00:15:00.00 -i input_file.mkv -to 00:15:00.00 -vn -acodec pcm_s16le -ac 1 -ar 16000 output_file.wav
Alternatively, try splitting off the full opus file from the original mkv before extracting the portion that you're interested in:
ffmpeg -i input_file.mkv -vn -acodec copy input_file.opus
ffmpeg -ss 00:10:00 -to 00:15:00 -i input_file.opus -acodec pcm_s16le -ac 1 -ar 16000 output_file.wav
I've seen these "Unsupported huge granule pos ...." errors when extracting from youtube sourced opus content.
What has worked for me so far is to have ffmpeg "re-write" the full opus bitstream before extracting portions of it:
ffmpeg -i from_youtube.opus -codec copy dupe.opus
ffmpeg -ss 00:15:00.000 -to 00:25:00 -i dupe.opus -codec copy extract.opus
Seems that ffmpeg can have problems trying to extract sections from youtube produced opus bitstreams.
I need the audio from video. So i find the ffmpeg. When i use
ffmpeg -i test.mp4 -acodec copy -vn test.mp3
It get the following error:
Invalid audio stream. Exactly one MP3 audio stream is required. could not write header for output file #0 (incorrect codec parameters ) invalid argument
How can this be solved?
If you need only to get the audio to MP3, you can simply use:
ffmpeg -i test.mp4 test.mp3
I loop over some files and convert them with ffmpeg. I provide -vcodec h264. When the input video already is encoded with that codec: will the video stream be copied? How to make sure it's not reencoded in that case? Is it what -sameq was used previously?
You need to use -c:v copy if you want the raw H.264 stream to be passed on without re-encoding:
ffmpeg -i myh264file.mp4 -c:v copy -c:a copy myh264output.mp4
-c:a copy will also copy the audio
-c copy will copy both audio and video as in:
ffmpeg -i myh264file.mp4 -c copy myh264output.mp4
Detecting H.264 streams is not straight forward. You will need to code this.
For the -sameq settings please refer to this statement.
I would recommend upgrading to a recent version of ffmpeg if it is not already done as -vcodec is not used anymore, now it is -c:v.
The documentation on ffmpeg could help you.
i am using ffmpeg for encoding a video which will then be restreamed using wowza.i am new to streaming.first i started wowza using command
/etc/init.d/WowzaMediaServer start
after that i start streaming a MP4 file using rtsp protocol.i used the command
ffmpeg -re -i /usr/local/WowzaMediaServer/content/sample.mp4 -acodec libfdk_aac -vcodec libx264 -f rtsp -muxdelay 0.1 rtsp://myuser:mypassword#127.0.0.1:1935/live/myStream.sdp
video start streaming before all of these i changed admin.password and added a username as myuser and password as mypassword when i run above command its streaming but after that they say go to
WowzaMediaServer/examples/LiveVideoStreaming/FlashRTMPPlayer/Player.html
and fill server with rtmp://localhost:1935/live
and Stream field with myStream
when i click on connect its giving me status
"Failed to play myStream; stream not found."
i am following this article http://www.wowza.com/forums/content.php?354-How-to-set-up-live-streaming-using-an-RTSP-RTP-based-encoder
where i am wrong i dont know.i am unable to figure it out. from wowza support team i am not getting satisfactory answers .so someone work on wowza please help me!!why i am not able to connect my video stream to wowza.Please respond stuck badly.
So it appears there are some basic issues with the rtsp from ffmpeg and then no matches to the play request
You have
ffmpeg -re -i /usr/local/WowzaMediaServer/content/sample.mp4 -acodec libfdk_aac -vcodec libx264 -f rtsp -muxdelay 0.1 rtsp://myuser:mypassword#127.0.0.1:1935/live/myStream.sdp
You need to make sure your ffmpeg has libx264 and libfdk_aac plugins available. You should be able to determine this with just
ffmpeg
and it should print out the libraries available.
If you have all the libraries then you are publishing a stream called
myStream.sdp
You then have instructions that say
and fill server with rtmp://localhost:1935/live
and Stream field with myStream
So you should either change your ffmpeg command to
ffmpeg -re -i /usr/local/WowzaMediaServer/content/sample.mp4 -acodec libfdk_aac -vcodec libx264 -f rtsp -muxdelay 0.1 rtsp://myuser:mypassword#127.0.0.1:1935/live/myStream
Note no .sdp in the stream name any more or use a Stream field in the player of
myStream.sdp
When publishing a stream and then attempting to play it back they must match, otherwise you get back Stream Not Found.
One way to successfully do this is to specify only the port number (65000 in this example), making sure it isn't 1935 and server in your ffmpeg command then create a mystream.stream file in your content directory of your Wowza server with ONLY the following line:
udp://0.0.0:65000
Then, in Wowza/conf/startupstreams.xml, add the following:
<!-- Native RTP example (SDP file is myStream.sdp) -->
<StartupStream>
<Application>live/_definst_</Application>
<MediaCasterType>rtp</MediaCasterType>
<StreamName>mystream.stream</StreamName>
</StartupStream>
Restart wowza and ffmpeg and then re-try your url in with the stream name mystream.stream.
I have input file as 02.mp3. I want to change it to mp3 file with some bit rate. While doing so, I want to preserve all the metadata plus the APIC, attached picture corresponding to image should also be transfered to the destionation file. I am using FFMPEG and i am using the following command...
ffmpeg -y -i 02.mp3 -id3v2_version 3 -ab 128000 -ss 0 -acodec libmp3lame -f mp3 -ac 2 -ar 44100 output.mp3
source file: 02.mp3
destination file : output.mp3.
But in destination file, i am not getting APIC(attached picture corresponding to 02.mp3).I am getting all other mp3 tags in output.mp3 except for APIC. How to get APIC in destinaton file as well?
You will need to patch your FFMPEG source to support support binary in metadata and rebuild. The patch is here:
http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2011-December/118085.html