Lossless cut from a h264 video with audio
Hello, tl;dr: Q: is there a way to cut a 10 second clip from a h264 video (downloaded from youtube) to later use it in web browsers with no quality loss? What I have tried so far: http://alpha.rawg.io/question/ Long version: My inputs are http://alpha.rawg.io/question/cook.txt <http://alpha.rawg.io/question/cook.txt> My first attempt is to opt-in for copy codecs using the following command: /usr/bin/env ffmpeg -y -ss 0:03:18 -t 0:00:10 -i cook.mp4 -c copy cook-start.mp4 &> cook-start.txt What I've got is: - Safari: audio/video sync is OK, beginning is OK, but additional 3 seconds of audio without video in the end - Chrome: audio/video is out of sync Then I tried to specify -ss as an output option: /usr/bin/env ffmpeg -y -i cook.mp4 -ss 0:03:18 -t 0:00:10 -c copy cook-end.mp4 &> cook-end.txt Safari & Chrome: first 3 seconds have no video, but audio only. Is there a clever trick to overcome this apparent keyframe location issue while not re-encoding videos? If there is no way to avoid re-encoding, what options should I use to minimise quality loss? Here is the webpage to check out my results & source files: https://alpha.rawg.io/question/ <https://alpha.rawg.io/question/> Thank you very much in advance. Samat.
try this one... /usr/bin/env ffmpeg -y -ss 0:03:18 -i cook.mp4 -t 0:00:10 -c copy cook-start.mp4 &> cook-start.txt
On Oct 10, 2018, at 8:44 56AM, Samat Galimov <s@samat.me> wrote:
Hello,
tl;dr: Q: is there a way to cut a 10 second clip from a h264 video (downloaded from youtube) to later use it in web browsers with no quality loss?
What I have tried so far: http://alpha.rawg.io/question/
Long version:
My inputs are http://alpha.rawg.io/question/cook.txt <http://alpha.rawg.io/question/cook.txt>
My first attempt is to opt-in for copy codecs using the following command:
/usr/bin/env ffmpeg -y -ss 0:03:18 -t 0:00:10 -i cook.mp4 -c copy cook-start.mp4 &> cook-start.txt
What I've got is: - Safari: audio/video sync is OK, beginning is OK, but additional 3 seconds of audio without video in the end - Chrome: audio/video is out of sync
Then I tried to specify -ss as an output option:
/usr/bin/env ffmpeg -y -i cook.mp4 -ss 0:03:18 -t 0:00:10 -c copy cook-end.mp4 &> cook-end.txt
Safari & Chrome: first 3 seconds have no video, but audio only.
Is there a clever trick to overcome this apparent keyframe location issue while not re-encoding videos?
If there is no way to avoid re-encoding, what options should I use to minimise quality loss?
Here is the webpage to check out my results & source files: https://alpha.rawg.io/question/ <https://alpha.rawg.io/question/>
Thank you very much in advance.
Samat. _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
Q: is there a way to cut a 10 second clip from a h264 video (downloaded from youtube) to later use it in web browsers with no quality loss?
try this one... /usr/bin/env ffmpeg -y -ss 0:03:18 -i cook.mp4 -t 0:00:10 -c copy cook-start.mp4 &> cook-start.txt
Does ffmpeg suffer from the same problem as AVIdemux that cuts must be made on a GOP boundary in order for the cut to be clean? Or does it recode a few full and differential frames so that the second clip of a cut always starts with a full frame followed by regenerated differential frames *wrt that full frame*, until the next full frame in the source video, like VideoReDo does? Apologies for terms full and differential, but I can never remember which are I, B and P frames. Is MPEG2 more prone to this problem than H264?
exactly same result as 'cook-start', i.e. /usr/bin/env ffmpeg -y -ss 0:03:18 -t 0:00:10 -i cook.mp4 -c copy cook-start.mp4 &> cook-start.txt; # ss input option
On 10 Oct 2018, at 19:30, DopeLabs <dopelabs@dubstep.fm> wrote:
try this one...
/usr/bin/env ffmpeg -y -ss 0:03:18 -i cook.mp4 -t 0:00:10 -c copy cook-start.mp4 &> cook-start.txt
On Oct 10, 2018, at 8:44 56AM, Samat Galimov <s@samat.me <mailto:s@samat.me>> wrote:
Hello,
tl;dr: Q: is there a way to cut a 10 second clip from a h264 video (downloaded from youtube) to later use it in web browsers with no quality loss?
What I have tried so far: http://alpha.rawg.io/question/
Long version:
My inputs are http://alpha.rawg.io/question/cook.txt <http://alpha.rawg.io/question/cook.txt><http://alpha.rawg.io/question/cook.txt <http://alpha.rawg.io/question/cook.txt>>
My first attempt is to opt-in for copy codecs using the following command:
/usr/bin/env ffmpeg -y -ss 0:03:18 -t 0:00:10 -i cook.mp4 -c copy cook-start.mp4 &> cook-start.txt
What I've got is: - Safari: audio/video sync is OK, beginning is OK, but additional 3 seconds of audio without video in the end - Chrome: audio/video is out of sync
Then I tried to specify -ss as an output option:
/usr/bin/env ffmpeg -y -i cook.mp4 -ss 0:03:18 -t 0:00:10 -c copy cook-end.mp4 &> cook-end.txt
Safari & Chrome: first 3 seconds have no video, but audio only.
Is there a clever trick to overcome this apparent keyframe location issue while not re-encoding videos?
If there is no way to avoid re-encoding, what options should I use to minimise quality loss?
Here is the webpage to check out my results & source files: https://alpha.rawg.io/question/ <https://alpha.rawg.io/question/><https://alpha.rawg.io/question/ <https://alpha.rawg.io/question/>>
Thank you very much in advance.
Samat. _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org <mailto:ffmpeg-user@ffmpeg.org> http://ffmpeg.org/mailman/listinfo/ffmpeg-user <http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org <mailto:ffmpeg-user-request@ffmpeg.org> with subject "unsubscribe".
_______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org <mailto:ffmpeg-user@ffmpeg.org> http://ffmpeg.org/mailman/listinfo/ffmpeg-user <http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org <mailto:ffmpeg-user-request@ffmpeg.org> with subject "unsubscribe".
Hi There, I was able to find a way to stream 2 channels to one YouTube channel using the following command line: ffmpeg -rtsp_transport tcp -i "rtsp:// web1:pass@10.10.10.125:554/cam/realmonitor?channel=1&subtype=0" -i "rtsp:// web1:pass@10.10.10.125:554/cam/realmonitor?channel=2&subtype=0" -f lavfi -i anullsrc -filter_complex "[0:v] setpts=PTS-STARTPTS, scale=800x448,setsar=1[upperleft]; [1:v] setpts=PTS-STARTPTS, scale=800x448,setsar=1[upperright]; [upperleft][upperright]hstack[base]" -map [base] -map 2 -f flv rtmp:// x.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx Any idea how to make it better quality and how to add 2 more sources??? Any assistance is appreciated! Thank you! -Zark
On Wed, Oct 10, 2018 at 15:00:30 -0500, Rad J wrote:
Any idea how to make it better quality and how to add 2 more sources???
Did you not see this answer in September? http://ffmpeg.org/pipermail/ffmpeg-user/2018-September/041119.html Moritz
Yes thank you that worked well, but I decided to got with two YouTube live channels and 2 streams per channel do to the quality. However I'm having some issues with the stream quality and frame loss... also YouTube is complaining about my stream type... This is what I'm getting: *Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).* *10:54 PM Bad Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).* *Please check the video resolution. The current resolution is (3840x1080), which is not optimal.* *The stream's current bitrate (992.00 Kbps) is lower than the recommended bitrate. We recommend that you use a stream bitrate of 4500 Kbps.* Do you know how to fix this? How to increase the bitrate? Thanks, Rad On Wed, Oct 10, 2018 at 4:46 PM Moritz Barsnick <barsnick@gmx.net> wrote:
On Wed, Oct 10, 2018 at 15:00:30 -0500, Rad J wrote:
Any idea how to make it better quality and how to add 2 more sources???
Did you not see this answer in September? http://ffmpeg.org/pipermail/ffmpeg-user/2018-September/041119.html
Moritz _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
On Mon, Oct 15, 2018 at 23:04:39 -0500, Rad J wrote:
However I'm having some issues with the stream quality and frame loss... also YouTube is complaining about my stream type...
You sometimes need to fiddle against YouTube's expectation. I remember that YouTube didn't see my live stream actually starting, without giving me detailed errors like yours. When I improved some parameters (such as GOP size), it suddenly worked.
This is what I'm getting:
*Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).*
*10:54 PM Bad Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).* *Please check the video resolution. The current resolution is (3840x1080), which is not optimal.* *The stream's current bitrate (992.00 Kbps) is lower than the recommended bitrate. We recommend that you use a stream bitrate of 4500 Kbps.*
Do you know how to fix this? How to increase the bitrate?
Sure we know. But please show your currently used command line(s) which provoke(s) these warnings. We can try to fine-tune or reproduce. Cheers, Moritz
an option you may wish to explore if you have the available network and encoding resources is youtube live streaming support for multiple cameras for a single livestream. each 'camera' has its own rtmp ingestion url and stream key and the viewer can choose which of the cameras they want to watch. multiple cameras show up as thumbnails above the main video. https://support.google.com/youtube/answer/2853812?hl=en cheers, DL
On Oct 16, 2018, at 4:27 58AM, Moritz Barsnick <barsnick@gmx.net> wrote:
On Mon, Oct 15, 2018 at 23:04:39 -0500, Rad J wrote:
However I'm having some issues with the stream quality and frame loss... also YouTube is complaining about my stream type...
You sometimes need to fiddle against YouTube's expectation. I remember that YouTube didn't see my live stream actually starting, without giving me detailed errors like yours. When I improved some parameters (such as GOP size), it suddenly worked.
This is what I'm getting:
*Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).*
*10:54 PM Bad Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).* *Please check the video resolution. The current resolution is (3840x1080), which is not optimal.* *The stream's current bitrate (992.00 Kbps) is lower than the recommended bitrate. We recommend that you use a stream bitrate of 4500 Kbps.*
Do you know how to fix this? How to increase the bitrate?
Sure we know. But please show your currently used command line(s) which provoke(s) these warnings. We can try to fine-tune or reproduce.
Cheers, Moritz _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
Hi DL, Thanks for that suggestion, I got it all configured however it's not showing up live... any ideas? https://www.screencast.com/t/HIX0JDrhHs I have tried shared stream key as well as single stream key. Here is my command line used: ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i "rtsp://xxxx:xxxx@10.1.10.125:554/cam/realmonitor?channel=1&subtype=0" -tune zerolatency -vcodec libx264 -t 12:00:00 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp:// a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx Here is the stream on YouTube: https://www.youtube.com/channel/UCKuRKJezfklD3y2kdKJAwCw/live <https://youtu.be/Dnpi0OY_Vck> Thanks, Rad On Tue, Oct 16, 2018 at 2:45 PM DopeLabs <dopelabs@dubstep.fm> wrote:
an option you may wish to explore if you have the available network and encoding resources is youtube live streaming support for multiple cameras for a single livestream. each 'camera' has its own rtmp ingestion url and stream key and the viewer can choose which of the cameras they want to watch. multiple cameras show up as thumbnails above the main video.
https://support.google.com/youtube/answer/2853812?hl=en
cheers, DL
On Oct 16, 2018, at 4:27 58AM, Moritz Barsnick <barsnick@gmx.net> wrote:
On Mon, Oct 15, 2018 at 23:04:39 -0500, Rad J wrote:
However I'm having some issues with the stream quality and frame loss... also YouTube is complaining about my stream type...
You sometimes need to fiddle against YouTube's expectation. I remember that YouTube didn't see my live stream actually starting, without giving me detailed errors like yours. When I improved some parameters (such as GOP size), it suddenly worked.
This is what I'm getting:
*Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).*
*10:54 PM Bad Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).* *Please check the video resolution. The current resolution is (3840x1080), which is not optimal.* *The stream's current bitrate (992.00 Kbps) is lower than the recommended bitrate. We recommend that you use a stream bitrate of 4500 Kbps.*
Do you know how to fix this? How to increase the bitrate?
Sure we know. But please show your currently used command line(s) which provoke(s) these warnings. We can try to fine-tune or reproduce.
Cheers, Moritz _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
Hello Mortiz, Thanks for getting back to me so quickly! Here is my command line I currently use: ffmpeg -rtsp_transport tcp -i "rtsp://xxxx:xxxx@10.1.10.125:554/cam/realmonitor?channel=1&subtype=0" -i "rtsp://xxxx:xxxx@10.1.10.125:554/cam/realmonitor?channel=2&subtype=0" -f lavfi -i anullsrc -filter_complex " [0:v] setpts=PTS-STARTPTS, scale=1920x1080,setsar=1[upperleft]; [1:v] setpts=PTS-STARTPTS, scale=1920x1080,setsar=1[upperright]; [upperleft][upperright]hstack[base]" -map [base] -map 2 *-b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k <-- I just added that, but does not seem to help* -f flv rtmp://x.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx And here is the live stream on YouTube: https://www.youtube.com/watch?v=Z5ZMPCuDAKA Another thing that also keeps happening is that the stream just freezes up after 24hrs or so... I have to stop and restart the command to get it going again.... :( https://www.screencast.com/t/ZgPhP8vMAz And after I restart I keep getting bunch of errors (that's normal tho... it still works, but can I fix those?) https://www.screencast.com/t/DRuWBg3zDi Thanks, Rad On Tue, Oct 16, 2018 at 6:28 AM Moritz Barsnick <barsnick@gmx.net> wrote:
On Mon, Oct 15, 2018 at 23:04:39 -0500, Rad J wrote:
However I'm having some issues with the stream quality and frame loss... also YouTube is complaining about my stream type...
You sometimes need to fiddle against YouTube's expectation. I remember that YouTube didn't see my live stream actually starting, without giving me detailed errors like yours. When I improved some parameters (such as GOP size), it suddenly worked.
This is what I'm getting:
*Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).*
*10:54 PM Bad Bad video settings* *The video is encoded with an unsupported codec. Please set the video codec for the stream to a supported codec (H.264).* *Please check the video resolution. The current resolution is (3840x1080), which is not optimal.* *The stream's current bitrate (992.00 Kbps) is lower than the recommended bitrate. We recommend that you use a stream bitrate of 4500 Kbps.*
Do you know how to fix this? How to increase the bitrate?
Sure we know. But please show your currently used command line(s) which provoke(s) these warnings. We can try to fine-tune or reproduce.
Cheers, Moritz _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
participants (5)
-
DopeLabs -
Martin Underwood -
Moritz Barsnick -
Rad J -
Samat Galimov