.
Hi,
I have this sample, attached: AVC H.264 + AAC audio 640 × 480 px. @ 29.97 FPS, that was submitted to me with this question:
"I want to create some video, using whatever software that will let me append the result to the sample without recoding."edit: — In order to end up with an MP4 file.
Which precise encoding settings / specifications, advanced if needed, should be applied, to create the MP4 clip I want to add?
I tried "VirtualDub + x264 VfW" (to AVI, then "Avidemux" to mux to MP4) and "AviDemux" (alone) avanced settings, to match as precisely as possible the sample characteristics — displayed by "MediaInfo".
At first sight, nothing special: it sure didn't look like a challenge!.. knowing that I was able to create: clips to append with no recode, to videos from a DV camcorder, very simply.
— But, with THIS particular sample, & so far: no way... The created result just won't append to the sample...
Any help on which, of those precise characteristics or specifications that ought to match exactly: appreciated!
.
+ Reply to Thread
Results 1 to 30 of 34
-
Last edited by bulgom; 9th Nov 2015 at 11:59.
-
.
Thanks, but in this case, the request is to end up with an MP4 file (I edited my post to add that).
I just tried to append some clip (in fact the same one, but recoded in a snap), using "MKVMerge". This time, it didn't work, although I remember making it work.
Now, the question is (anyway): MP4 result... -
Did you match the number of reference frames, and audio settings ?
-
.
No, this time, I didn't match the # of reference frames — but probably did, when it worked... to MKV append / never to MP4, though. About audio, I also tried: silent, having demuxed the audio away (on both files of course).
I'll try the reference frames # match again.
_____________________________________
edit: so: done trying to match # of ref. frames. But same result: the second clip (appended) displays grey, although players display the total duration OK: 10 seconds instead of the 5 seconds 1st clip duration. And the whole thing plays for 10 seconds; but that's it...
"MediaInfo" also shows "M & N GOP" values, that I don't know how to apply, when encoding the clip to append. And I wonder if that's the problem anyway...
_________________
Reminds me of Benzio's similar problem, that I was able to solve thru complicated manipulations... https://forum.videohelp.com/threads/374849-Join-two-mp4-videos-with-Avidemux-%28and-sim...ghlight=benzio post #7Last edited by bulgom; 9th Nov 2015 at 12:47.
-
Well, it's the 1st thing I tried when I managed to make it work to .mkv. Because I don't mind having to use an .mkv intermediate file. But, for "some" reason, that didn't work either.
And, as of today, I can't even find the right encoding, in order to get an appendable clip to .mkv, anymore (wish I knew what I'm goofing, this time).
One thing's sure: I wonder how to apply all the "MediaInfo" displayed characteristics (of the orig. sample), to a new encoding, whether using "x264" in cmdline mode, or "AviDemux" advanced settings... -
Your sample is Baseline@L3, which your other video will also need to be for any possibility of appending. Seems like some kind of cellphone video.
To my knowledge, x264 does not support GOPs of M/N making this whole thing harder to append. Your video uses a cycle of 1 I-frame followed by 29 P-Frames. So no B-frames, a very basic GOP structure. I would just take the hit and re-encode it but that's me.
Update: Ok, I realize these are not your videos bulgomLast edited by KarMa; 9th Nov 2015 at 14:37.
-
.
Thanks.
Is there a way to set — may be any other H.264 encoder, if not "x264" — to force 1 I-frame + 29 P-frames following, & make sure B-frames won't be generated (@29.97 FPS and 1 I+29 P, they shouldn't be, but I still wonder)? + available Baseline @L3 setting, of course.
I'd like to give that a try... if realistic enough (?)
Yep, recode... That's what those friends have been doing so far...
Right: friends' videos.
But it doesn't matter, as they've been "following your advice in advance", i.e.: recoding. And guess what: of course complaining (more or less) about the time it takes, even @ 640 × 480 (using old PCs...). At least, those are not complaining too much about storage space (native ~3000 kbs meaning quite heavy files, for such a small sized image anyway).
-
Yes, x264 can set a specific GOP makeup. --keyint 30 will set the max GOP interval to 30 --bframes 0 will be zero b-frames (so every other frame except for IDR frames will be P)
If you want to disable scenecut (--no-scenecut ), it will make to GOP repeating , no adaptive I frame insertion ie. always 30 in size (no I-frames inserted upon scenechange). Not a good idea IMO. And that' s not the reason for no being able to join
eg
Code:x264 --crf 18 --profile baseline --level 3.0 --ref 2 --keyint 30 --bframes 0 --sar 1:1 --force-cfr --fps 30000/1001 -o output.264 input.ext
You can use mp4box to wrap into a mp4 container -
.
Wow! Real goodie, above! Thank you: VERY MUCH!
While creating a new clip using the commandline output a working video, but still not appendable to the main (original) one
— but thanks for that cmdline, needed anyway —,
the "sps-id like 2 + binary join" technique works perfectly.
So... a method DID exist
For the friends I'm helping, I hope to be able to batch the whole thing into one ".bat" but, anyway, believe me, they and I have been waiting... quite a while, for such an excellent method (now, I'm trying to figure what "sps-id" is/does).
.[ Meanwhile (few minutes ago), I was just trying — 100% random attempt!.. — to use "x264 VfW version" via "VirtualDub" (= .avi, to remux to .mp4 with "AviDemux").
Quite clumsy, if I judge by the rather dodgy result: (surprise) works also, but some garbled image(s?) at end of play — with "U-Mplayer" anyway, not with "PotPlayer" neither "VLC" — i.e. difficult to recommend, knowing that people (friends) will delete their original material in the end... ]
-
[ Meanwhile (few minutes ago), I was just trying — 100% random attempt!.. — to use "x264 VfW version" via "VirtualDub" (= .avi, to remux to .mp4 with "AviDemux").
Quite clumsy, if I judge by the rather dodgy result: (surprise) works also, but some garbled image(s?) at end of play — with "U-Mplayer" anyway, not with "PotPlayer" neither "VLC" — i.e. difficult to recommend, knowing that people (friends) will delete their original material in the end... ]
If you want it to work 100% of the time, no glitches, use the method described in the other thread(s) with --sps-id . Ie. you have to demux the original to elementary streams , concatenate the elementary streams then put it into a container. The "added" section must also match audio specs (you concatentate audio & video separately, then put into a container) . As described in the other thread - many of the typical video settings actually don't matter that much, you don't really have to match it that closely. But it's critical that the splits and joins are on IDR boundaries. It's a PITA method, but this works 100% of the time, even better than something like videoredo or commercial software (they still fail on some streams), it's just clunky to do
Don't use a media player only to check - many media players can skip over errors and have error resiliency. Index the file (e.g. with avisynth). That will show errors if there are any errors. For example , that occurred to one of the other posters in one of the threads - it looked ok in MPCHC using a "normal" joining method, but when you look frame by frame with an indexed stream, the errors show up.Last edited by poisondeathray; 9th Nov 2015 at 18:24.
-
.
Yep, I've read (the whole) https://forum.videohelp.com/threads/369850-Joining-2-videos-reencoding-one-to-match-the...ncode-settings page
+ https://forum.videohelp.com/threads/374440-The-codec-s-private-data-does-not-match?p=24...=1#post2412411
and simply applied #11 post instructions, + still can hardly believe everything went so well at first try!
So far, I only tested the result with several media players + "MediaInfo" — but will also try to index & check, on possible errors.
"MediaInfo": I noticed several lines now displaying two infos. instead of one: "AVC / AVC, Baseline@L3 / Baseline@L3, CABAC : No / No, etc.". I guess I understand why.
And that makes me wonder — besides what "SPS ID" stands for —, in case I'd append another = a third clip, to one that's already made of two (that same way) and with "--sps-id 2", if I should set: "--sps-id 3".
Well, I might as well try, with "--sps-id 2" again, to check if that overwrites the previous "2" — the whole thing probably (or may be?) resulting in two parts only, playing, out of three. If that's the case, I then should keep track, of those special "sps-ided" files.
Also, yes, I noticed that some softwares, which claim to append with "no damage", i.e. smart rendering / recoding some frames only, still fail more or less (thinking about one named "Solveig", which sometimes outputs correct stuff, and sometimes, though still playable videos, garbled images)...
When I see the number of people struggling with videos, stubbornly unappendable, I wonder how the SPS method can be (kept?) so unknown...
Thanks so much, again, for sharing the magic command + explaining step by step how to apply. You "is" ONE help! — as even I, was able to "proceed"! -
I think mediainfo says 2 lines because your original elementary sample doesn't have a "duration" declared field . That won't affect the actual video bitstream . Whenever there is a missing field entry, it tends to repeat with a slash like you see there.
I might have missed matching some settings - I just looked at it quickly (you have to look at a stream parser for more detail), but for the most part, many of the encoding settings actually don't matter. And to reiterate - Just because it plays back ok in a media player doesn't necessarily mean anything. That's not a "proper" check. But if you look at an indexed stream and there are glitches, that means the join didn't work. Then there might be some obscure setting that you have to match as mentioned in the other thread - ie you'd have to look closer with a parser. (I'm still confident this works 100% if you've needed to match the obscure settings - I'm still looking for the 1 example of a failure)
sps-id = sequence parameter set id ; think of it just like a "label" or "name" . The default is zero "0" for every encoder, not just x264
As mentioned in the other thread, the new stream takes on the id of the 1st stream (the 1st dos appended stream). So there are reasons why you might want to do the actual joining in a specific order, or broken out into steps keeping that in mind. I think an example was given in one of the other threads. You can always check with h264_parse to see the id.
People only use this method, if the "regular" methods don't work. It's very clunky and not very user friendly to do as you can see
There are a few "gotchas", some of them might be mentioned in the other thread. If you have many joins, one of them is audio. When using compressed audio, there is always some delay encoded. It's described and explained in detail in other threads. Just know that it's worse for certain types of audio. AAC and some encoders like Nero are particularly bad. So if you have many joins, theoretically you can get sync issues because the delay compounds with each segment. (If using qaac, there is a no delay option.) . This doesn't affect the video, it's actually an audio problem, but I thought I'd mention itLast edited by poisondeathray; 9th Nov 2015 at 23:56.
-
QUITE right (the least I can say...). Attached: 30 seconds demo. Not that you need it, but should anyone (of my 'level') stumble too...
[ Btw: had to hunt "a while", for the working "AviSynth" plug-in; so, updated download link: https://forum.videohelp.com/threads/352273-AviSynth-can-t-get-ffvideosource-to-work?p=2...=1#post2418413 ]
-
Are you saying it didn't work when you indexed it ? Or was that your "previous" test before?
If you can't get it working and want help, then post the steps you performed exactly -
No, my previous test, "Final-video.mp4", dated from yesterday, did play perfectly and still does:
it opens and plays (+ scrolls) fine:
— on media players: that, we know;
— and also on "VirtualDub", "AviDemux" + other tools.
So far, so good.
There is no "previous test", in fact. There is: one only: "Final-video.mp4". Today's attachment just shows what happens when I open the corresponding ".avs" in "VirtualDub", as explained below:
Then:
today, and since you advised, I still wanted to check for possible errors. So I simply pasted an AVS example I found (other post), and modified it to my needs:
Code:loadplugin("C:\Program Files\AviSynth 2.5\plugins\ffms2.dll") FFVideosource("Final-video.mp4")
= the original video (since I appended a clip, used as a title in this case, to position 1; the original / untouched video i.e. tree leaves: follows).
I hope this explanation clarifies. But I can try to post a detailed step-by-step of my manipulations... as soon as possible.Last edited by bulgom; 11th Nov 2015 at 12:50.
-
It works for me when I append a random video to your video with that procedure, no errors when indexed with ffms2 or lsmash
Upload the encoded segment, and final video along with the steps you took -
·
· I'm sure not familiar with indexing. I only used "AviSynth / ffms2", not "lsmash"...
· My final video result: in attached ".7z" archive, and named "z_RESULT_joined-video_silent.mp4"
Appending a clip — named "TITLE-to-append.avi" — to an original AVC H.264 MP4 video, of more or less unknown (sub)characteristics,
without recoding the original video: "_ORIG.mp4"
———— s t e p s ————
Edited Nov. 13th, 2015 (you may cross your fingers (today only)).
The appended clip, i.e. "TITLE-to-append.avi", has to be recoded: no problem. It will be used as a title, or end credits, or even as some insert (in that case after cutting the original video in two parts). Here, I'm "appending" "TITLE-to-append.avi": BEFORE "_ORIG.mp4".
Although the "SPS-ID" method allows appending "just about anything", I of course prepared "TITLE-to-append.avi": as close as... I could, specs. wise, to "_ORIG.mp4" (using "MediaInfo" to gather those specifications).[ In example: an "AVC H.264" .avi, initial "HuffYUV" .avi version being too heavy in MB. ]
1. Recode "TITLE-to-append.avi" to "T.264"
+ extract raw h.264 video * stream only from "_ORIG.mp4" (to "_ORIG_track1.h264")
+ join "T.264" and "_ORIG_track1.h264" to "z_RESULT_joined-video_silent.mp4"
+ delete all .264 and .h264 (intermediate) files; original video: untouched:
[ * Audio: ignored for now (modified later + remuxed: last step(s). ]
Code:@echo on x264\x264 --crf 18 --profile baseline --level 3.0 --ref 2 --keyint 30 --bframes 0 --sar 1:1 --force-cfr --fps 30000/1001 --sps-id 2 -o T.264 TITLE-to-append.avi MP4Box\MP4Box -raw 1 _ORIG.mp4 copy /b T.264 + _ORIG_track1.h264 O.h264 MP4Box\MP4Box -add O.h264 z_RESULT_joined-video_silent.mp4 @echo off echo. echo. echo. echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ echo ³ HIT ANY KEY TO EXIT ³ echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ echo. echo. pause >nul del /q *.264 del /q *.h264
post #19 subedit · Above: I think I should point that someone who... knows what they're doing (i.e.: as opposed to me), wrote the "x264" command line line for me.[2. Rework audio stream so that everything synchs, convert it to ".aac", and mux it with "z_Final-video.mp4", using "Yamb/MP4box". Or convert the ".wav" to ".aac" along remuxing ("Video output" set to "copy"), using "AviDemux" = no desynch. Finally, in some cases, send "moov-atom" to header, as "AviDemux" does not, or too slowly (but "Yamb/MP4box" does, systematically). ]
3. Test to several media players; but: not 100% reliable! So: install "AviSynth 2.58" + add its "ffms-2.17" plug-in. And drop the below ".avs" script to "VirtualDub", to check for possible errors.
Code:loadplugin("C:\Program Files\AviSynth 2.5\plugins\ffms2.dll") FFVideosource("z_Final-video.mp4")
[ Todo / bonus step: (still) batch as much as I can, of the above steps, hoping to escape the gallows pole my friends are dragging me to (knowing they asked! But they shouldn't no more, since new edit)... ]
Last edited by bulgom; 13th Nov 2015 at 07:19.
-
I think I see the problem - this is a non standard stream . There is no deblocking control flag present. This means the flag isn't preset at all . Not that the flag is present and turning deblocking either off/on . I don't know of any encoder that does this ; you can't do it with x264 unless you modify the source. Can you tell me what the source of the original video is ?
-
.
(Just passed a call) According to the friends who asked what to do, it comes from a "Xacti" little camera.
So, no, not a cell phone video, but may be not very far from some of those, that sometimes don't respect stds. much. I've had quite a lot of problems with cell phone videos, especially dated from 2005 - 2010...
Last edited by bulgom; 11th Nov 2015 at 17:08.
-
You're allowed to change deblock alpha,beta values in different GOP's (for example some BD encoders do this) , but you're not allowed to change flag present to no flag present midstream. (--no-deblock is actually flag present indicating disable deblocking) . I don't think there is any software encoder that can do this (no deblock control flag at all) , unless you make a custom build. I'll look at it closer and see if there is workaround
-
.
What I'm wondering is: in what case / with what players will we have problems, with those "SPS-IDed" joined videos? Standalone ones, may be? Probably difficult to answer...
... and I remind that all the "Windows" based players I tested display the result perfectly.
So far anyway, it's ONLY the ".avs", once dropped to "VirtualDub", that displays the 2nd segment (= the orig. video, in my example) wrong.
Also, how come the join you tested ealier — using my sample + some random added clip — does not show that problem?
-
It didn't show a problem in the version of ffms2 or l-smash or dgdecodenv that I was using (your joined clip doesn't either), or potplayer, or ffplay . It also works in Adobe, Sony Vegas, professional programs.
But doing some more testing I found MPCHC using GPU decoding had a problem with the joined file (both yours and mine), even though DGDecodeNV (which uses GPU) decoded it correctly. It might be "good enough" for your purposes , but I would still classify it as a "failure" in my opinion even if it works in 99% of players and applications. If you look closer at the bitstream, there is a mismatch as mentioned above. I think that is the underlying problem . Mismatches of common or typical settings usually don't matter, but this one is rare but appears critical that will cause at least one decoder to fail. (You can overwrite SEI metadata, and mediainfo will show 1 set of values when you join it, it's not a metadata issue as mentioned earlier.)
Beware that certain versions of ffms2 are very buggy. The newer versions are very problematic. Most people tend to use l-smash now, it's more stable and doesn't have problems with interlaced AVC transport streams (ffms has had problems with those for years)Last edited by poisondeathray; 11th Nov 2015 at 17:51.
-
.
OK, all clear.
Woops! Forgot to test "MPCHC" (no very serious)... Let me fix.
Done:
well, my old 1.3.2225.0 MPCHC version anyway (I stick to it to for some reasons...) also displays perfectly.
But I sure took note that there is some problem.
About double display by "MediaInfo", OK; I don't mind that.
"ffms2": I used 2.17, as (latest) 2.2something didn't work at all, in my case. OK, gonna have to learn how to use "l-smash"...
Edits you added above (+ so did I): OK: didn't miss them: I read "backwards" too.Last edited by bulgom; 11th Nov 2015 at 18:11.
-
ok it might be a specific decoder version of mpchc, I'll have to trace the path / decoder, it might have been using the iGPU. But my potplayer was using GPU too, but played/seeked it fine as well (and DGDecodeNV uses the 2nd GPU , Nvidia)
I added some edits above - It works fine in professional programs like Adobe , Sony Vegas, etc.. so that should make you feel better. Even quicktime plays it fine. But still there is at least one decoding situation that fails. I would discount your ffms2 test until you try a different version of ffms2 (or lsmash), since certain versions are very buggy
So still it seems to work fine in 99% of programs, it just might have been buggy decoder. But I suspect if that flag setting is matched, it will work in 100% of programs
That double display is an SEI / metadata issue. I used a patched build that changed the entries (but not the actual video bitstream), and mediainfo no longer displays the issue (but still that version of MPCHC has problems with it) -
.
I think the next test would be: standalone players — but I wonder which, as I don't use any. I need my friends to test in their gadgets: cell phones players...
Since it seems to work 99%, I could may be consider that, in case of a problem, they'd have to recode the whole thing — from the joined version itself, since even "Vegas" doesn't bark. Btw: thanks for testing "Vegas" *, as I didn't.
* Plus OK in "VirtualDub", "AviDemux", "AviUtl", "Womble MPEG Video Wizard"
...
Last edited by bulgom; 11th Nov 2015 at 18:56.
-
It's definitely a problem with your ffms2 version, because the one I'm using doesn't show it on your clip. (or it might be the way you are loading it into vdub, make sure you're not using the ffmpeg source driver, manually select the AVI input driver. File=>file information should not say "ffmpeg")
In general, it's not necessarily a problem with the MPCHC or configuration I'm using - because other clips joined in the same manner (either from other devices or other software encoders) work fine in that same MPCHC version (or in other software or even hardware devices) . So it's something specific to your clip, and I think it's that flag present/absent -
.
Or also and "simply", a problem (or part of it) due to the — prehistoric — Win. XP PC I'm using! But well, my Win. 7 one (not young either) is almost always busy recoding stuff (since it's faster)... Above all, I'm curious about the smartphones reaction / but will have to wait.
"VirtualDub info." says:
AviSynth script · 0 h : 0 min : 12.51 sec · 0.00 sec · 0 kb/sec · 1
rawvideo · yuv420p (?) · 640 x 480 · 1 : 1 · 29.97 fps · N/A
____________________
(edit) 1st response: OK! I just "provided" some other friends with the method — warning them clearly about my little problem. I must say that those are not faint-hearted and don't bark "after" me because of "XX" mouse clicks! Believe me: they LOVE it!! and called me a geniusfor... 1 (whole) mn (aaah, feels GOOD once in a while...), until I disappointed them, telling where it actually comes from...
____________________
About l-smash: can't find a simple guide. "LSMASHSource.dll" 32-bit v° is now in "AviSynth" plugin folder. My l-smash .avs syntax is probably wrong, I don't know. "VirtualDub" keeps displaying an error msg.: "Can't open...". Should I add / install "libav"? I don't get it... Below + other tries just don't work:
Code:LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\LSMASHSource.dll") LSMASHVideoSource(source="z_FINAL-VIDEO.mp4", track=0, threads=0, seek_mode=0, \ seek_threshold=10, dr=false, fpsnum=0, fpsden=1, stacked=false, format="")
Last edited by bulgom; 12th Nov 2015 at 06:08.
-
For l-smash, do you have the requirements? especially vcredist_x86 ?
http://avisynth.nl/index.php/LSMASHSource
Requirements
AviSynth 2.6.0 or greater
Supported color formats: RGB24, RGB32, YUY2, Y8*, YV12, YV16*, YV24*, YV411*
* These additional planar colorspaces are not available in AviSynth 2.5.8.
Microsoft Visual C++ 2013 Redistributable Package (x86 / x64)
** vcredist_x86.exe is required for L-SMASH-Works-32bit
** vcredist_x64.exe is required for L-SMASH-Works-64bit
Code:LSMASHVideoSource("PATH\video.mp4")
In your list for post #19, it doesn't make sense to wrap it into mkv with mkvmerge then extract it with mkvextract (it doesn't make sense to use mkv* anything for your specific case)
If you're making a batch "intro", that only has to be done once as elementary stream for audio and video. If you're making a .bat command, batch demux the source file with mp4box to a temp folder, append the A&V , mux into mp4, delete the temp files - in that order; that's all done using a dos for loop (each source video is sequentially processed in the batch with those commands)
Similar Threads
-
[how to] Overlay image title(s) on AVC H.264 video - without recoding
By bulgom in forum SubtitleReplies: 11Last Post: 1st Nov 2015, 20:53 -
Editing MP4 files with H.264 (AVC) video and AAC audio
By Ahari in forum Newbie / General discussionsReplies: 4Last Post: 16th Apr 2012, 16:30 -
AVI container encoded with H.264/AVC video and PCM sound
By LoLaha in forum Video ConversionReplies: 6Last Post: 20th Mar 2012, 22:14 -
RGB video as H.264/AVC's input
By krao in forum Newbie / General discussionsReplies: 2Last Post: 24th Oct 2011, 10:27 -
Video Player for MPEG-4 AVC/H.264
By wingspar in forum Software PlayingReplies: 3Last Post: 15th Jun 2011, 22:56