MP4 Videos are playing only after fully loaded on Jwplayer [duplicate] - ffmpeg

This question already has answers here:
Post processing in ffmpeg to move 'moov atom' in MP4 files (qt-faststart)
(3 answers)
Closed 4 years ago.
Hi recently I am converted some videos to MP4 using FFMpeg but When I am trying to stream this video files, player needs to load a file completely, until it starts to play, I am trying to find a way to make it start play a file right from the start and keep on loading as well.
I am using this FFMpeg command for conversion:
ffmpeg -i input.mp4 -vcodec libx264 -vpre default -crf 28 -ac 1 -ar 44100 -b 284k -ab 70k -r 15 -s 640x360 output.mp4 2>&1

This is happening because mp4 format has its moov info at the tail of the file. The information is required for flash players before the file can be progressively download and play. Therefore if the info is in the end of file, it has to be fully downloaded, which is terrible, user-experience-wise.
From your answer you can compile a separate tool provided in ffmpeg - qt-faststart to post-process the mp4 file and then use the mp4 file for video streaming.
Specially, you can download a copy of source code for ffmpeg, and go to tools folder and run:
make qt-faststart
then you will have a tool named qt-faststart in tools directory. Then you can run:
qt-faststart input.mp4 output.mp4
and put output.mp4 to your streaming folder and the new mp4 file will be progressively downloaded while playing.
Alternatively another option is to do this during transcoding time as suggested in previous answers, but the command line is provided wrong, it should be:
-movflags +faststart
in your ffmpeg command line. It will do the same thing as you transcode.
So there are your two easiest solution to this, hope the best of luck!

For streaming, the moov atom needs to be at the beginning of the file, rather than the end. For ffmpeg, try adding:
-movflags faststart

You can always test with this tool - http://renaun.com/blog/2010/06/qtindexswapper-2/

Related

.M2P file extention to image file extension, image processing

I have a .m2p file (which is an image file i believe that contains many images, kinda like a video of still images) that I would like to convert to any image file (preferably .png or .jpg).
Does anyone know if there is a possible way to do so?
Does anyone know how to convert these, using a script, to a different file extension essentially. Extract out all the images from a .m2p file?
Any help would be appreciated.
Figured out the answer to this.
Can simply just use ffmpeg (for Mac atleast).
Images:
To grab a still from a certain time:
ffmpeg -i video.m2p -ss 00:00:07.000 -vframes 1 thumb.png
Videos:
To convert m2p to mp4
ffmpeg -i example.m2p -f mp4 -vcodec libx264 -preset slow -profile:v main -acodec aac example.mp4 -hide_banner
Random: I used the slow preset just so it outputs a better quality video

How to use ffmpeg to split an audio file into HLS-compatible chunks? (mp3 format)

I've been looking all over the web & StackOverflow, and can't get this to work. I have an audio file that I'd like to split into mp3 files and generate a corresponding m3u8 file.
I've tried this, which was the closest:
ffmpeg -i sometrack.wav -c:a libmp3lame -b:a 256k -map 0:0 -f segment -segment_time 10 -segment_list outputlist.m3u8 -segment_format mpegts 'output%03d.mp3'
But all the mp3 files are garbled when I play them.
There are two issues here. FFmpeg normally looks at the extension of the output files to determine output container. However, when the output format is forced -segment_format for segment muxer or just -f format for most others, ffmpeg will pay heed to that and no longer look at the extension. In this case, segment_format is set to mpegts so that's what the output files will be. To ensure valid mp3 files, set segment_format to mp3.
The second issue is that since the extension is mp3, my guess is that hls.js is not able to correctly determine the format of the segments, or it assumes a wrong format and tries to parse them that way. Either way, there should be some messages in the browser console to that effect. See https://github.com/video-dev/hls.js/pull/1190 for issues that hls.js has had with format probing.

Using ffmpeg to convert an SEC file

I need to convert an SEC file into any video format that I can share and/or upload to Youtube. MP4, etc.
I'm a complete newbie at all things terminal. I've tried:
ffmpeg -i video.sec video.mp4
ffmpeg -i video.sec -bsf:v h264_mp4toannexb -c:v copy video.avi
ffmpeg -i video.sec -b 256k -vcodec h264 -acodec aac video.mp4
I don't understand what any of these mean, they're just examples I found online. However, whatever I try returns this error:
Invalid data found when processing input
Any thoughts? Thanks!
I had to add the following option so it would skip the SEC's custom header.
-skip_initial_bytes 48
i know this is old, but i was trying to figure this out as well, what ended up finally working for me was this command.
./ffmpeg -f h264 -i INPUT.sec -filter:v "setpts=4*PTS" OUTPUT.avi
the -f h264 was the part i was missing. and the -filter:v "setpts=4*PTS" part is to slow it back down to the original speed. you can also change the .avi at the end to whichever format works best for you.
i hope this helps someone out :)
OK, just to clear up some recent threads…
The Samsung DVR used here was an SRD-440. RB kindly sent me a file to test and he sent me a .BU file with an associated .db2 file. This was a bit of a surprise as in all older Samsung DVR’s, the .bu files can only be played back in the DVR. I mentioned this here, https://spreadys.wordpress.com/2014/07/21/ifsec-samsung-exports/
It appears that Samsung have caught on, and the BU file is now playable due to it being a H264/AVC Stream conforming to a standard profile. I have updated the IFSEC Post mentioned above to highlight this change.
Back to RB’s stream and the challenge was to get these files viewable in WMV format. They were all field based, at 704×288.
The speed of playback is controlled by the Samsung software, using the .db2 file. As such, the metadata and timing information in the video stream was wrong. This caused speed issues and then quality issues when attempting to correct this.
As a result, I found it necessary to force an input rate and generate a new Presentation Time Stamp BEFORE the input file.
The following FFmpeg string did the job…
ffmpeg -r 12 -fflags genpts -i FILE.bu -vf scale=704:528 -sws_flags lanczos -q:v 2 FILE.wmv
Remember, this is for preview – analysis would be completed differently due to the scaling, the interpolation method, and the WMV compression!
As its likely that RB may have quite a few .bu files in a folder, I placed this into a batch file to transcode the whole lot within a few minutes… more on batch files coming in a new post soon!
https://spreadys.wordpress.com/2014/07/21/ifsec-samsung-exports/
or
ffmpeg -i (name of file).sec (name of final file).mp4
ffmpeg -i (name of file).sec -filter:v "setpts=3.3*PTS" (name of final_file).mp4

Change video file container to mp4

I have learned through Google, that to change video containers without losing quality I can run the following command:
ffmpeg -i videofile.mkv -codec copy videofile.mp4
This has worked great for a number of video files I have. However, I am having an issue with three of them (1 mkv file and 2 avi files). When I run that command against them, the video is there, but there is no sound. There is sound in the original video file.
Any ideas how to put the video in a new container while retaining the audio track?
Thanks. Brian
The .mp4 container is not compatible with the audio codecs of the problem files. This should be evident from the logs. So the audio channels of the problem files have to be transcoded to something allowed in .mp4, eg. aac:
ffmpeg -i videofile.mkv -c:v copy -c:a aac videofile.mp4
Maybe the container mp4 it doesn’t compatible whith codec of your input video mkv and avi
By the way, you can try
ffmpeg -i videofile.mkv -c:v copy -c:a copy videofile.mp4
Check this documentation.
https://en.m.wikipedia.org/wiki/Comparison_of_video_codecs
https://trac.ffmpeg.org/wiki/Map

How do I set buffer for MP4 in FFmpeg?

I convert videos to MP4 for my web player. My problem is: My videos don't buffer. I have to wait until the whole video is downloaded, and after that, I can play the video.
This is my exec() command:
ffmpeg -i uploaded_files/'.$le["file"].' -vcodec libx264 -pix_fmt yuv420p flash/'.$le["file"].'.mp4
Are there any options for buffering? My MP4 size and quality is good. But without buffering, it's bad.
Is this the fault of the exec() command I use?
My videos don't buffer. I have to wait until the whole video is downloaded, and after that, I can play the video.
Use the -movflags faststart option while encoding, e.g.
ffmpeg -i input.mp4 […] -movflags faststart output.mp4
Or, alternatively, run qt-faststart on the file.
The reason the files don't stream immediately is that their MOOV atom is at the end of the file, and in order to play it, the client needs to parse this info. qt-faststart will just move that atom and your files will start playing right away.

Resources