I was using the following command for recording input streams to mp4 into 10 seconds clip. But since few days there is no voice in the output mp4 clips.
Command is
ffmpeg -i rtsp://localhost:8554/mystream -c copy -bsf:a aac_adtstoasc -f segment -segment_time 10 -reset_timestamps 1 -map 0 output%d.mp4
ffmpeg output
I think its because of the format of input stream but i don't know for sure and also, i don't know how to solve it.
I solved it using the following command.
ffmpeg -i rtsp://localhost:8554/mystream -c:a aac -c:v copy -bsf:a aac_adtstoasc -f segment -segment_time 10 -reset_timestamps 1 -map 0 output%d.mp4
changing -c to -c:a aac -c:v
Related
I want to attach/append an image (something like youtube) to first frame of the video, i tried this command :
ffmpeg -i video.mp4 -i image.png -map 1 -map 0 -c copy -disposition:0 attached_pic out.mp4
But it doesnt working, the first frame is not my custom image
my ffmpeg version:
ffmpeg version n4.4-80-gbf87bdd3f6-20210830 Copyright (c) 2000-2021 the FFmpeg developers
You will have to concatenate a frame to the beginning.
Re-encode audio in video.mp4. The audio is HE-AACv2, but you don't have a HE-AACv2 encoder. So it has to be changed to the more common AAC-LC to allow concatenation with the video generated from the image.
ffmpeg -i video.mp4 -c:v copy -c:a aac main.mp4
Make a video from image.png with silent filler audio. It has to have the same attributes as main.mp4.
ffmpeg -loop 1 -framerate 30 -i image.png -f lavfi -i anullsrc=r=48000 -frames:v 2 -c:v libx264 -vf format=yuv420p -video_track_timescale 30k -c:a aac image.mp4
-frames:v 2 is used instead of -frames:v 1 as required for the audio.
Make input.txt containing:
file 'image.mp4'
file 'main.mp4'
Concatenate:
ffmpeg -f concat -i input.txt -c copy output.mp4
I'm having issues with piping the ffmpeg out to the ffmpeg input. I have tried as below
ffmpeg -i "y:\3000012936-TXMHD.mxf" -vcodec copy -acodec copy -f mpegts pipe:1 | ffmpeg -re -i pipe:0 -pix_fmt yuv420p -vsync 1 -map 0:v:0 -map 0:a:0 -c:a aac -c:v libx264 -use_template 1 -use_timeline 1 -init_seg_name "init-stream$RepresentationID$-$Bandwidth$.mp4" -media_seg_name "chunk-stream$RepresentationID$-$Number%05d$.$ext$" -b:v 1500k -b:a 128k -ac 2 -profile:v main -level:v 3.0 -s 1920x1080 -r 25 -vsync passthrough -increment_tc 1 -adaptation_sets "id=0,streams=v id=1,streams=a" -g 100 -keyint_min 100 -seg_duration 5 -frag_duration 5 -dash_segment_type auto -f dash "stream.mpd"
But I'm getting an error:
Conversion failed! av_interleaved_write_frame(): Broken pipe Error
writing trailer of pipe:1: Broken pipe
The input file is MXF, and output is going to be MPEG DASH. The reason to do the piping is because the input file is a growing mxf file. If i do it without piping the ffmpeg just closes before the mxf file is written completely.
Why not let ffmpeg read the file at the same framerate as the source media? If ffmpeg reads at the same speed as the file is written then it will never catch up and close the output.
ffmpeg -re -i "y:\3000012936-TXMHD.mxf" . . . . . . . .
There needs to be enough data on the source before you start ffmpeg. In case of network drives there could be a delay between writing data and that data being available over the network.
I tried to convert a UDP stream (that genrated from DVB signal) to HLS m3u8 file with this code:
ffmpeg -i udp://239.1.2.1:60001 -acodec aac -strict -2 -vcodec libx264 -hls_wrap 100 -f hls /var/www/html/ts/1.m3u8
and output m3u8 file is :
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:66
#EXTINF:0.960000,
21.ts
#EXTINF:2.080000,
22.ts
#EXTINF:2.400000,
23.ts
#EXTINF:1.760000,
24.ts
#EXTINF:2.080000,
20.ts
I tried to change the target duration to 10 in this file with the option -segment_time 10 but the target duration doesn't change in m3u8 file, can anybody help me with this problem?
I solve this problem with code:
ffmpeg -i udp://239.1.2.4:60004?fifo_size=50000000 -acodec copy -vcodec copy -preset ultrafast -flags -global_header -f hls -hls_time 20 -hls_wrap 5 /var/www/html/ts/4.m3u8
Add this option to ffmpeg fix problem
-preset ultrafast -flags -global_header
I have a trouble with ffmpeg
I receive a rtsp stream from a grabbing device (camera) and I stream-out it to rtmp (Youtube Live)
I want to have a copy of the stream in my computer so I write at the same time in a local file
I use this command :
ffmpeg -y -i 'RTSP_SOURCE' -c:v copy -c:a libvo_aacenc -map 0:v -bsf:v dump_extra -fflags +genpts -flags +global_header -movflags +faststart
-map_metadata 0 -metadata title= -f tee -filter_complex aevalsrc=0 '[f=mp4]/tmp/backup.mp4|[f=mpegts]/tmp/backup.ts|[f=flv]rtmp://a.rtmp.youtube.com/live2/STREAM_ID'
The problem is when I have some disconnections, ffmpeg exits and stop to recording
Is there any flag or option for telling to ffmpeg to continue recording in local files even there is not internet ?
Thank you very much for your help =)
You can try:
ffmpeg -f tee "[onfail=ignore] ...
More description is available here.
I'm using FFMpeg to segment a WAV file into mp3s for use in HTTP Live Streaming.
I'm using this command:
ffmpeg -i input.wav -c:a libmp3lame -b:a 128k -map 0:0 -f segment
-segment_time 10 -segment_list outputlist.m3u8 -segment_format mp3 'output%03d.mp3'
The stream is working, however I'm getting small "gaps" between each mp3 segment. Why is this?
I was able to solve this by using -segment_format mpegts.
ffmpeg -i input.wav -c:a libmp3lame -b:a 128k -map 0:0 -f segment -segment_time 10 -segment_list outputlist.m3u8 -segment_format mpegts 'output%03d.mp3'